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.