install
Analytics for Next.js, in one tag
A 1.2 KB core, no cookies and no stored IP. Replace YOUR_TOKEN with your site token to measure visits and sources, and connect Stripe, Lemon Squeezy, Paddle, or the revenue API to see the revenue behind them.
Copy your site token
It is in Dashboard → Settings → Install, inside the snippet. Before launch, you get a dashboard once we pick your account for the beta.
Paste the snippet
Once, in a place every page loads. Replace YOUR_TOKEN with your token.
import Script from 'next/script'; export default function RootLayout({ children }) { return ( <html> <body> {children} <Script src="https://api.getvero.dev/ t.js ?s=YOUR_TOKEN" strategy="afterInteractive" /> </body> </html> ); } Use next/script with afterInteractive. The optional SPA module auto-tracks App Router navigations.
Deploy and open your site
Vero counts visits to your domain and its subdomains, so a localhost test never shows up. With the snippet live, open your site in another tab: your dashboard notices the first visit by itself.
Where the tag lives in a Next.js app
The root layout in app/layout.tsx wraps every route, so it is the only place the tag needs to go. Load it with next/script and strategy afterInteractive, inside the body after children, the way the snippet does.
App Router navigations never reload the document, so the core alone would count only the first page of each visit. The SPA module patches the History API when the script loads and sends a pageview every time pushState, replaceState or popstate changes the path or the query. It covers the Pages Router the same way.
You do not have to pick modules by hand. When you add a Next.js site, Vero reads your home page, spots __NEXT_DATA__ or _next/static, shows the Next.js snippet and turns SPA on, with scroll, engagement, outbound and leave. Change the mix per site in Dashboard → Settings → Install.
If you would rather send nothing from the browser, middleware.ts can report pageviews from the edge, signed with the ingest secret from Site settings → Sales. Ad blockers cannot stop it and it works with JavaScript off, but you give up what only the browser knows: scroll, engagement, Web Vitals and client-side routes.
Troubleshooting
Visits from my Vercel preview never show up
Once your site has a domain, Vero only counts beacons whose origin is that domain, its www or apex twin, or one of its subdomains. A *.vercel.app deployment is another host, so the dashboard labels it a preview and ignores its visits. To check a preview without touching your numbers, start an install test and open the preview URL.
Frequently asked
Does the Pages Router work too?
Yes. The SPA module listens to the History API, which both routers use, so route changes in either one become pageviews.
Do query string changes count as new pageviews?
With the SPA module on, yes: a change to the path or the query is a pageview. A change to the hash alone is not.
Can I track from middleware.ts and skip the client script?
Yes, with the site's ingest secret. Every page request is counted, but scroll, engagement, Web Vitals and client-side navigations need the script in the browser.
After the tag
- Connect your revenuePaste one webhook URL into Stripe, Lemon Squeezy or Paddle and each sale arrives with its visit.
- Send your own eventsA signup, a click on a plan: point a goal at the event and get its conversion rate.
- Pick your modules9 optional modules, such as SPA routes, scroll or Web Vitals, turned on per site.
Ask for a place in the beta.
Anyone can join the list. The accounts we pick get Pro free for the whole beta.