Analytics and Tracking

Single Page Application Tracking

Also called SPA tracking

Setting up analytics on a site that swaps content without full page reloads, so each new screen is still recorded as a page view.

Quick facts: Single Page Application Tracking

Category
Analytics and Tracking
Also called
SPA tracking
Level
Advanced
Affects
Page view counts, landing page reports, funnels, ad platform conversions
Where to see it
GA4 enhanced measurement settings, GTM preview, GA4 DebugView, browser developer tools
In this article4
  1. How single page application tracking works
  2. Why it matters
  3. Common mistakes
  4. How to act on it

Single page application tracking is the setup that makes analytics record page views and events correctly on a site that changes what you see without loading a new page. Sites built with React, Vue, Angular or similar frameworks often work this way, and without extra configuration they can report one page view for an entire visit.

How single page application tracking works

On a traditional site, every click loads a fresh HTML page and the analytics tag fires again, so each page is counted. A single page application (SPA) loads once, then uses JavaScript to swap content in and update the address bar through the browser’s History API. The tag only loaded once, so unless something tells it the view has changed, it records nothing new.

There are three common ways to close the gap:

  • GA4 enhanced measurement. The page view setting includes an option to count page changes based on browser history events. It works on many SPAs with no code, but it fires as soon as the URL changes, sometimes before the page title has updated.
  • A history change trigger in Google Tag Manager. A history change trigger fires your page view tag on each route change, giving you control over timing and which values are sent.
  • Developer-pushed events. The application pushes a virtual page view to the data layer once the new screen has rendered, with the correct path and title. This is the most reliable option because the app knows exactly when a view is complete.

Why it matters

Untracked SPAs produce reports that look plausible but are wrong. Pages per session drops to one, landing page reports credit everything to the home page, and funnels that depend on reaching a confirmation screen show no completions. Ad platforms suffer too: if the Meta Pixel or Google Ads tag cannot see the thank-you view, it cannot record the lead, and automated bidding learns from bad data.

Consent is the other UK angle. Your cookie banner’s choice has to carry across every route change. A common fault is an SPA where the consent state resets or the banner re-renders on each view, which either annoys visitors or lets tags fire without valid consent under PECR.

Common mistakes

  • Counting twice. Leaving enhanced measurement’s history option on while also firing a GTM page view on history changes creates double-firing page views.
  • Stale titles and referrers. Firing before the new screen renders sends the previous page’s title, so reports show the wrong names against the right URLs.
  • Data layer values that never clear. A product value pushed on one screen can still be present on the next, attaching itself to unrelated events.
  • Counting every query change. Filters and sort options that only change a URL parameter can trigger page views you do not want, inflating counts. Decide which route changes deserve a page view.

How to act on it

Start by checking whether you have a problem. Open the site with GTM preview or GA4 DebugView, click through four or five screens and watch whether a page_view arrives for each one with the right path and title. If it does not, agree with your developer which of the three methods to use, then switch off the others so nothing double counts.

SPA tracking overlaps with JavaScript SEO, since the same rendering choices affect what search engines see. Getting both right on ad landing pages is part of my performance marketing service, because paid campaigns are only as good as the conversions they can record.

Do and do not

Do

  • Test page views across several screens before trusting reports
  • Fire page views after the new screen has rendered
  • Choose one method and switch off the others

Do not

  • Leave two page view methods running together
  • Assume consent persists across route changes without testing it

Questions people ask about this

How do I know if my site is a single page application?

Click a link in the main navigation and watch the browser tab. If the address changes but the page does not flash or show a loading indicator, and the browser's back button still works, it is probably an SPA or uses SPA-style navigation. Your developer can confirm which framework and router the site uses.

Does GA4 track single page applications automatically?

Partly. Enhanced measurement can count page views on browser history changes, and it is switched on by default for new data streams. It does not always send the right page title, and it does not cover events that depend on a screen being fully loaded, so test it rather than assuming.

Is a virtual page view the same as a real page view in reports?

In GA4, yes. A page_view event sent from a route change appears in the same reports as one from a full page load. What matters is that it carries the correct page location and title.

Related terms

Found this useful?

Share it, or ask an AI to summarise it

Back to the glossary

Knowing the term is the easy part

Applying it to your own site and budget is the work. Book a call and I will tell you what actually applies to you.