Event Tracking in Universal Analytics

In Google Analytics, Events are actions triggered by visitors to your site. These actions range from simple button clicks to more complex behaviors like watching a video for longer than 60 seconds, for example. The thing is, Google Analytics doesn’t automatically track Events; you need to add a tiny snippet of code to the part of your site where you want to track a particular kind of visitor engagement.

For a long time, tracking an Event on a button click could be done by adding the following code to the page:

onClick=”_gaq.push([‘_trackEvent’, ‘Category’, ‘Action’,  ‘Label’,  Optional Value, false]);”

Back in 2012, Google began rolling out a new brand of Analytics, which they call Universal Analytics. The features are a little more robust in UA so there are many good reasons to switch over, though it isn’t yet required. For anyone tracking Events, the switch to Universal Analytics means some additional work, as the code example above would no longer function in UA and would need to be updated on every page where it is used. The new version of Event Tracking code is slightly different but getting the difference right is crucial since the code simply won’t work otherwise.

Here’s an example string of code for Universal Analytics:

onClick=”ga(‘send’, ‘event’, { eventCategory: ‘Category’, eventAction: ‘Action’, eventLabel: ‘Label’});”

It is important to note that only the Category, Action, and Optional Label sections in the example above can be changed to describe the Event that is being tracked. The “send” and “event” elements cannot.

If you’re struggling to get Event Tracking to function on your site, chances are good you’re using the wrong version of this code. Simply trying the alternate version, testing your Event, and checking the Real-Time section of Google Analytics to see if the test was successful is a safe troubleshooting option. However, if you would like to know whether or not you’re using Universal Analytics or if you’re still operating on classic Google Analytics, there are a couple ways to check. They are explained in detail here on Google’s support site:


Ryan Wilson
Founder & CEO
Ryan has his hands in a bit of everything, but he mostly focuses on client success and the technical aspects of advertising. Ryan likes 90’s hip hop, heli-skiing, and spending time with his family.