Search code examples
google-analyticssingle-page-applicationanalyticsgoogle-tag-manager

Tag assistant shows duplicate GTM tags


I have a small website where I used Barba.js to create smooth transition between pages. So it won't load a new page completely fresh, but rather load the content in background using AJAX and add it to the existing document.

So to fire Google analytics page view event, I use History change trigger in GTM. And it seems to be working fine. in GA it is recording the page views correctly. But in Google Tag Assistant, it keeps increasing the count of GTM tag on every page load. And I have checked it is not adding GTM tag on page loads. It only adds a main content container to the document which doesn't contain GTM tag.

Here is the TAG Assistant screenshot after a 3rd page load : enter image description here

The Google analytics page view event is fired 3 times which is correct, but the GTM is also recorded 3 times.


Solution

  • This is a common behavior of Google Tag Assistant with single page website. The plugin is unable to detect single-page transitions correctly, so it will report the GTM container loading for each new URL when in fact the container has only loaded once.

    To understand if it is not actually loaded multiple times, try to open the Network requests of your browser's developer tools and look for requests for gtm.js, If you only see one per page loaded there are no problems.