What's WP
Find Everything Related to WordPress - Best Tutoriasl on WordPress!
How to Track Outbound Links on a WordPress Site with Google Analytics

How to Track Outbound Links on a WordPress Site with Google Analytics

Google Analytics is a web analytics service for tracking website traffic, and it has been regarded as an important method for better SEO. Since this service also records outbound links, we are going to emphatically introduce the way to do this on WordPress site by using Google Analytics. That is a great way to understand which outbound links are doing well as well as help you get to know you site in depth. Follow the step-by-step guide and make a hit in an effective way.

Track Outbound Links with JavaScript

By default, Google Analytics does not allow you to track outbound links. The first thing you are required to do is to add tracking code to your site directly. Log into Google Analytics admin with your own account and go to Admin > PROPERTY > Property Settings > Tracking Info > Tracking Code.

The tracking ID and tracking code for your website are shown on this page clearly. Note that, the code encircled by “” is the tracking code that you are looking for. Copy the tracking code without any change and then paste it to all pages to be tracked. And then, move to the following steps.

Where to Find Tracking Code

Since you have laid the ground work for tracking outbound links, check if the first line of the tracking code is shown as below. If so, go on with the following guide.


The following code is used to recognize outbound links and that can track the targets automatically. Perhaps, you can replace certain values to your own if needed.

    var trackOutboundLink = function(url) 
        ga('send', 'event', 'outbound', 'click', url, {'hitCallback':
            function () { document.location = url; }

Another way to do so is manually tracking outbound links by using the following line of code. You are required to replace http://www.outboundlink.com to the site URL and replace “Outbound Link Text” to any description for this linked site.

<a href="http://www.outboundlink.com" onclick="trackOutboundLink('http://www.outboundlink.com'); return false;">Outbound Link Text</a>

Track Outbound Links with Google Analytic by Yoast

If you are sick of a mess of coding stuff, going with a WordPress plugin is great for you. Google Analytics by Yoast plugin is selected here, which makes it much easier to track outbound links or track anonymous data.

Log into your WP admin and install this pugin upon activation. An item called “Analytics” comes to your WordPress dashboard sidebar, which is further divided into Dashboard, Settings and Extensions.

Firstly, Google Analytics by Yoast requires you to authenticate your Google Analytics profile via Analytics > Settings. Focus on the first tab “General” and that shows you a list of general settings. Check “Manually enter your UA code” and click “Authenticate with your Google account”. And then, “Save Authentication Code”.

Google Analytics General Settings

The left options allow you to track outbound links & downloads. Track anonymous data, anonymize IPs and ignore certain user roles. Check the option “Track outbound click and downloads” and then click “Save Changes”.

Move to the “Advanced” tab and target the option “Track full URL of outbound clicks or just the domain”. Make a decision between “Full links” and “Just the domain”. That depends. Besides, the option “Set path for internal links to track as outbound links” requires you to enter the prefix included in an internal link, like /out/, /recommends/, and the internal like will be tracked automatically.

Track Full URL or Just Domain

To check the status of all tracked outbound links, go to Google Analytics dashboard and go to Reporting > Behavior > Events > Tops Events and this is where to analyze each outbound link in tracking.

In addition to Google Analytics Yoast, Google Analytics Track Outbound Links is also a popular plugin designed for tracking outbound links. Before setting up this plugin, you should make sure that the Google Analytics code has been added to your website already. Likewise, the results for all outbound links can be searched via your Google Analytics dashboard > Reporting > Behavior > Events > Overview.


Lucy has been a very experienced SEOer, technical writer, web developer, c# developer since 2002. Now she owns a startup in San Francisco, CA, focusing on running a couple of blogs to share knowledge and experience with global readers and deliver exceptional results to global sponsors by leveraging the power of Internet.