On a traditional website, every new page gives you a fresh start: the browser loads a document, GTM loads again and the data layer begins empty. A single-page application (SPA) changes the screen without loading a new document. Much of what you assume about tracking stops being true, and the common result is not missing data but too much of it.
What changes when the page does not reload
In an SPA, the application rewrites the visible content and updates the URL, usually through the browser's History API. GTM loads once. That has three consequences:
- A trigger based on page load does not run again when the screen changes.
- Listeners and Custom HTML tags stay in memory across screens, unless something removes them.
- Data layer values stay too. Google says a variable persists only as long as the visitor remains on the current page, and in an SPA the browser never leaves that page.
So there are usually three separate problems to solve: counting page views once, keeping values current, and stopping listeners from stacking. They have different causes, so check them separately.
Choose one source of page views
Duplicate page views usually come from two systems both trying to help. There are three common sources, and you should use only one:
- GA4 enhanced measurement. With page changes based on browser history events turned on, GA4 reacts to
pushState()andreplaceState(). It needs no development work, but you have little control over timing.
