I would like to track an onclick of a button on a page on a site, after a condition is passed checking if a cookie is present.
Very simple but which syn
/* universal event tracking */
function trackEventTag(category, action, opt_label) {
/* analytics.js send event */
ga('send', 'event', { 'eventCategory': category, 'eventAction': action, 'eventLabel': opt_label });
/* add delay or additional tracking here */
return true;
}
/* send ga.js _gaq.push() events to universal tracker */
var _gaq = window._gaq || {
push: function (ar) {
if (ar && ar.constructor === Array && 0 in ar) {
if (ar[0] == '_trackEvent') {
var category = 1 in ar ? ar[1] : null, action = 2 in ar ? ar[2] : null, opt_label = 3 in ar ? ar[3] : null;
return trackEventTag(category, action, opt_label);
}
/* test for others you want to translate here */
}
return true;
}
};