Tracking file downloads in Google Analytics

WebSanity Internet Marketing logo
If you use Google Analytics to track website visitor traffic, then you might be missing valuable statistical information about the number of times that any PDFs you have on your site are downloaded. Google’s Analytics works by installing tracking code in all HTML files, but PDFs can’t have this code attached to them.

However, there is a way to get this information by putting some simple code on the links to the download files.

As an example, your initial link might be as follows:

<a href="https://www.websanity.co.uk/web-design-cambridge.pdf">Web design in Cambridge</a>

By adding a little bit of Javascript (shown in red), you can have all clicks to download the file appearing under the pagename you have picked:

<a href="https://www.websanity.co.uk/web-design-cambridge.pdf" onClick="javascript: _gaq.push(['_trackPageview', '/downloads/web-design-cambridge']);">Web design in Cambridge</a>

Finally you can track just how effective your downloads are in practice!

NOTE: Not only can you use this to track downloads, you can also use this to track key links that people click on within your site to leave it e.g. to partners, useful links etc.

Share
This entry was posted in Search Engine Optimisation (SEO) and tagged , . Bookmark the permalink.

Comments are closed.

About Gerald Thulbourn

Gerald Thulbourn setup WebSanity in 2004. He has a 1st class honours MEng in Microelectronics & Software Engineering (i.e. he's a techy), 5 A grades at A level (i.e. he works hard) and loves to communicate (i.e. odd for a techy). He hates tech speak, sloppy/badly tested code, and technology for the sake of technology's sake. He loves helping people understand marketing concepts and seeing how their application makes a real difference to their business. In particular he loves training; SEO, Website Analysis, WordPress etc. Read more about us on Google+