Event Tracking in Universal Analytics

By June 13, 2014Uncategorized

Google 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:

https://support.google.com/analytics/answer/4457764?hl=en

One Comment

  • Amitabh says:

    this is my universal analytics Event Click Code… Please tell me… as still unable to track the clicks in GA..How much time it will take to track click events…

    Maps

    Please revert me….

Leave a Reply