I have a number of outbound links on a website that I hope to track using Google Analytics (analytics.js).
Google 's outbound link tracking docs are clear, and the implementation they offer works for me. The problem is with links opened in a new tab / window . Google suggests opening links through a callback function that updates document.location as soon as the tracking event is sent to GA. But this, obviously, will not open the links in a new tab. And, importantly, using window.open instead becomes a victim of pop-up blockers.
This is Google's proposed implementation:
<script>
var trackOutboundLink = function(url) {
ga('send', 'event', 'outbound', 'click', url, {'hitCallback':
function () {
document.location = url;
}
});
}
</script>
, , Google , , , - .