Outbound & External Link Tracking with Google Analytics
And while the default set-up of Google Analytics does a good job of tracking where your site traffic is coming from, and how users move around your website, one thing that isn't tracked out-of-the box is events, or interactions by your users.
Knowing how your site's visitors are interacting with your content allows you to gain a lot of insight about what's working (and what isn't). The more you know, the more you can do to improve the performance of your website.
One of the first types of event tracking you should set up (especially if you do any affiliate marketing), is external link tracking in Google Analytics. It's easy to do, and there are several approaches you can take to effectively track external link clicks by your website users.
In this article I'll provide an overview, and guide, for 3 ways to set up event tracking for external links in Google Analytics. Hopefully one of the approaches outlined here is the right fit for you!
3 Simple Ways to Track External Link Clicks with Google Analytics

- Manually Add Event Tracking to the Code of Individual Links
- Add a Site-Wide Script to Track External Link Clicks in Google Analytics
- Use Google Tag Manager to Track External Link Clicks
How Event Tracking in Google Analytics Works
In order for the actions that users take on your site to be recorded in a way that makes sense, webmasters should first determine which types of interactions are most important to them, and then set up event tracking with clear and concise labeling, so that it's easy to understand and interpret the data that Google Analytics records.
When event tracking is set up, Google Analytics fires off data which includes 4 primary labels, 2 of which are required. These labels are:
Field Name | Value Type | Required | Description |
---|---|---|---|
eventCategory
|
text | yes | Typically the object that was interacted with (e.g. 'Video' ) |
eventAction
|
text | yes | The type of interaction (e.g. 'play' ) |
eventLabel
|
text | no | Useful for categorizing events (e.g. 'Fall Campaign' ) |
eventValue
|
integer | no | A numeric value associated with the event (e.g. 42 ) |

For example if you are setting up event tracking for outbound links in Google Analytics, you might set the eventCategory to "outbound" or "oubound link," the eventAction might be defined as "click" or "link click," and the eventLabel could be set to be defined with a label of your link ... something like "Sidebar Ad #1" or the actual URL of the link that's clicked (href.match).
The eventValue field is optional, but if you want to have a numeric value (monetary or otherwise) associated with the event action, you can add one.
If you plan to do a lot of event tracking on your website, take your time and plan out how you'll categorize these events ... that way you can quickly check on the performance of different types of events (i.e. "How are my Video Plays Doing?" or "What Are the Most Popular Downloads on My Site?" or, "Which forms are people interacting with most?"
How to Add Google Analytics Event Tracking to Individual Links
I wouldn't recommend doing this if you are an affiliate adding links to products and services throughout every post and page, but if you run a small blog, and are just curious about the performance of certain links, or want to test a few different landing page layouts during a paid campaign, this is a good option.
Here's the code you'll want to add to your links within the <a> brackets:
If you have a value you want to associate with each event, you can add that as a fourth label field in the exact same way.
After adding this code to your links, you can check your Google Analytics view in real time after clicking the links with event tracking, and if it's properly implemented, you should see the events firing, and the clicks being recorded.
How to Track All External Link Clicks in Google Analytics with 1 Script
The way it works is that it tracks all outbound link clicks, skipping over any link clicks which lead users to other pages on your website (this is already tracked in GA). This script will label these events in the "outbound" eventCategory, with "click" as the eventAction, and use the destination URL as the eventLabel.
This is a perfect solution for affiliates who have a website with links already in place, but who aren't using Google Tag Manager. Rather than adding event tracking to individual links, simply drop this script in your site footer, and you'll have all of your external/affiliate link clicks tracked in Google Analytics. This way you can quickly set up a goal based on this event to see how each page or blog post is converting, discover which links are getting clicked most, and further optimize your website to get more affiliate referrals from your traffic.
Tracking External Link Clicks with Google Tag Manager
I've found the Google Tag Manager tutorials from Julian at MeasureSchool.com to be very clear, concise, and useful, so rather than reinvent the wheel, I'm just going to embed their terrific tutorial video and write-up the instructions he offers below the video for those who don't like watching video tutorials.
I highly recommend his website and YouTube channel if you're new to Google Tag Manager and want to learn.
- Add a New Trigger named "Outbound Link Click" (or similar)
- Make it a "Click" event trigger.
- Set the Trigger Type to "Link Click," check "Wait for Tags, and set the Max wait time to 2000 milliseconds (2 seconds). Leave "Check Validation" clicked.
- To have this event fire on all pages on your site, the options for "Enable When" should be set to: Page URL > matches RegEx > .*
- Finally, specify that the event should fire on "Some Clicks" to have only external link clicks tracked on your website.
- Specify that this event tracking should fire on the following trigger criteria: Click URL > does not contain > yourdomain.com (updating yourdomain.com to reference your domain name).
- Go to the Variables menu, and make sure all fields under "Clicks" are triggered, so all available data is recorded for each click event triggered.
- Now that your trigger is set up, go to the "Tags" menu and "Add New" and label it "GoogleAnalytics - Event - Outbound Links,"
- Choose Google Analytics, and Universal Analytics (if that's what you have running on your site), and set the track type to "Event."
- Set your Event Tracking Parameters: Outbound Links > {{Click URL}} > {{Page Path}}
- Set "Non-Interaction Hit" to "False," which will make your outbound link clicks affect your bounce rate.
- On the "Fire On" menu, click "More" and select the Outbound Link Click trigger you just set up.
- Click "Create Tag," then test it using the Google Tag Manager debugger, and confirm the events are firing in the Real Time > Events section of your Google Analytics view.
- Once confirmed that everything is working properly, publish your new tag in Google Tag Manager.
Some Helpful Resources & Links
- Guide to analytics.js (The JavaScript Library for Google Analytics)
- AutoTrack on GitHub (Automatic and enhanced Google Analytics Tracking for common user interactions on the web)
You May Also Be Interested in This Link-Tracking Tool
Since you're obviously into tracking links, I wanted to share a tool that I've found to be helpful. |
Full disclosure, I'm an affiliate of ClickMagick.
I like and use their product. I wouldn't recommend this tool otherwise. |