Connect with us

Web Development

How to Track Page Scroll Depth in GA4 (no tagging)

Published

, on

Just add this code to your GA4 script:

 window.addEventListener('scroll', function() {
 if (window.scrollY > (document.documentElement.scrollHeight - window.innerHeight) / 2) {
 gtag('event', 'scroll', {
 'event_category': 'Scroll',
 'event_action': 'Scroll 50%',
 'event_label': '
'
 });
 }

Here is live code on my website:

GA4 Report View

author avatar
Alex
Over the past 9 years, I have realised that the most important weapon we have as tech enthusiasts is information. Information that I can share and actually help you solve some of your life problems. Of course, I'm going to lose some of that because of AI, but it's making me more productive today!
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Trending