Return to Snippet

Revision: 16850
at August 18, 2009 03:24 by dsntos


Initial Code
$('#wrapper a:not(.popupwindow)').filter(function() {
		var theHref = this;
		if (theHref.hostname && theHref.hostname !== location.hostname) {
			$(theHref).not(".noAutoIcon").addClass("external");
			$(theHref).not(".noAutoLink").attr('target','_blank').bind('click keypress', function(event) {
				var code=event.charCode || event.keyCode;
				if (!code || (code && code == 13)) {
					if(pageTracker){
						var fixedLink = this.href;
						fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
						fixedLink = '/outgoing/' + fixedLink;
						pageTracker._trackPageview(fixedLink);
					};
				};
			});
		};
	});

Initial URL


Initial Description
Detects all external/outgoing links, adds class, & adds target = _blank. When using a strict doctype, this method is valid when using target manipulation.

Initial Title
Outgoing Google Analytics links

Initial Tags
google

Initial Language
jQuery