Skip to content

Instantly share code, notes, and snippets.

@Gegam
Last active December 1, 2016 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Gegam/dd1eaa0a737b1d8811fd5d9213e4174d to your computer and use it in GitHub Desktop.
Save Gegam/dd1eaa0a737b1d8811fd5d9213e4174d to your computer and use it in GitHub Desktop.
var scrollDepthtracking = {}
window.addEventListener('scroll', function () {
var currentPos = body.scrollTop || window.pageYOffset || document.documentElement.scrollTop
, documentHeight = document.body.offsetHeight
, windowHeight = window.innerHeight
, scrollPercent = parseInt((currentPos + 5) / (documentHeight - windowHeight) * 10) * 10
if (!scrollDepthtracking[scrollPercent]) {
scrollDepthtracking[scrollPercent] = true
ga('b.send', 'event', 'Глубина прокрутки', scrollPercent)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment