WPLift is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission.

 How to Track Outbound Links on WordPress With Google Analytics Events

Last Updated on October 19th, 2023

Tags: ,

Ever wished that you could track outbound link clicks from visitors on your WordPress site?

If you’re like 90% of webmasters I know, you use Google Analytics to track your WordPress site. It’s the default and plenty of plugins make it stupid simple to add Google Analytics tracking to your WordPress site.

But here’s the thing about Google Analytics:

It’s so complicated that Google themselves had to launch an entire Analytics Academy! Yes – you can go back to school just to learn how to properly use Google Analytics.

But most of us don’t have time for that. And most of that stuff doesn’t really matter to you unless you’re using Google Analytics professionally.

But there are some slightly advanced techniques, like outbound link tracking, that are worth learning about…even for people who aren’t full-time analytics professionals.

In this post, I’m going to tell you a bit more about something called Google Analytics Event Tracking and then get into how you can get up and running tracking your first outbound link clicks on WordPress using Event Tracking.

What Is Google Analytics Event Tracking?

Events are basically any action a visitor takes while they’re on your page. The event we’re specifically interested in for this post is “clicking an outbound link”. But you’re by no means limited to that. You can also track events like:

But here’s the catch with Google Analytics Event Tracking:

It only tracks what you tell it to. I mean, you’ve probably noticed that you can’t track outbound link clicks on your WordPress site by default, right?

Article Continues Below

The reason for that is that you haven’t told Google Analytics to do it yet! So that’s what this post is all about – learning what code you need to add to your WordPress site to make Google Analytics track outbound link clicks for you.

Why Should You Care About Tracking Outbound Links on WordPress?

I’m by no means a professional data nerd, but I am a hobbyist data nerd. And from my experiences while hobby data nerding, I feel confident saying that tracking outbound link clicks gives you a ton of actionable data.

For example, if you’re engaging in any type of affiliate marketing, you can use Event Tracking to figure out:

  • What offers your readers are clicking on
  • What pages drive the most affiliate clicks

And even if you’re not an affiliate marketer, it’s still helpful to be able to see which outbound links your readers find most engaging.

Tracking Outbound Links with Google Analytics

Before I show you how to enable outbound link tracking directly on a WordPress website, I’d like to walk you through the process of activating this feature on the current and upcoming versions of Google Analytics. 

Google announced it plans to replace GA3 (Universal Analytics) and GA360 during 2023 with GA4. Universal Analytics accounts will stop collecting data at the beginning of July and GA360 will follow in early October. 

Consequently, the steps you have to take to enable outbound link tracking in Google Analytics will change once GA4 rolls out. Unlike the other two versions of Google Analytics, the GA4 automates the outbound link tracking once the feature is enabled. 

If you’re still using Universal Analytics you can activate outbound link tracking for your WordPress website using the Google Tag Manager. Here’s how: 

  • Go to GA3’s Google Tag Manager and choose the Select New option from the Triggers menu
  • Select a name for the trigger you created and click Trigger Configuration
  • Set the Trigger Type option to ‘Just Links’ and then choose if you want the trigger to fire on all or some link clicks
  • Proceed to adjust the Auto Event Variables and save the changes

You can use Google Tag Manager to create tags that track outbound link clicks, but testing if a tag works properly can be time-consuming.

Tracking Outbound Links with GA4

The upcoming Google Analytics update should make outbound link tracking easier because users no longer have to follow the standard category-action-label-value pattern. 

Article Continues Below

Instead, the GA4 gathers data for enhancement measurement, custom, collected, and recommended events. Most importantly, GA4 automates the setup process so you won’t have to create tags or events manually. 

Let’s go through the steps you must take to start tracking outbound links with GA4. 

  • Go to a GA4 Property and click the Admin link on the left side of the screen
  • Find the Data Streams option in the Property column and choose the data stream for which you want to enable outbound link tracking 
  • Toggle on the Enhanced Measurement button in the Events tab and then click the Gear button below 
  • Make sure the Outbound Clicks option is activated and click Save

To see the data GA4 collects from the website’s outbound links you can either look at the ‘Events’ report or generate an exploration report. 

Finding an Events report or creating an exploration report is straightforward. Follow the steps below to access an Events report: 

  • Head over to the Reports menu, expand the Engagement submenu, and select the Events option
  • Type the event’s name into the search box and click on it when it is displayed on the screen 

Creating an exploration report is slightly more difficult because you must create a new exploration template, import different dimensions, and metrics into the report, and adjust a variety of settings before generating a report. 

Please remember that GA4’s data retention is only 14 months. You must use a plugin if you want to create exploration reports for periods longer than 14 months.

How to Track Your First Outbound Link on WordPress Using Event Tracking

Tracking outbound link clicks on a specific link isn’t actually that complex. All you need to do is add a parameter to your link’s HTML.

You know how you add something like rel=’nofollow’ to some links to tell Google not to pass on your precious link juice? That’s pretty much how simple it is to add Event Tracking to a single link.

