Event Tracking w/ Universal Google Analytics

Before you attempt to change your event tracking codes make sure your website is using the Universal Analytics snippet. If you aren’t sure, check your snippet against the Analytics reference.

Things have changed with the transition to Universal Analytics from Classical. A couple of the big changes we noticed at PPC Blast were the use of Event Tracking, Ecommerce Tracking and the creation of Remarketing Lists within Universal Analytics. I have an tutorial on ecommerce tracking in Universal Analytics. In this article we will focus on the changes to event tracking. Universal Google Analytics

In classical Google Analytics you used to add a snippet of code to your links or images that would allow you to track events within Google Analytics that looks something like onClick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\'s First Birthday']);"

Now we must use jQuery to setup functions to be called when an event we want to track is being performed.

Setting up The jQuery Version of Event Tracking

This new version of event tracking requires no changes to your existing Universal Google Analytics tracking code. Although you will need to add some new code on your website. Here is a sample of code to add.

<script src="//"></script>
   $('#GBadge').on('click', function() {
         ga('send', 'event', 'Badge', 'Click', 'Google Badge Sidebar');

Breakdown of the Universal Google Analytics Event Tracking Code

#GBadge – This is how we identify the link/image we are tracking clicks on.

.on(‘click’ – This tells jQuery to perform the following function when the link/image identified by #GBadge when it is clicked. You can exchange ‘click’ with ‘mouseover’ or any other javascript function you need.

send – This command tells jQuery to send Google Analytics the event once it is activated.

event – This tells Analytics that the process to be tracked is an event.

Badge – This is the Event Category. You can change this to whatever category you are tracking.

Click – This is the Event Action. You can change this to whatever action you are tracking.

Google Badge Sidebar – This is the Event Label. You can change this label to fit whatever event you are tracking.

Using this jQuery Event Tracking

Once you have setup your jQuery function it is time to implement it. Within your link or image add the id (#IdName) to the link/image like this:

   <a href="" id="GBadge">Google Partners Badge</a>

Testing your New Universal Google Analytics Event Tracking

Now that you have setup your event tracking in jQuery it is time to test it.
Login to Google Analytics, choose your account that you are tracking, go to Real-Time within Analytics, then click on Events. Now go back to your website and click on the link that you are tracking and see if you see it in real time within Analytics. Once you do you are all setup for event tracking.

Check out My Tutorial on Ecommerce Tracking in Universal Google Analytics
Ryan Davis ()

Ryan is a Senior PPC Manager for PPC Blast.
He has been working in web design/developement for over 16 years and PPC for over 3 years. He is Google Adwords Certified and Bing Ads Certified.

Posted in: Analytics

Leave a Comment (0) ↓
Loading Disqus Comments ...
Loading Facebook Comments ...

Leave a Comment

Help Us Improve The PPC Blast Blog
Follow Us or Leave A Comment Below!