Before you start
Create a free Cool Analytics account and add your site. You'll get a site ID — replace YOUR_SITE_ID in the code below with it. The dashboard shows the snippet with your ID already filled in.
Install on Remix & React Router
- 1Open app/root.tsx.
- 2Inside the <head> of your Layout (or App) component, paste the script tag after <Links />.
- 3Deploy. Client-side navigations between routes are tracked automatically.
export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<Meta />
<Links />
<script defer src="https://coolanalytics.dev/hb.js" data-site="YOUR_SITE_ID" />
</head>
<body>
{children}
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}Check that it works
Open your live site in a new tab, then open your Cool Analytics dashboard. Your visit appears on the live map within seconds — with the page you're on, where you came from and your browser.
Nothing showing up? Make sure you're looking at the published site (not a preview or editor), that an ad blocker isn't blocking the script, and that you're not testing on localhost.
Track signups, purchases and clicks
Pageviews, sources, countries and outbound link clicks are tracked automatically. For the moments that matter to you, send a custom event. Events named like a signup show up as signups, and events with an amount show up as revenue — on the live map and per traffic source.
// anywhere in your Remix & React Router site's browser code
window.hb?.track("signup");
// with an amount, it shows up as revenue
window.hb?.track("purchase", { amount: 49 });Remix & React Router tips
- Client-side route changes are tracked automatically — the script listens to the browser history, so there's no router hook to wire up.
- Track successful form actions on the client, e.g. in a useEffect that runs when fetcher.data shows success.
- Visits from localhost are ignored so your own development doesn't count. To test locally, add data-dev="1" to the script tag for a moment — then remove it.
Want to keep your own visits out of the stats? Open your site once with #hb-ignore at the end of the URL. That browser is excluded until you visit with #hb-track.
Remix & React Router analytics FAQ
Does it work with React Router v7?+
Yes. Framework mode uses the same root.tsx structure, so the same snippet applies.
Is it compatible with SSR streaming?+
Yes. It's a normal deferred script in the head, so it doesn't interfere with streaming.
Can I track events from a loader or action?+
No — those run on the server. Call window.hb?.track() in the browser after the action succeeds.