Google Analytics Tutorial: Events Tracking
Lots of things can happen in a website today. You can play a video, subscribe to a newsletter, even play flash games! Would you be able to track if your users are engaging in these activities in your website with Google Analytics? With the usual tracking code, you can’t. So let’s make some tweaks and make sure you’re tracking these valuable interactions shall we?
Pinpointing each Activity
People go in your website to do a certain activity. Either it’s to read the information in your page, watch a video, play a game, or simply send you an email using your contact form. Whatever it is, you can track it and collect the data as a Goal (See our Google Analytics Goal Tracking Tutorial here) or as an event or even both. This data can be used to further improve your website – such as whether to put the email subscription form in the sidebar or as a pop-up or which of your advertisements are getting the most attention / clicks.
Hands in the Mud
So let’s get our hands dirty. Before we start, make sure you have your Google Analytics Tracking code installed in your website.
The code is something as simple as:
onClick=”_gaq.push([‘_trackEvent’, ‘Event Category’, ‘Event Action’, ‘Event Label’]);”
Attach this code to a link or a button in your website. Here’s an example:
<a href=”http://yourURLhere.com” onClick=”_gaq.push([‘_trackEvent’, ‘Event Category’, ‘Event Action’, ‘Event Label’]);”>Your Anchor Text</a>
What this code does is it tells your Google Analytics Tracking code to track an event happening in your website. And whenever someone clicks this link where the code is attached to, it will record the event.
Let’s take a real example that I use here in the SEO Hacker website. See this sidebar?
If you check out the code behind this sidebar, I applied the onClick Events Tracking Code to all of ’em. The code looks like this:
<a onclick=”_gaq.push([‘_trackEvent’, ‘Google Plus SH Page Sidebar’, ‘SEO Hacker G Page’, ‘Visited our Google Plus Page’]);” rel=”publisher” target=”_blank” href=”https://plus.google.com/102703521231315022013/”>Follow us on Google+</a>
It means that when someone clicks on one of these links, it will automatically tell Google Analytics that someone clicked it. It will specify which of the links the user clicked and where the user went. The sample code tells me that the user went to my Google Plus page through this sidebar link.
Inserting the code is a piece of cake – unless you have a TON of things you want to track in your website. So don’t track each and everything a user does – only that which is important. Besides, you wouldn’t want to dilute the important events in your website with the unimportant and ‘common’ ones.
Tracking Events through Forms
Usually a form has some sort of button such as my Email Subscription form on the right sidebar:
You can put the onClick code in the ‘input’ part of the code like this:
<input onClick=”_gaq.push([‘_trackEvent’, ‘Sidebar Email Form’, ‘Email Subscribed’, ‘SEO Hacker RSS Subscribed’]);“ name=”submit” id=”af-submit-image-1013632171” type=”image” class=”image” style=”background: none;” alt=”Submit Form” src=”http://www.aweber.com/images/forms/modern/red/button.png” tabindex=”502“/>
It’s fairly simple – now Google Analytics gets to track each time someone subscribes to our Email RSS feed using this form. Right now I have no other email forms in my website but if I do, I can put another events tracking code in it so it would track which is the better, more effective form in gathering leads.
How it Looks Like
On your Google Analytics Sidebar, go to Content -> Events -> Top Events.
This is how your events would look like in the Top Events section in your Google Analytics. As you can see, most of my events come from outbound links. Tracking outbound links comes with a different code which we will tackle in our Google Analytics Tutorial series.
You can also check out on which pages most of your events happened. Of course, you could always combine the data using Segments if you want to see exactly which Event happened on which Page.
Events tracking is simple and easy. Events Tracking is also highly overlooked. Don’t waste any time. The earlier you apply this in your website, the more valuable data you can look back to. That data can be your basis for A/B testing of forms, buttons, links, videos, etc.
Learn from your user activity, apply that data to your website, test. That’s what Google Analytics is about.