Track PDF file downloads

January 24th, 2009

A common way of tracking how website pages being used is through Google Analytics. You just need to bury a piece of javascript code towards the end of your web pages.

What if you have PDF files or other MP3, or video files for people to download and you like to know how many downloads each file gets? Obviously, you can not add the javascript tracking code to these PDF, or MP3, or FLV files.

Google offers a neat way of handling this — add an onClick javascript event to your link a tag. For example:

<a href=”http://www.example.com/files/map.pdf” onClick=”javascript: pageTracker._trackPageview(‘/downloads/map’); “>

For more details, pleaseĀ read the original article.

Please add your comment