Link tracking

How many visitors click on a specific link?

Event Tracking in Google AnalyticsLinks tracking or, more broadly, event tracking allows you to gather information on a specific hyperlink or button on your website.

It’s a really simple but incredibly valuable trick to know. And all it requires is your standard Google Analytics tracking code ¬†which is probably already included on your website.

Assuming you have Google Analytics set up I will directly jump into the wonders of Event Tracking.

Event categories, labels and actions

Google Analytics forces you to directly adopt a system of organizing your events – for which you will thank Google quite soon as event tracking can become somewhat of an obsession and will quickly result in an information overload if it wasn’t for Google’s structured way of storing this.

First of all you should think of a category. These can be anything, but personally I prefer to categorize my events according their location on the site. For example ‘Header’, ‘Footer’, ‘Sidebar’, etc.

When you’ve decided on the category, the next step is picking a label. The label is further ‘segmentation’ of your category. For example this could be ‘Social media’, ‘Contact’, ‘Support’, etc.

The final part is the action. The action relates to the actual link. What does the link do or what is the link about.

So to put everything together: let’s say I have a link to my Twitter account in the footer of my site. The category would be ‘Footer’, the label would be ‘Social media’ and the action would be ‘Twitter’. (Keep in mind that this is just an example and you’re free to choose your own categories, labels and actions.)

Adding a little code to your links

Now that you’ve decided what categories and labels you want to use for tracking the clicks, let’s add some code to our links. To keep it simple I will continue with my Twitter example. If I look at the Twitter link in the footer of my site, the links looks like this:

<a href="http://twitter.com/jgrietveld" target="_blank" title="Follow me on Twitter">Follow me on Twitter</a>

That’s a normal link without any event tracking applied to it. To start tracking the clicks I get on this link, I should add the following code:

onClick="_gaq.push(['_trackEvent', 'Footer', 'Social media', 'Twitter']);"

So the entire link would like like this:

<a href="http://twitter.com/jgrietveld" target="_blank" title="Follow me on Twitter" onClick="_gaq.push(['_trackEvent', 'Footer', 'Social media', 'Twitter']);">Follow me on Twitter</a>

It’s that simple.

How to activate Event Tracking in your Google Analytics account?

Where to find Event Tracking stats in Google Analytics

Fig.1

This is a standard feature of Google Analytics. The only requirement is that you’re using their standard ga.js tracking code which you can easily check by looking at the source code of a page on your website that has the tracking code implemented. Do a search for ga.js and if you find it, you’re good to go! This is the default tracking code that Google will give you when you create your account so it is unlikely (but not impossible) that you’re using some other tracking script from Google.

Categories and Labels

Categories and labels are set on your tracking code and are automatically imported into your Google Analytics account. So no need to pre-set your categories and labels in Google Analytics, just start adding the tracking code to your links directly and write down any categories, labels and actions as you go on your site. As soon as somebody clicks the link everything gets added to your account.

Over of Event Tracking in Google Analytics

Fig.2

Finding your link tracking in Google Analytics

  1. Open your website’s stats inside Google Analytics.
  2. In the menu on the left side of your screen click the ‘Content‘ tab (see fig.1)
  3. This will uncover a list of options. Now click on ‘Events‘ and then on ‘Overview‘ (see fig.2)
  4. Now you’ll see a overview of all your events.

I recommend that you click around a little through all the options under the Events items in the menu. Each will give you interesting insights into your site’s activity.

Also, don’t limit yourself to these 4 options in the menu. You can really get into the nitty gritty by drilling down into the information by adding a secondary dimension to your data (Fig.3 is a screenshot from the Top Events view.) That’s where the real fun starts!

Happy tracking!

Adding a Secondary dimension in data analysis

Fig.3