Guide

Install EazyStats in 2 minutes

Step-by-step guides to install EazyStats tracking code on your platform

Next.js

Next.jsNext.js Integration

Add EazyStats to your Next.js project

Follow these simple steps to integrate EazyStats analytics into your Next.js App Router (v13+) application.

1

Add tracking script to Root Layout

The recommended way to add scripts to all pages in a Next.js App Router application is by using the root layout file.

folder_openOpen your root layout file

Typically located at app/layout.jsx or app/layout.tsx

codeapp/layout.jsx
          import Script from "next/script";

                       export default function RootLayout({ children }) {
                        return (
                            <html lang="en">
                            <head>
                                <Script
                                data-website-id="your_website_id"
                                data-site-domain="yourdomain.com"
                                src="https://eazystats.com/tracker.js"
                                strategy="afterInteractive"
                                />
                            </head>
                            <body>{children}</body>
                            </html>
                        );
                        }
        
warning

Replace Placeholder Values

Important: Make sure to replace the placeholder values:

  • your_website_id → Your actual Website ID from EazyStats
  • yourdomain.com → Your website's root domain
info

Localhost Tracking

EazyStats is disabled on localhost to avoid tracking your own development traffic. The analytics will only work on your live website.

2

Verify installation

After deploying your changes, follow these steps to verify everything is working:

rocket_launchDeploy

Deploy and visit your live website

analyticsCheck Dashboard

View your dashboard for incoming data

scheduleWait

Data appears within a few minutes

2

Alternative: Using public/index.html

You can also add the script directly to your public/index.html file if you prefer:

codepublic/index.html
<script
  defer=""  data-website-id="your_website_id"  data-site-domain="yourdomain.com"  src="https://eazystats.com/tracker.js"
> </script>
lightbulb

Pro Tips for Next.js

speedApp Router: This guide is for Next.js 13+ with App Router. For Pages Router, add the script to _app.js
routeAuto Route Tracking: The tracker automatically detects client-side route changes in Next.js
settingsScript Strategy: We use afterInteractive for optimal performance
celebrationYou're all set!

Your Next.js app should now be tracking visitors with EazyStats. Check your dashboard to see your analytics!