Fathom Not Tracking Page Changes in Next.js and SPAs

Share
Workaround available Web (Next.js, React, Vue, Livewire, SvelteKit) Updated November 13, 2026Based on 3 user reportsHow we research

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. 1. Plain script: enable SPA mode

    1. Add data-spa="auto" to the Fathom script tag (uses the History API, falls back to hash changes)
    2. Use data-spa="history" or "hash" if you only use one routing type
    3. Reload and click through a few routes while watching the real-time dashboard
    Did this fix it?
  2. 2. Next.js App Router: use fathom-client

    1. Run npm install fathom-client
    2. Create a client component ('use client') that calls load('SITE-ID', { auto: false }) once in useEffect
    3. In a second useEffect that depends on usePathname() and useSearchParams(), call trackPageview
    4. Wrap it in <Suspense fallback={null}> and render it inside <body> in app/layout.tsx
    Did this fix it?
  3. 3. Remove double tracking

    1. If you call trackPageview manually, make sure auto is false (or data-auto="false")
    2. 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 quote
Fixed it? Share this guide

Other Fathom Analytics errors

All 14 Fathom Analytics errors and fixes →