Reputation: 1822
I have a problem with running of gatsby based pages with GTM scroll depth. The problem is that the gtm scroll depth isn't compatible with SPA and doesn't reset when moving to the next page. Does someone use any other script, to measure scroll depth, that is easy and fast to integrate with gatsby and gtm/ga?
Upvotes: 9
Views: 1760
Reputation: 484
If you installed gatsby-plugin-google-tagmanager
it will fire an event with each route change: gatsby-route-change
.
You need to fire gtm.load
on every gatsby-route-change
which will reset the scroll depth. (thanks @Andi for the hint)
Create a new trigger:
Create a new tag:
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'gtm.load'
});
</script>
When you preview the changes, when going from one page to another, you will see that
Upvotes: 2
Reputation: 307
You can change your page view tracking from gtm.historyChange
to manual data layer pushes of gtm.load
, which is one of the three event types which resets the GTM scroll depth trigger.
Upvotes: 3