Friday, November 14, 2008

Jquery and google analytics team up to track downloads

While searching for a way to track downloads from my websites I came across this post on how to do it with jquery. Since I use jquery for a few things already I thought it'd be a good match.

I’ve quickly modified gaTracker to utilise the new API and call it’s _trackPageview() method rather than using urchinTracker(). The code is available below:

jquery.gatracker.js (Tracking API version)

It works in exactly the same way as the gaTracker 1.0.1 release, and can be dropped in it’s place, but utilises the new tracking API. Feel free to grab a copy until support gets built into the official release.


The great thing about this plugin is that it loads the ga tracker before adding the onclick events. Apparently this is a requirement by the google analytics api.

No comments:

Post a Comment