: Event Tracking in Universal Analytics I'm using Universal Analytics tracking code and would like to start tracking click events for one of the buttons. I added the ga('send'...) on click event
I'm using Universal Analytics tracking code and would like to start tracking click events for one of the buttons. I added the ga('send'...) on click event via jQuery. Do I need to make any changes to the actual Universal Analytics tracking snippet?
More posts by @Sent6035632
2 Comments
Sorted by latest first Latest Oldest Best
No you don't. Google mentions that the events tracking is part of analytics.js (which is what the default Universal Analytics snippet is calling).
I'm sure you already saw this, but in case you didn't and you're wanting to confirm that you did the jQuery part correctly, here's Google's example.
No, you don't need to make any changes. I'm assuming you are invoking the library and creating the tracker through the standard method.
Your code should look something like this:
<button onclick="ga('send', 'event', 'your_category', 'your_action', 'your_label');">
With jQuery, placing an event listener on the button:
$('button').click(function(){
console.log("sending your event"); // use this to debug
ga('send', 'event', 'your_category', 'your_action', 'your_label');
}
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.