google analytics 4 has some cool updates for tracking deep dive metrics like scroll depth & time on page without relying solely on event triggers
i switched from universal to GA4 and noticed a huge difference in the data quality. now i can get real insights into how users interact with my site, not just where they click ❤
check out this snippet:
// ga. js - init & send scroll depth eventsga('set', 'screenName', window. location. pathname);window. addEventListener("scroll", function() {if (this. scrollY> document. documentElement. scrollHeight *.75) { // when user scrolls past bottom of page by ~3/4thsconsole. log("GA Scroll Depth: User reached near the end");ga('send','event',{'ec':'engagement', 'ea': "near_end",'ev':"1"});}});