/ Published in: jQuery
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
// 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;
});
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                