How to Track Next.js App Router Pageviews Without Cookies
A step-by-step developer tutorial for tracking Next.js 14/15 App Router applications without cookies or consent banners.
To track Next.js App Router pageviews without cookies, add the 1.15 KB Analytics script to your root app/layout.tsx using next/script with strategy="afterInteractive". The script automatically hooks into history.pushState and history.replaceState to track client-side route changes seamlessly.
- Step 1: Obtain your Website UUID
- Step 2: Add Script to app/layout.tsx
- Step 3: Verify Route Navigation in DevTools
Step 1: Obtain your Website UUID
Sign in to Analytics by Sufyaan Studio, click "Create Website", and copy your unique website UUID.
Step 2: Add Script to app/layout.tsx
Import the Script component from next/script and insert the lightweight tracking script into the <head> of your root layout.
Step 3: Verify Route Navigation in DevTools
Open your browser Developer Tools (F12) -> Network tab, filter by /c, and navigate between pages in your Next.js application. You will see instant 204 No Content beacon responses for each client route change.
Guide FAQ
Start tracking your websites with confidence.
Create an account in 30 seconds. Up to 25,000 events free every month.
