Hello RudderStack team! I'm facing an issue using ...
# support
f
Hello RudderStack team! I'm facing an issue using Google Tag Manager as a destination. Problem is that it looks like RudderStack is sending 3 dataLayer.push. In particular: • This only happens if I have cookies stored • You can see from the screenshots that the datalayer is the same across the 3 duplicate events, except for that eventModel ◦ for one event it does not appear (this is the same behavior I see when debugging after removing cookies) ◦ for one event is completely empty ◦ and for another one, it shows the key/value structure, but yet empty Is there anyone else facing this issue? I've checked from the page Network and Rudderstack is only sending one track call. Have also checked, and there's no implementation done via Google Tag Manager. Events are only fired once via Rudderstack as they should. Thanks a lot!
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
Hi Fillippo, Are these scroll events? The scroll events are sent directly via the SDK. You can checkout these docs here on how to disable enhanced measurements (scrolls, outbound clicks etc)
f
Hi Ranhanath, they are scroll events in the sense that they track scrolling behavior, but these are setup as a custom events. Meaning, we're not using Google default ones but our developer took care of adding a script in the website to fire a track call to RudderStack when the user hits certain scrolls. Attaching the code 👇
<script> $(document).ready(function() { let timeSpentOnPage = 0; // in seconds let $blogPost = $('#blogPost'); // Section that determines the length let blogPostHeight = $blogPost.height(); let blogPostOffsetTop = $blogPost.offset().top; // Array to store all the scroll events let scrollEvents = [ {name: 'BLOG_SCROLL_50', percent: 50, triggered: false}, {name: 'BLOG_SCROLL_75', percent: 75, triggered: false}, {name: 'BLOG_SCROLL_90', percent: 90, triggered: false}, {name: 'BLOG_ONPAGE_120', percent: 85, time: 120, triggered: false} ]; // Increase time spent on page counter every second setInterval(function() { timeSpentOnPage++; }, 1000); $(window).scroll(function(e){ let scrollTop = $(window).scrollTop(); let scrollPercent = (scrollTop - blogPostOffsetTop) / blogPostHeight; // Adjust to section let scrollPercentRounded = Math.round(scrollPercent*100); scrollEvents.forEach(event => { if (!event.triggered) { if (scrollPercentRounded >= event.percent) { if (event.time) { if (timeSpentOnPage >= event.time) { rudderanalytics.track(event.name); event.triggered = true; console.log(event.name + "fired") } } else { rudderanalytics.track(event.name); event.triggered = true; console.log(event.name + "fired") } } } }); }); // Update height and offset when window resizes $(window).resize(function() { blogPostHeight = $blogPost.height(); blogPostOffsetTop = $blogPost.offset().top; }); }); </script>
To add on this, we have already disabled enhanced event measurement, hence why you do not see any default scroll event but only these custom, all caps events.
m
Can you share the website where this is happening and the destinationId. Thanks
f
pinata.cloud - 2KGe8K9uUQbwDTRS55hujGpQ9V8
m
I am wondering if this is because you have setup GTM, Google Ads and GA4 for the same source all in device mode. GA4 in device mode uses gtag under the hood (Have to confirm if google ads in device mode does the same, but I think it does) . Can you disable one of the destinations say GA4 and check?
f
Have tested what you recommended: disabled all GA4 destinations, then deleted cookies and tested on new tab, but it did not work. Events are still fired 3 times
m
Oh ok. Let me see if the team can help on this.
h
you really should be debouncing scroll events ^^
f
What do you mean by that @hundreds-lifeguard-65770?
h
scroll/resize can fire hundreds of times per second giving very inconsistent behaviour/bugs
so always debounce to ensure only one handler is fired every n milliseconds
m
This is something new I learned today. Thanks @hundreds-lifeguard-65770
👍🏼 1
f
Hi @shy-kite-21035, any updates on this?
Also looping in @modern-refrigerator-23429