Skip to content

Instantly share code, notes, and snippets.

@Gegam
Last active October 31, 2018 10:11
Show Gist options
  • Select an option

  • Save Gegam/ff098bdf9e95822d344a to your computer and use it in GitHub Desktop.

Select an option

Save Gegam/ff098bdf9e95822d344a to your computer and use it in GitHub Desktop.
GA scroll depth in px
var scrollDepthtracking = {};
window.addEventListener ('scroll', function () {
var currentPos = body.scrollTop || window.pageYOffset || document.documentElement.scrollTop,
currentPosRnd = Math.round((currentPos / 200) * 200);
if (!scrollDepthtracking[currentPosRnd]) {
scrollDepthtracking[currentPosRnd] = true;
ga('b.send', 'event', 'Глубина прокрутки в px', currentPosRnd);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment