Tracking PDF downloads with Google Analytics

By default, there is no way of tracking document downloads – such as PDF’s – in google analytics.  Google Analytics works by sending some information back to google whenever someone lands on a web page.  But of course, a document download is not a ‘page’ in the traditional sense – so we need to find an alternative.

Fortunately, google provides a simple ‘event tracking’ mechanism which allows you to assign a page view to an event – such as an ‘onclick’ event.  The code example below shows a regular link to a PDF file, followed by the same link with google tracking enabled:

[crayon language=”html” title=”No Tracking”]Download this PDF[/crayon]

[crayon language=”html” title=”Add Google Tracking to PDF’s”]Download this PDF[/crayon]