Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- document.addEventListener('scroll', function(){
- var h = document.documentElement,
- b = document.body,
- st = 'scrollTop',
- sh = 'scrollHeight';
- var percent = parseInt ( (h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100);
- console.log(percent + "%");
- if (percent == 25)
- {
- ga('send', 'event', 'Scrolling', 'moreThan25%', '{{Page URL}}', { 'nonInteraction': 1 });
- }
- else if (percent == 50)
- {
- ga('send', 'event', 'Scrolling', 'moreThan50%', '{{Page URL}}', { 'nonInteraction': 1 });
- }
- else if (percent == 75)
- {
- ga('send', 'event', 'Scrolling', 'moreThan75%', '{{Page URL}}', { 'nonInteraction': 1 });
- }
- else if (percent == 90)
- {
- ga('send', 'event', 'Scrolling', 'moreThan90%', '{{Page URL}}', { 'nonInteraction': 1 });
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement