Reputation: 784
In Google Analytics, you can track events like this:
$(document).on('click', '#home .post', function() {
ga('send', 'event', 'Home', 'click', 'Posts', '4');
});
What I'm wondering is if I can, instead of '4', pass a variable like this:
$(document).on('click', '#home .post', function() {
var index = $(this).index() + 1;
var indexStr = '' + index;
ga('send', 'event', 'Home', 'click', 'Posts', indexStr);
});
If it does, I'm also wondering if it is necessary for me to convert it to string.
Upvotes: 0
Views: 1624