Google Analytics shows exit pages but it won’t show which links users click to leave your site, so in order to do this, you need to track those links. There are several reasons to track outbound Links and one of them is to see which outbound link is converting the most and which are not.

There are couple of ways to do this one is by inserting an event tracking code and other is to download a plugin that will do the work for you.

Event Tracking

Event tracking works by sending four pieces of information to Google Analytics. That are Category, Action. Label and Value.This piece of information is used in the code and it triggers when a user clicks on the link.

This example assumes that you are using analytics.js file instead of classic code. You can further read the documentation over here.

The code will look like this:

<script>
/**
* Function that tracks a click on an outbound link in Analytics.
* This function takes a valid URL string as an argument, and uses that URL string
* as the event label. Setting the transport method to 'beacon' lets the hit be sent
* using 'navigator.sendBeacon' in browser that support it.
*/
var trackOutboundLink = function(url) {
ga('send', 'event', 'outbound', 'click', url, {
'transport': 'beacon',
'hitCallback': function(){document.location = url;}
});
}
</script>

So, if a user clicks on an outbound link. The code that triggers will look like this:

<a href="http://www.example.com" onclick="trackOutboundLink('http://www.example.com');
return false;">Check out example.com</a>

Auto-track Plugin

Auto-track plugin is like hard coding auto event listeners.It is much easier to assign interactive events instead of dealing with bunch of JavaScript code.

In order to install this, you need to do couple of things:

  1. Load the autotrack.js file on your website. Replace the path/to/autotrack.js file with the actual location of the file hosted on your server
  2. Replace UA-XXXXX-Y with your tracking ID
  3. Replace the sample list of plugin ‘require’ statements with the plugins you want to use.
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXX-Y', 'auto');

// Replace the following lines with the plugins you want to use.
ga('require', 'outboundLinkTracker');
// ...

ga('send', 'pageview');
</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>
<script async src="path/to/autotrack.js"></script>

 

You can also use additional plugins from the list.

WordPress Plugin

Another simpler way is to download Google Analytics plugin developed by Monster Insights. Just imagine, you have hundred of affiliate links on your site and each time you want to track those links, you need to put the event tracking code mentioned above, it would be quite a task. So, it is easy to download this plugin that will track all outbound links for you.

Follow the setting from the screenshot:

 

You need to select the “Track Outbound Links” box and save your setting. Next, you need to click on the Advance Settings from the same plugin.

In advance setting. Select the Event option from “Track Download” and sets your internal path as “/offer/, /linkout/” and label those links as Affiliates.

Events Tracked in Google Analytics

Once you set-up this, you will see your events being tracked in Google Analytics under events overview. Please note that your events will be classified as Outbound Article, Outbound Affiliate and Outbound Comments. And, if you switch between Event Action and Event Label, you will see links URL and anchor text.

 

Share your experience with me and if you are facing any issues, then leave your comment.

You may also like: