November 18th 2020
One of the things that is often seen as a micro analytics goal, or often just an observation by marketers, is tracking how many clicks happen away from your site. This is especially important for bloggers who constantly reference external sites, and also for affiliate marketers who – for the most part – rely on users clicking out to a partner website. There’s an argument for affiliates that a click out would be more of a macro (or primary) goal as they can then work out a rough conversion rate from the clicks.
Luckily, it’s relatively easy to do with Google Tag Manager and pushing events through to GA is also a simple process. In this guide, I’ll show you how to set up the outbound link click trigger in GTM, then set up the event to go along with it. We’ll also look at adding in a dynamic variable to track the actual URL clicked on so that you don’t have to create multiple events. Let’s get started.
Setting Up An Outbound GTM Trigger
Alright so if you’re not familiar with Google Tag Manager, it’s probably a good idea to read this post on the basics of tag manager, and why it’s great for your website, this will give you a good first step to understanding how it works and why it will likely change your life!
If you’re a GTM OG then let’s crack on, firstly you’ll need to create your trigger in which your GA event tag will be applied, so go ahead and navigate to triggers then to ‘New’. Once you’re there, the trigger type you will need to select is ‘Just Links’.
This is a good trigger if you want to add something to the site that tracks every click interaction on a page, you might want to segment users and see what particular cohort clicks on which link first, or you might just want to test if people click a certain menu item before any other, as an example.
In this case, we only want the trigger to fire when certain links are clicked, you guessed it, anything that is outbound, i.e. not the domain we’re working with, so once you’ve open the links trigger type, click on the radio button that says, ‘Some Link Clicks’ as per the below:
Once you’re here, you’ll be given a set of conditions in which the user will have to meet, before the container can fire the trigger. The first drop-down menu will provide you with a list of classes, or ID’s that you can use, this is very useful, especially for button clicking where you can allocate the id of a button on a particular page, and fire a marketing tag/GA event tag. That’s for another blog post though as we’re keeping things simple this time. All you need from this drop-down is to select ‘Page URL’ and from there you can allocate a specific URL of an outgoing link. Let’s say you wanted to see how many people clicked on a link that contained google.com, you would use the following:
Logically, if you add a tag to this trigger, it will fire any time a link is clicked that contains google.com, easy. For the sake of efficiency though, let’s say we just want this tag to fire on any outbound link, in that case, just add your domain and change the condition (the drop-down box in the middle) to ‘does not contain’ like so:
So there are two different options for firing a tag depending on certain circumstances, and how your website and strategy is set up. So what do you do when you’ve set up the trigger? You can either fire marketing tags on there, like Google or Facebook, or you could fire a GA event tag in order to observe those micro-conversions we spoke about. So let’s go ahead and do that using the second method we used, any link that does not contain your domain.
Creating a Google Analytics Event
Now you have your trigger in place, let’s set up the event that is going to send data to Google Analytics once the trigger has fired. To do this, you’ll need to set up a new Universal Analytics tag:
Within here, you’ll be able to set the parameters for your event, which can essentially be anything you like, usually you would tend to name them from top-level down, with the most granular detail at action or label level. In this case, you could name the category ‘External Link’ the action ‘Click’ and the label can be static according to the URL (remember the Google example above), or it can be dynamic. You can do this by adding a parameter into the label section by clicking on that plus sign next to the text box which will bring up the variables you can use. You’ll see a long list of pre-set variables there to choose from, pick the one that says ‘Click URL’:
Once you’ve done that, you can leave the value (unless you want to allocate a value, this can be static too), select False as the Non-Interaction Hit, then add you Google Analytics ID (which also should be a pre-set variable, if this is the first time you are creating it then it may ask you to set this up).
Finally, add the trigger we created before as the method of firing the GA event tag. As always, head to preview mode and test what you’ve done, you should be able to see this in the real time events report in GA as you do it, if not, use the preview to tell you when the tags have fired.
It’s a really great trigger to have up your sleeve this one, and there’s more you can do with it, including firing on elements, when modals appear, buttons, video play buttons etc.