Showing posts with label analytics. Show all posts
Showing posts with label analytics. Show all posts

Sunday, December 6, 2009

Tracking Web hits to PDFs with Google Analytics

Here's some sample code on tracking PDFs, video, image files (anything other than HTML or server-processed pages). This a simple takeover of your own anchor tag that drops a quick client-side event in there for google to track, just before serving up your PDF.


< a href="http://www.example.com/files/map.pdf" onclick="javascript: pageTracker._trackPageview('/downloads/map'); ">

I'm not entirely clear on whether or not the link used in your javascript has to actually exist. If anyone figures it out before I get around to it, please post here!

In the mean time, here's a link to the Google Analytics support page addressing this exact approach.