Thursday, March 31, 2011

How to track downloads in Google Analytics automatically?


We use Google Analytics here because it is a great tool to help us understand our visitors. Today we're going to talk about a way to track if visitors download files or click on links to external websites.
Tracking this sort of behaviour may be really important to see if people are interacting with the web site the way intended. For example, businesses that have their brochures or product catalogues downloadable as PDF's.
The official Google Analytics help says that any link can be monitored if this script is added in the link:
onclick="pageTracker._trackPageview('/file_name.file_extension')
Adding this script to every download link on your website can be a laborious task

Tracking downloads automatically

The simple solution we found is to use a JavaScript that automatically attaches event listeners to files which are downloaded from your web pages.

What sort of downloads can you track automatically?

Using the javascript you can track the following file extensions:
  • doc, eps, jpg, png, svg, xls, ppt, pdf, xls, zip, txt, vsd, vxd, js, css, rar, exe, wma, mov, avi, wmv, mp3
In addition to tracking these downloads, the JavaScript will also track clicks on links to external websites and include these in your Google Analytics statistics.

How do you install the tracking JavaScript?

Is it really that simple?

Yes, but note that this tracker is written for Google Analytics new tracking code which uses the lighter ga.js. If you are using the old tracking code with urchin.js you can still track file downloads but not using this link tracking JavaScript. Check out this site for more information on tracking download links with the old tracking code.

0 comments:

Post a Comment