On a traditional website, every click loads a new HTML page and the analytics script runs again. A single-page application loads once and then swaps content in place, updating the address bar with JavaScript. If the analytics script only counts page loads, a visitor who opens ten screens looks like a visitor who saw one page and left.
How route changes happen
Most SPA routers use the browser's History API. Moving to /pricing calls history.pushState, and the back button fires a popstate event. The address changes, the page does not reload.
Some routers use the hash instead: https://example.com/#/pricing. Here the part after # holds the route, and the browser fires hashchange when it changes.
A tracking script for SPAs has to listen for these changes and send a page view for each one, with the new address and the previous page as the referrer.
How Reveata tracks SPAs
The Reveata script handles History API routing on its own: it records a page view on every history.pushState, replaceState and back or forward navigation (Install the script). React, Next.js, Vue, Nuxt, SvelteKit, Angular and other frameworks have their own setup guides under frameworks and site builders.
For hash routers, add data-hash="true". Each hash route then counts as its own page, stored as a path like /app/#/settings/billing. A plain anchor such as #pricing is still ignored, because on ordinary sites it only points to a heading. Query strings inside the route are filtered the same way as normal ones, keeping only campaign parameters such as UTM tags and ad click ids (Hash-based routes).
| Router setting | Needs data-hash |
|---|---|
Vue Router createWebHashHistory() |
Yes |
React Router createHashRouter or <HashRouter> |
Yes |
Angular withHashLocation() or useHash: true |
Yes |
| Any router in History mode | No |
If you want full control, set data-auto="false" and send page views yourself with reveata('pageview'), for example for virtual pages inside a wizard.
Common mistakes
- Double page views. Adding a manual page view call on route change while automatic tracking is on counts every screen twice.
- Changing only the query string. In Reveata, a change of the query string alone is not a new page, which keeps filter and sort controls from inflating page views.
- Goals before the first page view. A goal needs a visit, and only a page view starts one. With
data-auto="false", send the page view first. - Hash routes in filters and funnels. With hash routing, include the hash in goals and filters:
/#/checkout/done, not/checkout/done.
Checking it works
Open your app, click between a few routes and watch the realtime view. Each route should appear as its own page. Adding data-debug="true" to the snippet logs every page view the script sends in the browser console.