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(
Solution 1:
var count = 0;
setInterval(function(){
// increment "count" by 5 each time setInterval is run
count+=5; //is this what you need?ga('send', 'event', 'time', 'tracking', 'seconds', count);
}, 5000);
Solution 2:
Is this what your looking for?
var count = 0;
setInterval(function(){
count = count + 5;
// increment "count" by 5 each time setInterval is runga('send', 'event', 'time', 'tracking', 'seconds', count);
}, 5000);
Solution 3:
How about this?
var count = 0;
setInterval(function(){
count+=5;
// increment "count" by 5 each time setInterval is runga('send', 'event', 'time', 'tracking', 'seconds', count);
}, 5000);
Post a Comment for "Javascript: Increment Count By 5 For A Variable Inside A Setinterval() Function"