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:
[sourcecode language='javascript']
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://’,”);
}
}
});
}
});
[/sourcecode]