Start free
new

Single-page app add-on: #/ routes, back/forward restores and prerendering

Hash-routed apps otherwise look like one page, and back/forward-cache restores are silently missed.

An optional add-on for apps that use hash routes (#/settings), and for any site where people use Back and Forward a lot. The core script stays exactly as it is.

Why quietstats: you get this without cookies, a consent banner or storing IP addresses, in every plan including Free.

In every plan, including Free. Privacy and performance.

📘 Step-by-step guide, with screenshots and diagrams →

Start free, no cardSee live demo

  • No cookies or consent banner
  • No IP addresses stored
  • Groups under 5 visitors hidden
  • 845-byte script
  • Free plan, no card
Single-page app add-on: #/ routes, back/forward restores and prerendering: example screenshot with made-up demo dataSingle-page app add-on: #/ routes, back/forward restores and prerendering: example screenshot with made-up demo data
ExampleScreenshot with made-up demo data, not a real customer’s numbers.

What it is

spa.js sits next to script.js or events.js, or goes into a one-file bundle. With data-hash on the tag, each #/ route counts as its own page (stored as /app#/settings, without the route’s query part); plain #section anchors are ignored, and the first route on load is attached to the core script’s pageview rather than counted twice. Pages restored from the browser’s back/forward cache are counted, which the core script cannot see. The add-on’s own pageviews wait until a prerendered page is actually shown.

Why it matters

Hash-routed apps otherwise look like one page, and back/forward-cache restores are silently missed. Fixing both in an add-on keeps the standard script small and unchanged for everyone else.

How it works

  1. Add the add-on tag after your quietstats tag, with data-hash if your app uses #/ routes.
  2. Or open Manage site → One-file bundle, tick Single-page apps and Count #/ routes as pages, and use the one tag it gives you.
  3. Routes appear in Top pages as /path#/route.

Privacy: what is and isn’t collected

Collected

  • The #/ route as part of the page path (no query part)
  • Nothing else new: the same pageview as the core script

Never collected

  • Cookies or anything stored in the browser
  • Plain #section anchors
  • The query part of a route, such as ?token=…
  • Cookies, localStorage or anything else stored on the visitor’s device
  • IP addresses or user agents (used in memory, then discarded)
  • Anything that links a visitor across days (the visitor ID resets daily)

How quietstats works, and the legal caveats →

Rows and limits

  • The core script still counts its first pageview when a page is prerendered; only the add-on’s own pageviews wait for the page to be shown
  • Scroll and engaged time (data-engage) still attach to the page without its #/ route
  • spa.js is about 1.3 KB; script.js is unchanged at 845 bytes
  • D1: 1 row per counted route as for any pageview; the first-route fix-up updates the existing row (no new row)

“Rows” are database rows written, which is what our hosting is billed on. Reads are not rows written. Methodology →

Questions

Do I need this for React, Next.js or Vue?

Only if your router uses #/ URLs or you want back/forward-cache restores counted. pushState routers are already counted by the core script.

Will routes be counted twice?

No. The first route on load updates the core script’s pageview, and later route changes are counted once each.

Does it work with custom events?

Yes. Put it next to events.js, or tick both in the one-file bundle.

Related features

All privacy and performance features → · All features → · Docs: Single-page app add-on guide → · Compare features with other tools →

Guides on this topic

All website analytics guides →

Set it up
HTML
<script data-host="https://quietstats.co.uk" data-site="YOUR_SITE_ID" data-dnt="true" data-hash src="https://quietstats.co.uk/js/spa.js" async defer></script>

Replace YOUR_SITE_ID with the ID on your site’s settings page. Install guides →

Try it on your own site

Free during launch: one site and 5,000 pageviews a month, no card needed. After launch, paid plans start at £5 a month.

Start freeSee pricingSee live demo

Explore quietstats

See your traffic (119)

Live visitors and live eventsTrend charts, headline cards and any date rangeCompare any two date rangesWorld map, countries and regionsDevices, browsers, operating systems and screens

Sources and campaigns (63)

Sources and channelsAI search referralsUTM campaignsSearch keywords from Google Search ConsoleShort links

Behaviour and content (80)

Top pagesPage transitionsScroll depth and engaged timeClick mapVisitor journeys

Goals, events and conversions (83)

Goals and funnelsCustom events and conversion ratesRevenue cards and revenue by sourceEngagement goalsA/B tests with your own tags and a plain-English confidence note

Reports, sharing and alerts (44)

Alerts inbox and rulesReport snapshotsPassword-protected snapshotsOptional public stats pageAnonymous benchmarks against similar sites

Data in and out (42)

CSV and Excel downloadsStats APIImport from Plausible or GA4API playgroundTSV and XML export for every report

Privacy and performance (17)

Zero cookies, privacy built inUnder 1 KB script and single-page appsPages never countedPrivacy proof page and badge for your siteSigned-in sessions

Why quietstats

Why quietstatsPricingLive demoStart free

Compare

quietstats comparedFeature comparisonvs Google Analyticsvs Plausiblevs Fathom Analyticsvs Simple Analyticsvs Umamivs Matomovs Cloudflare Web Analyticsvs GoatCountervs Piwik PROvs PostHogvs Microsoft Clarityvs Pirsch Analyticsvs MixpanelGoogle Analytics alternatives

Learn

Website analytics guidesMetrics handbookAnalytics glossaryPlaybooksGDPR and cookie-free analyticsInstall on SquarespaceInstall on WixInstall on GhostInstall on Google Tag ManagerBlog

Playbooks and tools

Script size calculatorCookie banner checkerPlaybook: Local businessPlaybook: Online shopPlaybook: Blog or publisherPlaybook: SaaS or appPlaybook: Charity or community groupPlaybook: Agency with clientsUTM link checkerConversion rate calculatorCookie banner traffic-loss calculator