If you want to track, say, a class of links (or all of your outbound links), things get a little more complicated (I recommend using a plugin for that). But if you just want to track individual links you’re using in posts or pages, this method works perfectly fine.

Adding the Code Snippet to Your Desired Link

If you’re not familiar with the code of a regular link, here’s a quick refresher. It looks something like this:

Article Continues Below

<a href=”www.google.com”>Link Text</a>

To add Google Analytics Event Tracking to that link, you just need to include this snippet:

onclick="ga('send', 'event', 'CATEGORY', 'ACTION', 'LABEL');"

So your final link should look something like this:

<a href=”www.google.com” onclick="ga('send', 'event', 'CATEGORY', 'ACTION', 'LABEL');">Link Text</a>

But what do those labels actually mean?

The code consists of 4 parts, with only two of them being required. These parts are:

  • Category – required: The type of object that was interacted with. For outbound link tracking, it might be something like Link (but you can use whatever term you’d like)
  • Action – required: The action that triggered the event. For outbound link tracking, you’d probably put Click.
  • Label – optional: A label for the specific event. For example, you could make it Affiliate if you’re tracking outbound affiliate link clicks.
  • Value – optional. A numeric value associated with the event. Most of the time, you can leave this off for outbound link tracking.

There’s also another optional value that deals with whether or not Google Analytics should count users who complete events as bounces. But for now, I’m going to leave that out so as to not muddy the waters.

A Real Life Example

Let’s take a real life example. Say you want to track an outbound link click on one of your Amazon Associates affiliate links. One way to set it up would be like:

<a href="https://www.amazon.com" onclick="ga('send', 'event', 'Link', 'Click', 'Amazon Affiliate');">Buy At Amazon</a>

This will give your link:

  • Category = Link
  • Action = click
  • Label = Amazon Affiliate
  • Value = NO VALUE ASSIGNED

Here’s what it looks like in WordPress:

track an outbound link click with example

And to a user, it just looks like a regular old link:

track an outbound link click with example preview

But when they click on it, the magic happens…

Viewing Your Outbound Link Clicks in Google Analytics

When you head to Google Analytics, you can view your outbound link click data by going to Behavior → Events:

view outbound link clicks in google analytics behavior to events

On the Overview, you can see a quick dashboard look of all the events happening on your site.

But my favorite view is the Pages dashboard because it lets you see exactly which pages are driving the most outbound links for your site:

view outbound link clicks in google analytics overview to pages to google analytics events

For example, you can see that the Google Analytics Events post I showcased in the screenshot above already drove an outbound click!

And by using Secondary dimensions, you can even figure out which traffic sources are driving the most affiliate clicks:

view outbound link clicks in google analytics secondary dimensions

Basically, you’ll now be able to integrate outbound link clicks into your other Google Analytics reports.

WordPress Plugins for Google Analytics Event Tracking

The manual method I outlined above is fine for tracking a link here and there. But if you want to add Google Analytics Event Tracking to every single outbound link on your WordPress site, you’re definitely going to be better off going with a plugin.

Plugins allow you to implement site-wide WordPress tracking without needing to add the Event Tracking code to every link manually. I know of two good ones:

Frequently Asked Questions about tracking outbound links on WordPress with Google Analytics

What are Outbound Links?

Any external link on a WordPress website that takes a visitor to another domain can be considered an outbound link. However, the term external link is also used to refer to backlinks or links that lead a visitor from another domain to your website. 

Outbound links are commonly used to provide additional information to a reader which is why they’re often called ‘authority links.’ In addition, they increase topical signal strength, provide extra value to the reader and improve the website’s search engine rankings.

Affiliate links are a subcategory of outbound links that lead a visitor to a page where they can purchase a service or a product.

How to Monitor Outbound Traffic?

WordPress doesn’t have a default functionality that allows users to monitor outbound traffic. However, doing so will enable you to know where your website’s visitors go after leaving your site and help you understand what to do to improve the user engagement metric. 

Enabling the outbound link tracking in Google Analytics will allow you to see how many of your website’s visitors click on outbound links you include on different pages. 

Also, you can add a code snippet to a link that will enable you to monitor outbound traffic in Google Analytics or install a WordPress plugin.

Wrapping Things Up

Google Event Tracking isn’t the only way to track outbound link clicks on WordPress with Google Analytics. There’s also something called Google Tag Manager which can help you accomplish much the same thing.

But, because I think Google Tag Manager is a little bit intimidating for a casual user (at least that’s how I found it), I opted to stick to Google Event Tracking for this introduction.

If you just want to track specific outbound links, you can get by using the manual method I outlined in this post. But if you want to set up site-wide outbound link tracking for all your links or a specific CSS class of links, then I definitely recommend going with one of the plugins.

Now over to you – have you ever played around with outbound link tracking? If so, did the insights you gained help you improve your site?

A team of WordPress experts that love to test out new WordPress related software, WordPress plugins and WordPress themes.