Web Development
How to Track Page Scroll Depth in GA4 (no tagging)
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: