How To: Track File Downloads with Google Analytics
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:
[/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.
Related Posts
8 Comments to How To: Track File Downloads with Google Analytics
This is a very useful tip. I have bookmarked this page so I can come back when I start adding different type of contents on my site.
Cheers,
plin
April 3, 2009
Thanks for sharing it. I learn a lot from your post. I will try it in my google analytics.
April 8, 2009
[...] How to Track File Downloads in Google Analytics How Do I Manually Track Clicks on Outbound Links in Google Analytics? Google site
July 5, 2009
[...] [...]
September 17, 2009
Question: Does anyone know anyone that might be interested in being a mentor for affiliate marketing? I am not sure how to ask, and was hoping someone that reads your wonderful blog may know of someone. If yes, my email is susanizzoblair@yahoo.com. Thank you so much, I am getting very desperate.
January 26, 2010
I’m wondering if this may be used to track external accesses to the PDF URL, ie without loading the web page where the onClick event is located. Any help? Thanks !!!!!
January 26, 2010
I doubt this could track access to PDFs without loading the web page. The only way (that I know of, happy to learn otherwise) is to use server side logs. These aren’t as popular as they once were, but are probably more accurate than the standard Javascript tracking we do nowadays (Google Analytics). Those logs will contain downloads of PDF files without any referring page.
June 29, 2010
Great tip – thanks.
Do you happen to know anything about treating events in Google Analytics as conversions?
Thanks!
Leave a comment
Featured Posts
- HTML Fadein Fadeout: Basic Javascript/AJAX Tutorial using jQuery's fadeTo
- Basic AJAX Tutorial: Smooth Scrolling Text Marquee with a jQuery plugin
- Basic AJAX Tutorial: jQuery toggle and slide
- Hosting: How to pick a WordPress Host
- Basic jQuery Tutorial: Modify CSS classes and attributes, Hover and Toggle example
Follow Me
Email Subscription
Recent Posts
Top Commentators
- No commentators.
Archives
Tags
Blogroll
- 456 Berea St
- ActionScript 3 Design Patterns
- adactio – home of Jeremy Keith
- ajaxian
- Boxes and Arrows
- Chris Brogan
- CSS Globe
- InsideRIA
- Jarrod Michael Studios
- Mad Vertices
- NETTUTS
- Portsmouth Community Calendar
- Roomware Blog
- Signal vs. Noise
- Six Revisions
- Snook
- Style Grind
- Tiago’s Weblog
- Viget Extend
- Vitamin
- Whats the latest
- Why Banks Fail
- Woork
- zupko.info

March 26, 2009