Skip to content

Instantly share code, notes, and snippets.

@neotyk
Created October 5, 2010 10:03
Show Gist options
  • Save neotyk/611312 to your computer and use it in GitHub Desktop.
Save neotyk/611312 to your computer and use it in GitHub Desktop.
// create custom :external selector
$.expr[':'].external = function(obj){
return obj.hostname && obj.hostname !== location.hostname;
};
$(document).ready(function() {
// apply additional style to external links
$('a:external').addClass('external');
// and behavior
$('a:external').click(function() {
_gaq.push(['_trackEvent', 'Outbound Links', 'Click', $(this).attr('href')]);});});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment