Expand my Community achievements bar.

DTM Single Page App Hash Change GTAG

Avatar

Level 1

<!--

Start of global snippet: Please do not remove

Place this snippet between the <head> and </head> tags on every page of your site.

-->

<!-- Global site tag (gtag.js) - Google Ads: 804146465 -->

<script async src="https://www.googletagmanager.com/gtag/js?id=AW-804146465"></script>

<script>

  window.dataLayer = window.dataLayer || [];

  function gtag(){dataLayer.push(arguments);}

  gtag('js', new Date());

  gtag('config', 'AW-804146465');

</script>

This is the snippet that we are trying to implement via DTM in a single page application.

It is being implemented on all pages in a single page application funnel where it fires as non-sequential HTML on the hashChange.  The team I am working with is reporting that it is firing multiple times on each subsequent hashChange.  So on the first page it will be once, the second page twice, etc through the funnel until the last page is loaded per hashChange.

I want to know what the solution is to have this only fire once as implemented.

My understanding is that the dataLayer isnt being emptied because no actual page refresh is occurring. I have tried to clear the dataLayer at the end of the function , but it then deletes the data before ever sending it to GTM.

The tag will NOT fire as sequential javascript because it requires the src file to send information to GTM.

0 Replies