web traffic report

How To: Track File Downloads with Google Analytics

Wednesday, March 25th, 2009 | Business, Tutorials | 11 Comments

Google Analytics is what most people use nowadays for web traffic reports.  It is flexible, powerful and simple.

The problem with Google Analytics is that it doesn’t analyze web traffic reports, but generates data in real time.  In most cases, this isn’t a problem.  In fact, it is big feature.  The problem is what about files that do not parse javascript such as PDFs, ZIP files, or other non-HTML documents.

When a user clicks on a PDF from your site, you will never see that PDF in Google Analytics.

How to track File downloads with Google Analytics
It’s very easy.  As is most things with Google Analytics.

Google Analytics provides a method for tracking anything you want.  It’s called “_trackPageview”.

You use it in javascript as “pageTracker._trackPageview(‘/downloads/map’);”.

How does this help us track file downloads?  Simply modify the link to the file asset to have an “onClick”:

[jscript]
Link to the file here:

<a onclick=”javascript: pageTracker._trackPageview(‘somefile.pdf’);” href=”somefile.pdf”>Download somefile.pdf</a>

[/jscript]

See how easy that was?

Hopefully you have a function used to print out those links, then you can modify it in one place (that’s what I did).

You should see results in Google Analytics under Top Content shortly.

Tags: , , , , , , , ,


Please share, it makes me happy:

Subscribe to Email Alerts

Follow Me

Follow seangw on twitter

Archives

Categories

prestashop theme

virtuemart template