next/script component in your root layout so it runs on every page. Client-side navigation between routes is tracked automatically, so you don’t need to wire anything into the router.
Before you start
- A tinyanalytics site. If you don’t have one yet, follow the Quickstart.
- Your site’s numeric site ID, from Settings → Tracking in your dashboard.
Add the tracking script
- App Router
- Pages Router
Add a
<Script> to your root layout, app/layout.tsx:app/layout.tsx
Client-side navigation is tracked automatically
Next.js renders route changes on the client, and tinyanalytics records each one as a new pageview by default (data-track-spa). You don’t need to hook into next/navigation or the router — moving between pages is captured for you. See Track single-page apps if you want to change this.
Verify
Deploy or run your app, open it in a browser, then check Realtime in your dashboard for your visit. See Verify your setup for the full check.Your install is working when your own visit appears in Realtime in your dashboard.
Related
Install on React
A plain React or Vite app instead.
Configure the tracking script
Every
data-* option, passed as a <Script> prop.Track custom events
Send events from your components.
Verify your setup
Confirm tracking works.