Skip to content

Instantly share code, notes, and snippets.

@coinso
Last active July 19, 2017 07:59
Show Gist options
  • Save coinso/247cf0aba29a11b846b274b41f637067 to your computer and use it in GitHub Desktop.
Save coinso/247cf0aba29a11b846b274b41f637067 to your computer and use it in GitHub Desktop.
(function($){
//time to event
//set new variables when page is loading
var d = new Date();
var timestamp = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
var c = 'time';//event category
var a = 'click';//event action
var l = 'time to event: '; //event label
//console.log('started at:' + timestamp);
//add element to track
$('ele').click(function () {
//create timestamp on event
var f = new Date();
//create the difference in seconds
var dif = parseInt((f - d)/600);
var la = l.concat( dif + ' seconds');
//console.log('clicked on: ' + timestamp);
//console.log(la);
//send event to google - choose your right google code
//_gaq.push(['_trackEvent', c, a, la]);
//ga('send', 'event', c, a, la);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment