Javascript: Increment count by 5 for a variable inside a setInterval() function
I'm trying to use Google Analytics events to track time spent on site more accurately (without relying on delta time between visits to another page on site). I'm using setInterval() to continuously trigger that GA even every 5 seconds. How do I properly increment seconds elapsed to send along with the GA event data? var count = 0; setInterval(function(){ // increment "count" by 5 each time setInterval is run ga('send', 'event', 'time', 'tracking', 'seconds', count); }, 5000); var count = 0; setInterval(function(){ // increment "count" by 5 each time setInterval is run count+=5; //is this what