Google Analytics Download Tracking

Google Analytics is a tag based analytics program, which makes it a bit harder to track actions for untagged items such as documents. For example, if I want download tracking for my famous pdf white paper or power point presentation – it’s something which is not out of the box in Google Analytics.

In this post I will show two ways to track document downloads in Google Analytics.

Google Analytics pdf Tracking

The Official Google Analytics Solution for pdf Tracking

Google Analytics offers their own solution, which enables you to tag each link in your website with its custom onClick Java Script so that Google Analytics records the Downloads and can track it:

For example, to log every click on a particular link to as a pageview for /downloads/map you would add the following attribute to the link’s <a> tag:

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

It works – However it is not very efficient.

  • It requires a complex implementation all over your web site (especially if you have a content management system with complex code behind it).
  • It increases the weight of your page (assuming you want to track multiple actions

The Efficient Solution for Document Tracking in Google Analytics (GA)

I stumbled upon this blog post at iqcontent, who offered a great solution. I tried it and it works too – I highly recommend it, although it’s not an official Google Analytics add on.

What they do, is they offer a separate javascript, which is hosted in your js files directory, and is called near the Google Analytics code, on every page of your site.


  • You have to implement it on every page
  • You have to host the Java Script file

it would look as follows:

Google Analytics pdf Tracking

And the code would look as follows:

<!-- Just 1 short line of code added here-->
<script src="/js/taglinks.js" type="text/javascript"></script>
<!-- regular Google Analytics Code here -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-90639-7");

Note, that this script will track the following file types:

  • PDF (.pdf)
  • Microsoft Word (.doc)
  • Microsoft Excel (.xls)
  • Microsoft PowerPoint (.ppt)
  • Microsoft Visio (.vsd)
  • Microsoft Visio XML (.vxd)
  • ZIP Archive(.zip)
  • RAR Archive (.rar)
  • Text file (.txt)
  • Downloadable Javascript file (.js)a
  • Downloadable CSS file (.css)
  • Executable (.exe)
  • NEW Windows Media Audio (.wma)
  • NEW Quicktime (.mov)
  • NEW Audio Video Interleave (.avi)
  • NEW Windows Media Video (.wmv)
  • NEW Mpeg Layer-3 (.mp3)

In a more advanced lesson, we’ll discuss the issue of advanced actions tracking, including ajax and flash objects. Kind’ a funky stuff 🙂

Here’s a taste.

6 thoughts on “Google Analytics Download Tracking”

  1. Hi, that’s great I can track it by adding javascript.
    I use the official way now but I don’t know where to find the results. Is that in the Content Drilldown or somewhere else.. And if I switch to the Efficent way you described here, would it be in the same place?

    Can you please help to find the results? Thanks

  2. Hi Tomek,
    Thanks for visiting and commenting.
    I’ve attached a screen shot. Once you implement the code line and put the tracking file on the root, you can simply go to content > top content and then filter your results using ‘contains’ and type “.pdf” (or any other filetype you’re tracking).
    Screen Shot Example

  3. Hi Reno,
    It will work in the way you describe as well, regardless of the file location.

    The tracker tracks the click on the link, not the actual download completion, hence does not matter where the file is – GA sees the code and tracking the onclick event.

  4. Hi there
    Unless I understand wrongly, this will track all clicks on links to documents, but won’t track direct links to PDFs from search engines or other external sites. Is this correct? And if so, is there anything I can do about it?

Leave a Reply