Tracking outbound links with Google Analytics

In Tools by Xu CuiLeave a Comment

Related articles:

Your webpages likely have some links to external web pages (e.g. a journal article’s page, or a government resource page, etc.). When your users click such links, they leave your site. Normally Google Analytics won’t track such link clicks, but there is a way to do so.

First, you need to add a javascript function on your pages:

var captureOutboundLink = function(url) {
   ga('send', 'event', 'outbound', 'click', url, {
     'transport': 'beacon'

Then, add or modify the onclick attribute to your links:

<a href="" onclick="captureOutboundLink(''); return true;">Check out</a>

In Google Analytics, you can see such clicks in real time or in history. To view the clicks in real time, click Realtime -> Events; to view the history, click Behavior -> Events -> Overview.

If you find the article useful, you may consider to subscribe:

Leave this empty:

Leave a Comment