Remix
Add Rybbit analytics to your Remix app
Remix renders the whole HTML document from app/root.tsx, so the snippet goes in the <head> of that file and reaches every route.
Get your tracking snippet
In your Rybbit dashboard, open Site Settings → Tracking Script and copy your snippet. It looks like this:
<script src="https://app.rybbit.io/api/script.js?siteId=YOUR_SITE_ID" defer></script>YOUR_SITE_ID is the numeric ID of your site. If you self-host Rybbit, app.rybbit.io is the domain of your own instance.
Add the snippet to Remix
Open app/root.tsx (or app/root.jsx) and add the tag inside <head>, after <Meta /> and <Links />:
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "@remix-run/react";
export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
<script src="https://app.rybbit.io/api/script.js?siteId=YOUR_SITE_ID" defer></script>
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}Restart the dev server after the change. Client-side navigation after the initial server render is tracked automatically as pageviews.
Verify installation
Open your live site in a new tab and click through a few pages. Within a few seconds the pageviews appear in the Rybbit dashboard.
If nothing shows up:
- View the page source and search for
script.js?siteId=to confirm the snippet is on the page. - Open the browser Network tab and check that
script.jsreturns200and thatPOSTrequests go to/api/track. - Disable ad blockers, or set up a proxy so the script loads from your own domain.
- See the script troubleshooting guide for other common causes.
Track custom events
Call window.rybbit.event() from any route or component. Check for window first, because Remix renders components on the server.
export default function OfferRoute() {
const handleClick = () => {
if (typeof window !== "undefined" && window.rybbit) {
window.rybbit.event("offer_claimed", { feature: "Special Offer" });
}
};
return <button onClick={handleClick}>Claim Offer</button>;
}Troubleshooting
- Pageviews missing after client-side navigation: this is rare. If it happens, call
window.rybbit.pageview()from a root-level effect that runs onuseLocation()changes; test the default behaviour first.
Next steps
- Track custom events such as signups, purchases and button clicks.
- Identify users to connect sessions to accounts.
- Proxy the script through your own domain to bypass ad blockers.
- Script attributes let you skip or mask URLs and tag events.