So I’ve been playing around with a few things regarding Google analytics in the last few days. I wanted something which I could track not just page views but also downloads and external links clicks.
I started off with Chris Blankenship's Google tracker extension. While I was grazing I also came across his jQuery goodness article about getting jQuery to work with BlogEngine.Net without causing any conflicts with the native $ script handle.
I tried first of all to modify his extension to add to the script and append an onclick event to all the page anchors elements, parsing the domain/path of any href content into a call to the $.pageTracker._trackPageview(path) method.
After a few hours my frustration grew as I faffed around with substandard regular expressions which weren’t very elegant. It worked… but I’ve seen prettier lepers.
Around the same time I was also looking at John Callaway’s jQuery extension and when I came across Jamie Thompson’s jQuery Analytics API I decided it would be a lot cleaner to implement it with jQuery and roll the whole lot into one extension.
So here it is, version 1, the combination of the above in one drag and drop extension. Bear in mind it can take a while for Google analytics stats to update but so far it seems to work like a charm.
Many thanks to the following sources/references for the ideas
Chris Blankenship - for Google Tracker and jQuery Goodness articles/plug-in
John Callaway - for the jQuery Extension for BlogEngine.Net
jQuery Documentation - http://code.google.com/apis/ajaxlibs/documentation/#jquery