-
-
Save Gegam/fb7ec7d3b19087af377ab45283e261a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scrollDepthtracking = {} | |
var contentMaxHeight = Math.max( document.body.scrollHeight, document.body.offsetHeight, | |
document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight) | |
window.addEventListener('scroll', function () { | |
var currentPos = document.body.scrollTop || window.pageYOffset || document.documentElement.scrollTop | |
, documentHeight = document.body.offsetHeight | |
, windowHeight = window.innerHeight | |
, scrollPercent = Math.ceil((currentPos + 5) / (contentMaxHeight * 10) * 10 | |
if (!scrollDepthtracking[scrollPercent]) { | |
scrollDepthtracking[scrollPercent] = true | |
ga('b.send', 'event', new String('Глубина прокрутки', "UTF-8"), scrollPercent) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment