How to Track Outbound Links on WordPress With Google Analytics Events
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:
- A user clicking play on a YouTube video
- Someone scrolling down your page
- Someone submitting a form
- And lots, lots more
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?
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.
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:
<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:
And to a user, it just looks like a regular old link:
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:
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:
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:
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:
- WP Google Analytics Events – the most popular option. A freemium plugin that’s pretty simple to use.
- Gravitate Event Tracking – not quite as popular but looks solid.
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?