Next.js apps usually sell something: a SaaS plan, a course, a product. Reveata fits the way Next.js is built, with a component for the browser and helpers for route handlers and server actions, so revenue attribution is a few lines rather than a project.
What you get
- Every page view, App Router and Pages Router, client-side navigation included.
- Goals, identify and payments from typed helpers:
trackGoal,identify,trackPayment({ email })for a thank-you page,resetVisitor()on log out anddecorateUrl(url)for links you open from code. - Broken links (404) with the page that linked to them, from
<ReveataNotFound />inapp/not-found.tsx. - Opt-in extras: file downloads, form submissions and web vitals.
- Server-side ids for checkouts, through
readTrackerIdsfrom@reveata/next/server.
Two ways to install
The script tag, no package:
// app/layout.tsx
<Script src="https://reveata.com/js/script.js" data-website-id="ws_your_tracking_id" strategy="afterInteractive" />The package: npm install @reveata/next, then render <Reveata /> once in the root layout (or pages/_app.tsx). Its options include cookieless, domains, excludePaths, hash, api, respectDnt and enabled, for example enabled={process.env.NODE_ENV === 'production'}. Next.js's own Script component is documented in the Next.js Script reference (opens in a new tab).
Linking payments to visits
In a route handler or server action that creates a checkout, read the Reveata cookies and pass the ids on:
import { cookies } from 'next/headers';
import { readTrackerIds } from '@reveata/next/server';
const ids = readTrackerIds(await cookies());
// put ids.visitorId / ids.sessionId in the checkout metadataFor Stripe, that means metadata.reveata_visitor_id and metadata.reveata_session_id on the Checkout Session (Stripe Checkout attribution); clientReference(ids) gives the dt_… string for client_reference_id. Other payment providers take the same keys in their own custom data. If you bill yourself, ReveataApi from @reveata/next/server sends payments with a website key (Payments API).
Serving the script from your own domain
A Next.js app can proxy the script and events itself with rewrites and a proxy secret, so fewer visits are lost to ad blockers. See the Next.js section of Proxy through your own server, or use the managed proxy.