How to track clicks to PDF files in Google Analytics

WebSanity Internet Marketing logoGoogle Analytics is a great free tool for having a look at visitor behaviour on your website, but it isn’t possible ‘out of the box’ to track statistics for clicks on links to PDF documents (e.g. online brochures) or external websites.

This unfortunately requires a little technical work, but it might be something you can ask your website developer to set up for you.

Put this code in the <head> section of your web page (ask your developer):

<script type="text/javascript">
  function recordOutboundLink(link, category, action) {
    _gat._getTrackerByName()._trackEvent(category, action);
    setTimeout('document.location = "' + link.href + '"', 100);

Then whenever you would have put a link to an external website like this:

<a href="">The link</a>

put the following linking code instead:

<a href=""
onClick="recordOutboundLink(this, 'Outbound Links',
''); return false;">
The link</a>

Look in Event Tracking report within Google Analytics and this will now show you information about the of people who clicked on Outbound Links and which ones. Just rename the text in the link to separate out links to PDF files or brochures or anything else into separate groups:

<a href=""
onClick=" recordOutboundLink(this, 'Brochure views',
'');return false;">
The link</a>


This is great for people who drive traffic to distributors or who don’t sell online, so that they can get better ‘conversion’ statistics to help them get more out of their website statistics.

Help and advice on SEO in Cambridge, Huntingdon or Peterborough from WebSanity Internet Marketing.

This entry was posted in Search Engine Optimisation (SEO), Web Hints & Tips and tagged , . Bookmark the permalink.

Comments are closed.

About Gerald Thulbourn

Gerald Thulbourn setup WebSanity in 2004. He has a 1st class honours MEng in Microelectronics & Software Engineering (i.e. he's a techy), 5 A grades at A level (i.e. he works hard) and loves to communicate (i.e. odd for a techy). He hates tech speak, sloppy/badly tested code, and technology for the sake of technology's sake. He loves helping people understand marketing concepts and seeing how their application makes a real difference to their business. In particular he loves training; SEO, Website Analysis, WordPress etc. Read more about us on Google+