How to track clicks to PDF files in Google Analytics

//, Search Engine Optimisation (SEO), Web Hints & Tips/How to track clicks to PDF files in Google Analytics

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.

2012-05-25T12:08:50+00:00 May 25th, 2012|News, Search Engine Optimisation (SEO), Web Hints & Tips|