In a Single Page Application, the number swaps correctly on first load but not on later page transitions, because those transitions don’t re-fire the DOM Ready event the Tag depends on.
Symptoms
When visitors first land on the website, the number in the header swaps correctly. But as they navigate to other pages, the number stays the same. The Invoca Tag is already deployed through Google Tag Manager, triggered by the DOM Ready event. Applies to: Invoca Tag ScriptCause
In a Single Page Application (SPA), the initial DOM Ready event fires when a visitor first loads the website, but subsequent page transitions typically don’t trigger this event again — only the content within the page updates dynamically. Because the site has an SPA structure, the appropriate callback needs to fire again after the page’s content updates.Resolution
To make the Tag run again, callInvoca.PNAPI.run() once the page is fully loaded. In Google Tag Manager, you can set up an additional tag for this.
Identify the event your site fires when a page finishes loading, and use that event as the trigger for rerunning the Invoca tag. For example, one account had an event called “Loaded a Page” — configuring that event to trigger the rerun tag caused the Invoca Tag to execute again and swap the number correctly on each new page.
NoteYour engineering team will need to fire a custom event from your SPA so Google Tag Manager can “hear” it and respond by calling
Invoca.PNAPI.run().- When a visitor first lands on the site, the initial Invoca Tag run swaps the number in the header.
- As the visitor navigates, page content loads dynamically.
- Once a new page’s content is fully loaded, your custom event (like “Loaded a Page”) fires.
- That event is configured as the trigger for the rerun tag associated with the Invoca Tag.
- When the event fires, the rerun tag executes, causing the Invoca Tag to run again and update the header number for the new page.