Google Analytics Moo-ized

October 14 2008, 10:49pm

As both David Walsh and I wrote about Google Analytics Tracking utilizing Mootools to make your outbound link tracking easier, and David did setup a variable for the Google Tracking code before we run the code to tag our outbound links. Upon second review, it’s a little different than the modified code I presented yesterday, but I dig using the href replacement on your outgoing string. Here’s the updated code:

window.addEvent('load',function(){ // Double-checking in case your drop this site wide // Do anchors exist on the page? if ($$('a')){ $$('a').each(function(anchor){ var href = anchor.get('href'); // if it matches my site or is an absolute path it's outgoing if(href.indexOf('http://ikeif.net') == -1 && href.indexOf('/') !== 0) { anchor.addEvent('click', function(e){ var track = "pageTracker._trackPageview('/outgoing/'" + href.replace('http://',''); } } }); } });

Copyright © 2008 iKeif - tech and social media geek, mootools fan, and a ton of links. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@ikeif.net so we can take legal action immediately.Plugin by Taragana