Created
February 5, 2019 10:22
-
-
Save ogii/c66e3e9e825f566f337bdcc946652a54 to your computer and use it in GitHub Desktop.
Tracking scroll goals in VWO
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 scrollPos = window.innerHeight; | |
window.addEventListener('scroll', function(e) { | |
var pos = window.scrollY + window.innerHeight; | |
window._vis_opt_queue = window._vis_opt_queue || []; | |
if (scrollPos < pos) { | |
// down | |
if ((document.querySelector('div.top').getBoundingClientRect().top + window.scrollY) < pos) { | |
window._vis_opt_queue.push(function() { | |
_vis_opt_goal_conversion(200); | |
}); | |
} | |
} | |
scrollPos = pos; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment