Skip to content
Frameworks

React Router and Remix analytics

2 min read · Updated · By the Reveata team

Short answerIn React Router framework mode, including Remix apps moved to it, add the Reveata tag to the Layout in app/root.tsx. In declarative or data mode, paste it into index.html. Route changes are counted automatically, and an action can put the visitor id into your checkout metadata.

React Router now covers everything from a client-side router to a full-stack framework, the successor to Remix. Where Reveata goes depends on which of those you use; what it gives you is the same.

What you get

  • Every route counted through the History API, with no code in route components. Changes to the query string alone (?tab=2) are not new pages.
  • Form goals on React Router's <Form>, which renders a regular form: the goal counts on submit, even though React Router handles the submission.
  • Revenue attribution from actions that start checkouts.
  • First-party serving through the managed proxy, your Express server or your host's rewrites.

Where the tag goes

How you use React Router File
Framework mode (React Router 7 with react-router.config.ts, including Remix apps moved to it) The Layout in app/root.tsx
Declarative or data mode in a Vite app index.html at the project root
Hash routing (createHashRouter) Either of the above, with data-hash="true"

Framework mode works with server rendering and with ssr: false, because both render root.tsx into the HTML. Don't render the tag inside a route component: it would be added on every navigation. React Router's modes are explained at reactrouter.com (opens in a new tab).

Linking payments to visits

In framework mode a checkout usually starts in an action. Send the ids with the form from the browser (window.reveata.metadata() into hidden inputs), then add them to the checkout metadata on the server, for example a Stripe Checkout Session's metadata.reveata_visitor_id (Stripe Checkout attribution). If Reveata doesn't connect to your provider, send each payment from the action with the Payments API, but never both for the same provider.

Serving the script from your own domain

Frequently asked questions

I have a Remix app. Which instructions apply?

If it has moved to React Router 7 framework mode, use app/root.tsx. The tag goes in the Layout that renders <head>.

Does window.reveata have a TypeScript type?

No. Declare it once, for example declare global { interface Window { reveata?: { metadata?: () => Record<string, string> } } }.

Will localhost visits be counted?

No, unless you add data-allow-localhost="true".

See it with your own numbersReveata ties every visit and sale to the source that brought it. Add your website in a minute.
Get started
Was this page useful?
IntegrationReact app analytics for Vite and Create React AppPaste the Reveata snippet into the head of your React app's index.html, the root one for Vite or public/index.html for Create React App. The script counts route changes from React Router, TanStack Router or Wouter by itself, and window.reveata.metadata() passes the visitor id to your checkout.IntegrationExpress.js analytics with a first-party proxyPaste the Reveata snippet into the layout, static HTML or front-end index.html your Express app serves. Two Express routes can serve the script from your own domain with your proxy secret, and your checkout route can copy the visitor id into the checkout metadata.IntegrationStripe Checkout analytics and attributionAdd the Reveata visitor and session ids to the metadata of each Stripe Checkout Session your server creates. When Stripe reports the payment, Reveata reads the ids and credits the money to the exact visit that started the checkout.IntegrationAngular analytics with ReveataPaste the Reveata snippet before the closing head tag of src/index.html. ng build keeps it in the built page, server-side rendering included, and the Angular Router's History API navigation is counted automatically. HashLocationStrategy needs data-hash="true".IntegrationAstro analytics with revenue attributionPaste the Reveata snippet with is:inline into the Astro layout that renders the head of every page. Astro then leaves the tag as written, view transitions are tracked, and payment links or checkouts started from your pages are credited to the visit behind them.IntegrationDjango analytics with revenue attributionPaste the Reveata snippet before the closing head tag of the base template your Django templates extend. Every page is tracked, the Django admin is not, and two hidden form fields let your checkout view put the visitor id into the payment's metadata.