FRAMEWORK INTEGRATION GUIDE

How to Install Analytics on Next.js

Seamlessly track pageviews, client-side route transitions, and custom events across Next.js 13, 14, and 15 applications with zero cookie consent banners.

Quick Setup: Next.js
By Sufyaan Studio ResearchVerified August 2026

To integrate Analytics by Sufyaan Studio with Next.js (App Router or Pages Router), add the Next.js <Script> component to your root app/layout.tsx file with strategy="afterInteractive" and data-web="YOUR_WEBSITE_ID".

KEY TAKEAWAYS
  • 1.15 KB featherlight tracker preserves Next.js speed
  • Zero cookie consent banners required
  • Automatic SPA client route change detection
  • Full support for custom conversion event tracking
PREREQUISITES
  • Next.js 13+ (App Router or Pages Router)
  • Your Website UUID from dashboard
STEP-BY-STEP IMPLEMENTATION

Installation Instructions

1

Add Tracker to app/layout.tsx

Import the Script component from next/script and place it in your root layout.

NEXT.JS SNIPPET (STEP 1)
// app/layout.tsx import Script from 'next/script'; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html lang="en"> <head> <Script defer src="https://analytics.sufyaanstudio.com/t.js" data-web="YOUR_WEBSITE_ID" strategy="afterInteractive" /> </head> <body>{children}</body> </html> ); }
2

Track Custom Events (Optional)

Dispatch custom conversion events on button clicks or form submissions.

NEXT.JS SNIPPET (STEP 2)
// Inside any client component: 'use client'; export function CheckoutButton() { const handleCheckout = () => { if (typeof window !== 'undefined' && window.analytics) { window.analytics.track('checkout_clicked', { plan: 'pro_annual' }); } }; return <button onClick={handleCheckout}>Upgrade Now</button>; }
FAQ & VERIFICATION

FAQ: Next.js Analytics Integration

Ready to track Next.js traffic with speed?

Create your account in 30 seconds and start tracking for $0.

analytics