Analytics and Tracking

History Change Trigger

Also called History change, pushState trigger

A Google Tag Manager rule that fires when the address bar changes without the browser loading a new page.

Quick facts: History Change Trigger

Category
Analytics and Tracking
Also called
History change, pushState trigger
Level
Advanced
Affects
Page view counts, funnel reporting, landing page attribution
Where to see it
Google Tag Manager (History Change trigger), Preview mode, GA4 DebugView
In this article4
  1. How a history change trigger works
  2. Why it matters
  3. Where history change triggers go wrong
  4. How to get it right

How a history change trigger works

Older websites loaded a fresh page for every click, which gave analytics an obvious moment to record a view. Many modern sites do not. Applications built with frameworks such as React, Vue or Angular, and a good number of booking and checkout flows, redraw part of the screen and rewrite the address bar without the browser ever fetching a new document.

The browser still keeps a record of that change in its session history, and Google Tag Manager can listen to it. The History Change trigger fires whenever that record is updated — forwards, backwards through the back button, or sideways when only part of the address alters. It also exposes the previous and new addresses as variables, so a tag can send the correct one instead of guessing.

Why it matters

Without it, an entire application collapses into a single page view. Every step of a multi-screen booking flow, every filter and every product a visitor opens is attributed to whichever address they arrived on. Landing page reports become useless, funnels cannot be built, and the ad platforms receive conversions with no path behind them.

It matters more than it used to because so many small business sites now sit on themes and builders that behave this way in part — a filtered listing, a quick-view product panel, a multi-step form — without anyone being told that the site is now part application.

Where history change triggers go wrong

The first problem is over-firing. Not every history change is a new screen. Opening a filter, switching a tab, sorting a listing or jumping to an anchor can all rewrite the address, and a tag attached without conditions will report each one as a page view. The reported figures rise, nobody trusts them, and the site looks busier than it is.

The second is timing. The address changes before the new content finishes rendering, so a tag that reads the page title or a value from the page may capture whatever the previous screen left behind. That is how the wrong title ends up attached to the right address.

How to get it right

The dependable route is to agree with your developer that the application will push a named event into the data layer once a screen has finished rendering, and to trigger on that instead. It costs a short conversation and removes both problems at once.

Where that is not available, use the History Change trigger with conditions that exclude the changes which are not real screens, and take the address from the trigger’s own variables rather than reading it off the page. Then check the whole journey in Preview mode, watching for a first screen counted twice — the initial page load and the first history change often both fire — and confirm the sequence in GA4 before you publish the container. If the site is largely an application, treat single page application tracking as a design decision rather than a patch.

Do and do not

Do

  • Ask developers for a data layer event after each screen renders
  • Add conditions so filters and tabs are excluded
  • Take the address from the trigger variables, not the page

Do not

  • Fire a page view on every history change without conditions
  • Let the first screen be counted twice
  • Read the page title before the new screen has rendered

Questions people ask about this

Why does my single page app only record one page view?

Because no new document is ever loaded. The standard page view tag fires when the browser fetches a page, and an application that redraws the screen and rewrites the address bar never does that again after the first visit. You need either a history change trigger or, better, a data layer event pushed by the application when each screen is ready.

Why are my page views suddenly much higher?

A history change trigger with no conditions counts things that are not screens. Opening a filter, switching a tab, sorting a list or following an anchor link can all update the browser history, and each one is then reported as a view. Add conditions that exclude those patterns, or move to a data layer event that only fires for genuine screen changes.

Is a data layer event really better than a history change trigger?

Yes, where the developers can provide one. The application knows exactly when a screen has finished rendering and what it contains, so the event carries the right address, the right title and any details you need. A history change trigger only knows the address bar moved, and it learns that before the new content exists.

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.