Google Tag Manager's History Change trigger will fire a tag when the URL fragment changes or when a site uses the HTML5 pushstate API. This trigger is useful to fire tags that track virtual pageview in single page web applications.
To create a new history change trigger:
- Click Triggers New.
- Click Trigger Configuration and choose the History Change trigger type.
When a history change event occurs, Tag Managers populates the following variables:
- History old url fragment: What the URL fragment used to be.
- History new url fragment: What the URL fragment is now.
- History old state: The old history state object, controlled by the site's calls to pushState.
- History new state: The new history state object, controlled by the site's calls to pushState.