Next.js
App Router and Pages Router.
Use the Script component so the line loads on every route. Page changes inside the app are counted on their own.
App Router (app/layout.tsx)
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<Script defer data-site-id="YOUR-SITE-ID" src="https://spintaxifycms.com/js/analytics.js" strategy="afterInteractive" />
</head>
<body>{children}</body>
</html>
);
}
Pages Router (pages/_document.tsx)
Put the same Script line inside the Head of your custom document, or in pages/_app.tsx.
Deploy, then open the live site.
Check it works
Open your site in a normal browser window (not one where you are logged in as admin, if you excluded admin pages). Then open Analytics in Spintaxify. Within a few seconds Online now shows 1, and the setup card ticks Install the script.
Tip: your site ID is in Analytics → Settings → General. Copy the snippet from there and it is already filled in.
Something missing? Contact us and tell us what you were looking for.