-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
- Some sample code below, where
ratiosis a list of breakpoint percentages (of the page height) to track. - A similar utility could be written using airkit's inview module, to track events when specific elements enter view.
var ratios = [0.3, 0.6, 0.9];
var func = function(category, action, label) {
trackEvent(category, action, label);
};
window.addEventListener('scroll', function() {
var scrollRatio = window.scrollY /
(document.body.offsetHeight - window.innerHeight);
for (var i = 0; i < ratios.length; i++) {
if (scrollRatio > ratios[i]) {
var percent = ratios[i] * 100;
func('EVENT NAME', 'EVENT ACTION', percent + '%');
ratios[i] = 200; // Some number out of bounds.
}
}
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels