I'm building a simple bit of jQuery to use with Google events tracking, and everything works up until the ga
function -- I thought I could just place the variables in the function, but it's not working. I know because if I use an alert to display the variables before the ga function, I get the alert. But, if I place the alert after the line, it doesn't work.
jQuery('.button[data-track="true"').click(function() {
var eventCategory = jQuery(this).data("category");
var eventAction = jQuery(this).data("action");
var eventLabel = jQuery(this).data("label");
ga('send', 'event', eventCategory, eventAction, eventLabel);
});
This is an example Google gives:
$('#button').on('click', function() {
ga('send', 'event', 'button', 'click', 'nav-buttons');
});
Anyway to use the variables in the ga
function?