Return to Snippet

Revision: 28483
at July 8, 2010 17:59 by errkk


Initial Code
// Event Tracking for external Links
//Add expression for external and mailto links
$.expr[':'].external = function(obj){
    return !obj.href.match(/^mailto\:/)
            && (obj.hostname != location.hostname);
	};

function track_outbound_links(){
	// bind click function to all external links
	$('a:external').addClass('external').click(function(){
		var link = $(this).attr('href');
		_gaq.push(['_trackEvent', 'External Link', link]);
		window.location.href = link;
		return false;
	});
}

Initial URL

                                

Initial Description

                                

Initial Title
Track outbound links with GA and jQuery

Initial Tags
event, google, jquery, links

Initial Language
jQuery