// listen for all clicks on anything. You could change document to a selector like #content to make it more efficient. $(document).on('click', function( e ) { // if this is a link, and the href does not contain our domain, it's an external link. Track it. if( e.target.href && e.target.href.indexOf( window.location.hostname ) < 0 ) { ga('send', 'event', { eventCategory: 'Outbound Link', eventAction: 'click', eventLabel: e.target.href, // the outbound link url will appear as the event label in GA. Find under Behavior -> Events -> Event Label transport: 'beacon' // not supported in some versions of IE }); } });