Since you are already using Google Analytics, they have a javascript function to put in the onclick
event.
The method name is either urchinTracker
or pageTracker._trackPageview
depending on whether you are using urchin.js
or ga.js
as your Analytics script include.
An example (from here) in both formats:
<a href="/files/map.pdf" onClick="javascript:urchinTracker ('/downloads/map');">
<a href="/files/map.pdf" onClick="javascript:pageTracker._trackPageview ('/downloads/map');">
Basically what that does is call the javascript method (which does the 'analytics call' to Google's server) then does the <a>
action as normal (ie. whatever the link was supposed to do - in this case open PDF files).
Is that what you are looking for - or is the jQuery answer what you wanted?
EDIT: in response to your question, this post contains a non-jQuery javascript include (here) that looks for 'downloadable files' and adds tracking. If you want to use jQuery, check out the other answer by ropstah since he/she has updated their answer to be Google Analytics-specific.