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:
|
1 |
<a href="/assets/file.pdf">Download this PDF</a> |
|
1 |
<a onclick="_gaq.push(['_trackEvent', 'PDF', 'Download', '/assets/file.pdf']);" href="/assets/file.pdf">Download this PDF</a> |
Keep up to date: sign up to our infrequent newsletter …
