Marketing · Side quest build

Build your own Hotjar

See where visitors struggle without recording their secrets. Hotjar charges $39–$99 per month — that’s $468–$1188 a year — for something you can replace with focused software of your own. Here is the honest scope, the honest timeline, and the exact prompt to hand your coding agent.

from 3 daysUseful if privacy-first

Who this replacement is for

This build targets a product team improving one public marketing or onboarding flow. The goal: understand clicks, scroll depth, and obvious friction while protecting visitor privacy. If you need more than that, keep paying — the point of building it yourself is owning a tool shaped exactly like your workflow, not re-implementing a venture-funded roadmap.

How long it actually takes

One number would be a lie, so here are three. Each tier is a real, usable product — pick the one that matches how much of Hotjar you actually use.

EstimateWhat you get
3 daysevent script, click counts, basic page dashboard
2 weeks+heatmap aggregation, scroll depth, rage clicks, filters
3 months+pixel-perfect session replay, funnels, cross-site identity — the part you should probably skip

What a minimal Hotjar alternative needs

Data model

Site, Session, PageView, InteractionEvent, HeatmapBucket

Integrations

first-party script endpoint

Capability context

Workers, Analytics Engine, Astro

The guardrail

Never capture form values, keystrokes, page text, exact IP addresses, or unsampled sensitive routes.

Deliberate non-goals

Do not recreate pixel-perfect session video, surveys, funnels, or cross-site identity.

The complete build prompt

Copy this into your coding agent of choice. It is scoped for a useful v1 — journeys, screens, business rules, data model, security, tests, and acceptance scenarios included. Pick your stack:

You are building a production-ready software product named “Warmtrail”, a deliberately focused alternative to Hotjar. Build a complete, usable vertical slice—not a landing page, static mockup, or disconnected collection of components.

WORKING AGREEMENT
Before writing implementation code, produce a short technical plan that names the routes or pages, server actions or endpoints, data tables, important state transitions, authorization boundaries, background jobs, and external adapters. Resolve contradictions in favor of the narrow audience and non-goals below. Prefer a small, legible architecture over speculative abstraction, but do not omit persistence, validation, error handling, or tests.

PRODUCT BRIEF
Primary user: a product team improving one public marketing or onboarding flow.
Primary outcome: understand clicks, scroll depth, and obvious friction while protecting visitor privacy.
Product principle: optimize the exact workflow below instead of copying the full breadth of Hotjar. A first-time user should understand what to do from the interface itself, without a tour or documentation.

END-TO-END USER JOURNEYS
Implement all of these flows through the real interface and persistent data layer:
1. The product owner registers a site, copies the first-party script, sets a sampling rate and excluded routes, then verifies a test pageview from the installation screen.
2. A sampled visitor moves through the public flow while the script records page transitions, normalized clicks, scroll buckets, and structural interaction events without capturing entered content.
3. The product owner filters a page by device and date, studies aggregate click and scroll maps, opens a structural session timeline, and identifies repeated rage clicks on one control.

SCREENS AND INFORMATION ARCHITECTURE
Build these as coherent responsive views. Each screen must specify its primary action, secondary actions, visible status, validation feedback, empty state, loading or pending state, success confirmation, and recoverable failure state.
1. Site setup: script snippet, allowed origins, sampling percentage, excluded route patterns, installation status, privacy checklist, and send-test-event action.
2. Overview: sampled sessions, pageviews, top pages, device mix, friction-event counts, date comparison, and clear sampling context beside totals.
3. Page insights: responsive page outline, click-density overlay, scroll-depth distribution, device selector, minimum-sample warning, and element-level click ranking.
4. Session and friction explorer: privacy-safe event timeline, navigation and viewport changes, dead or rage clicks, filters, retained-data notice, and no video playback.

CORE CAPABILITIES
1. small first-party event script with explicit sampling
2. page-level click coordinate aggregation
3. scroll-depth buckets and rage-click detection
4. session timeline using structural events rather than video
5. dashboard filters by page, device class, and date

