Full marks to whoever decided to use sheep as a tool for advertising televisions. Just goes to show, ewe shouldn’t feel sheepish about bringing up left field ideas.
Full marks to whoever decided to use sheep as a tool for advertising televisions. Just goes to show, ewe shouldn’t feel sheepish about bringing up left field ideas.
Want to add Google Analytics tracking to all the non-HTML resources on your site? How about the outbound links to other websites? If you’re like me, you’ve considered it and then rejected it for being too annoying to add the tracking code manually.
Time for jQuery to come to the rescue. By adding the tracking code automatically to the links that need it you can avoid the hassle of editing all of your existing pages.
$(document).ready( function () { $("a").click( function () { var protocol = this.protocol; var link = $(this).attr("href"); if (link.substring(0, protocol.length) == protocol) { pageTracker._trackPageview('/exit/' + escape(link)); } else { link = this.pathname; if ( (link.substring(link.length - 1) != "/") && (link.substring(link.length - 4) != ".php") ) { pageTracker._trackPageview(link); } } } ); } );
The following caveats apply:
Spot anything that looks wrong? Does this not work on your browser of choice? Let me know.
According to Larry Wall, there are three great virtues of a programmer: laziness, impatience and hubris. I seem to have a surplus of the first and so have resisted blogging for a long time. Maybe my impatience and hubris have overtaken the laziness.
This may be the first of many blog posts or I may give up after a few. Either way, enjoy it while it lasts.