Google Event Tracking Analytics Tag Explained

Event Tracking Basics

First off, Event Tracking is a new feature in Google Analytics. If you are already a user, it is a different thing you have to implement with tagging. So if you are not an existing implementer of Google Analytics, you will have to start from the beginning.

I have been working with Web Analytics for over a decade, and there isn’t an analytics program on the market in the top 3 or 4 that I have not worked with, from Webtrends, Coremetrics, Omniture (Now Adobe), to Google Analytics.

So recently when I was asked to write a short spec on the Event Tracking tag and how it works in Google Analytics, I had to look carefully at this tag. It could be confusing, because Google Analytics typically does not use a lot of tagging. You just pop it in there and it works! Good news though, is that 99% of Google Analytics users won’t need another tag, unless they want to dig deeper (or have to).

So, as a reminder, the basic chunk of Google Analytics code looks like this:

<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
try {
var pageTracker = _gat._getTracker(“UA-XXXXXXX-X”);
pageTracker._trackPageview();
} catch(err) {}</script>

You get this when you login to Google Analytics, go to edit your account and click on “check status”. If you need more info on how to do this, I am going to write an in depth overview of google analytics and will cover the basics in that article.

Basically replace the UA-XXXXXXX-X with your code, or grab the full javascript code from www.google.com/analytics/ , pop this code into your html, and you are ready to go with Google Analytics.

Extra Tags & Event Tracking

There appears to be about 5 or 6 extra tags for Google Analytics (depending on what article you view on the web), and finally 2 extra tags for the checkout process. By tag, I am referring to lines in the analytic javascript code block. The big one that seems to be getting lots of attention recently is Event Tracking by Google Analytics. This is because it is new in their program and answers a lot of problem areas that Google Analytics did not cover in the past.

The basics of Event Tracking are you add a line of code per event. This would mean adding the following line:

pageTracker._trackEvent(category, action, optional_label, optional_value)

to the google analytics javascript block. I would place it right above
pageTracker._trackPageview();

You would replace the variables in _trackEvent in order to produce specific tagging of Events.

Category

The Category is used as the highest level tracking. This means it ties together all the other variables and should not be too unique per line. It is required. This means if you are tracking a series of events, you would keep this the same per event page or action. If you are tracking a WebForm for instance, then keep all of these the same wording like “Web Form” so they are grouped together.

Action

The Action is used to track the type of so called ‘actions’ the web surfer is taking. So for this example, you would use “Viewed Form” or “Completed Form” or “Received Error” or something similar.

Labels

The label is used to show additional info about the event you are tracking. It is kind of like giving a page a title. In this case this could be “Seeing Form On Page” or “Filled Form Out” or “Got Error On Form”, or it could just be “Form Page”. If it is unique that is fine as well.

Values

The values field is an Integer or Number field, so it often won’t apply. A great article about about this subject, the Event Tracking Guide, says that it is great for counting or summing things up like download time.

That’s it for now. There will be a future article on my success or failure in implementing the event tracking in Google Analytics.