Created
February 7, 2018 09:55
-
-
Save jacobovidal/a796696f6e84ea25987afdd00452961e to your computer and use it in GitHub Desktop.
Scroll tracking trigger to check if page height is bigger than the double of your viewport (Useful for Google Tag Manager)
This file contains hidden or 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
// If using with GTM, anonymize the function name | |
function isScrollable() { | |
function getDocumentHeight() { | |
return Math.max(document.body.scrollHeight, document.body.offsetHeight, | |
document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight); | |
} | |
function getViewPortHeight() { | |
return Math.max(document.documentElement.clientHeight, window.innerHeight || 0) * 2; | |
} | |
if (getViewPortHeight() < getDocumentHeight()) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment