hasReported10 = false; hasReported20 = false; function report10() { if (!hasReported10) { ga('send', 'event', "Lander", "Read 10", "Tracking", 10); clearInterval(intv10); } hasReported10 = true; } function report20() { if (!hasReported20) { ga('send', 'event', "Lander", "Read 20", "Tracking", 20); clearInterval(intv20); } hasReported20 = true; } var inview = new Waypoint.Inview({ element: jQuery('#read-track-container')[0], enter: function (direction) { if (direction == "down") { if (!hasReported10) { intv10 = setInterval(report10, 10000); } if (!hasReported20) { intv20 = setInterval(report20, 20000); } } }, // These may become a factor later with content underneath // entered: function (direction) { // }, // exit: function (direction) { // }, exited: function (direction) { if (direction == "up") { if (!hasReported10) { clearInterval(intv10); } if (!hasReported20) { clearInterval(intv20); } } } });