DETAILED BEHAVIOR AND BUSINESS RULES
Treat these as server-enforced product requirements, not interface suggestions:
1. The collector must reject unapproved origins and excluded routes, apply explicit sampling before event collection, and cap events per session and request.
2. Never collect form values, keystrokes, selected text, DOM text, accessibility labels containing user data, or events originating from password and contenteditable fields.
3. Normalize click coordinates relative to the target element and viewport bucket so events from different screen sizes can be aggregated without storing a page screenshot.
4. Classify rage clicks from a documented time, distance, and count threshold; discard full IP addresses after coarse request handling and expire raw structural events on schedule.

DATA MODEL AND LIFECYCLE
Design a small relational schema centered on Site, Session, PageView, InteractionEvent, HeatmapBucket. Before implementing it, document:
1. Each table’s purpose, primary key, ownership or tenant boundary, timestamps, status fields, and important attributes.
2. Foreign keys, uniqueness constraints, check constraints, indexes needed by the named screens, and transaction boundaries for multi-record changes.
3. The allowed lifecycle or state transitions, who may trigger each transition, which transitions are terminal or reversible, and what audit history must remain immutable.
4. Archive, retention, and deletion behavior, including what happens to dependent records and external files.
5. Idempotency strategy for submissions, jobs, imports, notifications, webhooks, or retries where applicable.
Use migrations rather than ad-hoc schema creation. Store time instants consistently and retain named timezone context whenever local schedules or dates matter. Never rely on a counter, disabled button, or client-side check to preserve a business invariant.

USERS, AUTHENTICATION, AND PERMISSIONS
Implement only the roles required by the stated audience. Make the ownership and visibility model explicit before coding. Enforce authorization in every server-side query and mutation, including search, exports, attachments, live updates, and guessed URLs—not merely by hiding controls. Use secure session defaults, protect state-changing requests, and provide an understandable signed-out, expired-session, and forbidden state. Seed distinct users when multiple roles are required so permissions can be demonstrated and tested.

INTERACTION AND VISUAL DIRECTION
The product should feel fast, calm, focused, and credible rather than like a generic admin template. Use a clear visual hierarchy, restrained color, readable typography, generous hit targets, and consistent placement for primary actions. Start with server-rendered HTML and progressively enhance only the interactions that benefit from it. The core workflow must remain understandable if enhancement fails.

Start with server-rendered Astro pages and ordinary HTML forms. Use HTMX for form submissions, partial navigation, and server-driven updates, then Alpine.js only for small local browser state. The core workflow must remain understandable if either enhancement layer fails.

Design mobile layouts intentionally instead of simply stacking desktop panels. Support keyboard navigation, visible focus, semantic landmarks, explicit labels, useful page titles, reduced-motion preferences, and screen-reader announcements for asynchronous results. Never use color alone to communicate state. Destructive actions require clear scope and confirmation; safe repeated actions should be idempotent.

TECHNICAL DIRECTION
Build this version with the AHA stack: Astro for routing, layouts, and server-rendered pages; HTMX for interactions that benefit from HTML fragment responses; and Alpine.js for small, local interface state. Prefer Cloudflare D1 for relational persistence, R2 for object storage, Workers for server endpoints and scheduled work, Durable Objects only for coordinated real-time state, and Workflows or Queues for durable background jobs—but only when the product requirements call for them.

Keep domain rules in testable server-side modules instead of route handlers or UI components. Separate persistence, external providers, and background work behind small interfaces without building a framework. Prefer ordinary HTML forms and URLs for durable navigation; use optimistic interaction only when failure can be reconciled clearly.

The product brief currently identifies Workers, Analytics Engine, Astro as capability context. Preserve any required native, browser-only, edge, storage, real-time, or background-processing capability through a narrow adapter appropriate to the selected framework. If the core workflow genuinely requires native or browser APIs, keep that runtime as the primary execution surface rather than simulating inaccessible capabilities or inventing an unnecessary web surface.

Integrate with first-party script endpoint. For every integration:
- List required environment variables in an .env.example without real secrets.
- Add a small adapter with timeouts, normalized errors, and a deterministic local fake or development path.
- Verify inbound signatures and deduplicate provider events where supported.
- Keep credentials server-side, encrypt long-lived provider tokens at rest, and redact secrets and sensitive payloads from logs.
- Define retry, backoff, and idempotency behavior for any side effect that can be repeated.

SECURITY AND PRIVACY
Never capture form values, keystrokes, page text, exact IP addresses, or unsampled sensitive routes.
Validate, normalize, and length-limit all untrusted input on the server. Escape rendered content by default, sanitize any intentionally accepted markup, rate-limit public or abuse-prone actions, and use private object storage plus short-lived authorized URLs for sensitive files. Collect the minimum personal data necessary for the named workflow. Document retention and deletion behavior. Add specific protections for the riskier surfaces in this app, such as uploads, redirects, outbound requests, email delivery, OAuth, webhooks, CSV import or export, and real-time connections.

ACCEPTANCE SCENARIOS
Automate these app-specific scenarios at the most appropriate level:
1. Given interaction with an email or password field, the collector records no value, keystroke, field text, or identifying selector while unrelated page events continue.
2. Given five rapid clicks within the configured radius on one element, one rage-click marker appears in the timeline and aggregate rather than five separate alerts.
3. Given a route matching the sensitive-route exclusion list, pageviews and interactions from that route are rejected even when the script is present.

TESTING
Add focused unit tests for state transitions, authorization predicates, normalization, date or money calculations, and other risky domain rules. Add integration tests for persistence constraints and each external adapter’s success, timeout, retry, and rejection paths. Add at least one browser-level test for every end-to-end journey above, including one small-screen viewport. Tests must use isolated data and run through a documented single command.

OPERATIONS AND FAILURE RECOVERY
Add structured server logs with request, job, or event correlation IDs but no secrets or unnecessarily sensitive data. Make failures actionable in both the interface and logs. Background work must expose pending, succeeded, failed, and retrying states where relevant; do not silently swallow errors. Include safe database migration and rollback guidance, seed data, backup and restore notes, external-data cleanup behavior, and a basic health or diagnostic path appropriate to the stack.

DELIVERABLES
Ship the working application, migrations, representative seed data, tests, .env.example, and a concise README. The README must cover prerequisites, local setup, environment variables, migrations, seed and test commands, deployment, integration setup, backup and restore, security decisions, and known limitations. Seed data should exercise the happy path plus at least one empty, failed, overdue, expired, archived, or permission-restricted state relevant to the product.

DEFINITION OF DONE
The app is complete when a fresh developer can follow the README, create and migrate the database, run the app, sign in as each relevant role, complete every named journey using real persisted data, refresh without losing state, recover from common failures, and use the core interface on phone and desktop. All acceptance scenarios pass, permission boundaries are covered by tests, and no core screen is left as a placeholder.

NON-GOALS
Do not recreate pixel-perfect session video, surveys, funnels, or cross-site identity.

Frequently asked questions

How long does it take to build your own Hotjar?

A basic version — event script, click counts, basic page dashboard — takes about 3 days. Roughly 2 weeks+ gets you a solid v1 with heatmap aggregation, scroll depth, rage clicks, filters. Matching everything Hotjar really does (pixel-perfect session replay, funnels, cross-site identity) is closer to 3 months+, which is exactly why you should scope down instead.

How much does Hotjar cost if I keep subscribing?

Hotjar runs $39–$99 per month on public paid plans, which is $468–$1188 per year. A focused self-built replacement costs your build time plus close-to-zero hosting.

What stack should I use to build a Hotjar alternative?

The build prompt on this page ships in four flavors: the AHA stack (Astro, HTMX, Alpine.js), Next.js, Laravel, and Ruby on Rails. The capability context for this product is Workers, Analytics Engine, Astro. Pick the stack you already know — the scope matters more than the framework.

What features does a minimal Hotjar replacement need?

A useful v1 needs: small first-party event script with explicit sampling; page-level click coordinate aggregation; scroll-depth buckets and rage-click detection; session timeline using structural events rather than video; dashboard filters by page, device class, and date. Everything else is scope creep until you personally miss it.

What should I deliberately not build?

Do not recreate pixel-perfect session video, surveys, funnels, or cross-site identity.

Prompt copied. Go ship it.