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.
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 www.example.com/files/map.pdf as a pageview for /downloads/map you would add the following attribute to the link’s <a> tag:
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.
- You have to implement it on every page
- You have to host the Java Script file
it would look as follows:
And the code would look as follows:
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 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”
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
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
Nice tool – just curious.
Does it even work when you have your pdf’s in a folder?
Because, I have a feeling it only works when the files are on the root level.
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.
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?