Skip to content

Instantly share code, notes, and snippets.

@ogii
Created February 5, 2019 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogii/c66e3e9e825f566f337bdcc946652a54 to your computer and use it in GitHub Desktop.
Save ogii/c66e3e9e825f566f337bdcc946652a54 to your computer and use it in GitHub Desktop.
Tracking scroll goals in VWO
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