Fathom Not Tracking Page Changes in Next.js and SPAs
Quick answer
In single-page apps, client-side navigation doesn't reload the page, so Fathom only records the first view unless you add data-spa="auto" or call trackPageview on route changes. In Next.js App Router, use fathom-client with auto: false and a client component.
Most likely fix: Plain script: enable SPA mode
How to fix it
Try these in order — the most common fix is first.
1. Plain script: enable SPA mode
- Add data-spa="auto" to the Fathom script tag (uses the History API, falls back to hash changes)
- Use data-spa="history" or "hash" if you only use one routing type
- Reload and click through a few routes while watching the real-time dashboard
Did this fix it?2. Next.js App Router: use fathom-client
- Run npm install fathom-client
- Create a client component ('use client') that calls load('SITE-ID', { auto: false }) once in useEffect
- In a second useEffect that depends on usePathname() and useSearchParams(), call trackPageview
- Wrap it in <Suspense fallback={null}> and render it inside <body> in app/layout.tsx
Did this fix it?3. Remove double tracking
- If you call trackPageview manually, make sure auto is false (or data-auto="false")
- Don't combine data-spa with manual route-change tracking
Did this fix it?
Symptoms
Only landing pages are recorded, pageviews are far lower than expected, or every pageview is counted twice.
Why it happens
- Script loaded without SPA mode, so history changes aren't tracked
- Next.js App Router component missing 'use client', Suspense, or the pathname dependency
- Both automatic and manual pageview tracking enabled (double counts)
- Framework navigation (e.g. Livewire wire:navigate) not firing a pageview
This guide also covers
- fathom next.js not tracking
- fathom analytics spa
- fathom-client app router
- fathom pageviews not tracking route change
Still not working?
If Fathom Analytics keeps failing, you're not alone. See every Fathom Analytics problem users report or the alternatives people switch to.
Done fighting Fathom Analytics? Our small team builds your own Fathom Analytics alternative, made for how you work. On your domain or hosted by us. Price agreed together.
Get a quoteOther Fathom Analytics errors
- Fathom Analytics Not Working (No Visits Showing)
- Fathom Only Showing Homepage in Stats
- Fathom Analytics Blocked by Ad Blockers
- Fathom Events Not Showing Up
- Fathom WordPress Plugin Not Tracking
- Fathom Numbers Different From Google Analytics
- Fathom Referrers Missing or Showing as Direct
- Fathom Google Search Console Data Not Showing