Posts Tagged ‘tracking’

Using Google Analytics to track click throughs from your website

Friday, May 16th, 2008

This post has been superceded by a more recent post on Google Analytics Event Tracking.

The Problem

It has always been difficult to track when someone clicks a link on your website which takes them to an external website (a click through or clickthru if you prefer). The problem is that the resulting request is made to the external website and is logged there, it doesn’t get logged on your own website at all.

For the web designer wanting to log clickthrus this is a problem, the traditional answer is to put the code which opens the new site in a file. When the user clicks on a link some code is executed locally (and logged locally) which then makes the call to the external site. This works fine but it makes it quite difficult for search engines to follow the link to the external site, sometimes impossible. If Google can’t follow the link to the external site then you may be giving them visitors but you are not helping their page rank in Google.

This is obviously a problem that many clever people have been thinking about for some time, one of the best solutions I have found is Search Engine Friendly Click Tracking which uses javascript to log any click on a link to a file or database.

The solution

But while checking some details in Google Analytics I found a section on using javascript events to track outbound pageviews. This is essentially the same technique as mentioned above but integrated with Google Analytics rather than standalone. It seems to me that this little feature using the new version of the Google Analytics tracking code is the holy grail of Search Engine Optimisation!

King Arthur sees a vision of Google Analytics

All you need to do is;

  1. make sure that you are using the new version of the Google Analytics Tracking code.
  2. That the code is inserted in your webpage above any links that you want to track (I put it just after the <body> tag in my test page).
  3. Add a javascript event tag to each link you want to track.

The actual tag is quite simple, this is Google’s example;

<a href=”” onClick=”javascript: pageTracker._trackPageview (‘/outgoing/’);“>

When somebody clicks on the link Google Analytics will log the click as a call to /outgoing/ in your analytics report.

And of course the href code is retained in its natural form so it is easy for search engines to follow the link, you can give the target site the link love it deserves.

I think this is a brilliant development, a big thank you to the wizards at Google for their continued good work!

Bonuses from Google Analytics

Using Goals to monetize outbound links

In Google Analytics you can assign goals to pages which make you money, say the checkout page on your shop. You can do the same thing with your new trackable outbound links, so if you carry advertising on your site you can see exactly how much you are earning. You could assign a value of say 10p to any pageview in the /outgoing/ directory and use Google Analytics to work out your bills.

Tracking calls to images and PDF files

Also, this technique can be applied to any sort of link. I discovered it while looking for a why of tracking views of a PDF file. If you have a file, like a PDF or an image, where you can’t insert the Google Analytics code inside the file then you can do something like;

<a href=”” onClick=”javascript: pageTracker._trackPageview (‘/my_document.pdf’);“>

And you can track views of the PDF or image file just like they were a regular web page.

Thank you Google

Thank you to Google for another great tool. Now that I know the answer I have no trouble finding the solution with a search in Google but I hope this article saves someone else some time.