Reputation: 57
I'm currently sending a click event into Google Analytics using the following code:
$(document).ready(function() {
$('#button').on('click', function() {
ga('send', 'event', 'button', 'click', 'nav-buttons');
});
});
It works just fine.
However, I want the value to be the minutes of how long the user has on the page.
This means, it will track how many minutes it took the user to click the button.
Upvotes: 2
Views: 159
Reputation: 1188
$(document).ready(function() {
//current time at document ready
var past = new Date().getTime();
$('#button').on('click', function() {
//how much minutes passed when button clicked
timeElapsedInMin = Math.floor((new Date().getTime() - past) / 60000);
ga('send', 'event', 'button', 'click', 'nav-buttons', timeElapsedInMin);
});
});
Upvotes: 2