Google Tag Manager Tutorial Part 1: Tracking Outbound Links in GTM Version 2

Google Tag Manager v2


20. August 2015


Last year we published a Google Tag Manager Guide to help you start using Google Tag Manager for event tracking.  Since then, Google has upgraded all Google Tag Manager accounts to Version 2.  This updated Google Tag Manager tutorial contains revised information about how to use the new GTM v2 to track important events on your website like link clicks, downloads, and form submissions.

This tutorial assumes you already have a Google Tag Manager account, have created a Container, and have installed it in your website (if not, start with the Tag Manager Help).  You should also already have a Google Analytics account for your website, and have already installed the tracking code with one of the methods recommended by Google Analytics.  Start by opening up Google Tag Manager and clicking on your Container to begin.

Part 1: Tracking Outbound Links

Part 1 of this tutorial will show you how to set up Google Tag Manager to track outbound links.  It is very useful to know how often users click on links that take them away from your site, and which of these links they click.  Unfortunately Google Analytics does not automatically track outbound links.

Set up outbound link tracking by following the steps below. First you will enable a built-in variable that gets the URL of elements that users click on.  Then, you need to create the trigger that defines what an outbound click is. Then finally, you will create a tag that records these clicks as events in Google Analytics.

1. Enable the Click URL Variable

In Google Tag Manager Version 2, you can enable and disable a variety of built-in variables (previously known as Macros), as well as create your own custom variables if needed. This lets you reduce the amount of JavaScript running on your page, in order to optimize page load speed.

Google Tag Manager Version 2 variables

To track outbound link clicks, you need to have the built-in "Click URL" variable enabled.  This will let you capture the URL of the links that users click. To enable it, just check the box next to "Click URL".

Enable the Click URL variable

2. Create an Outbound Links Trigger

Google Tag Manager Version 2 uses triggers to define when a tag should fire, for example, when a specific kind of click happens, a certain page is loaded, or a particular form is submitted. To set up a trigger for outbound link clicks, follow these steps:

  1. Click "New" on the triggers page to create a new trigger.
  2. Replace "Untitled Trigger" with a descriptive name like "Outbound Links".
  3. Choose Event:  Select "Click".
  4. Configure Trigger:
    1. Select Targets "Just Links".  This requires that the click is on a link, not on anything else, like a button or other page element.
    2. Tick checkbox "Wait for Tags" and set the Max wait time as 2000 milliseconds. This allows the trigger to wait up to two seconds for all the tags that use this trigger to be ready before taking the user to the link.
    3. Tick checkbox "Check Validation". This checks that a link is actually a valid link that takes the user to another page.
  5. Enable When:
    1. Select options: Page URL matches RegEx ".*". This enables the trigger on all pages of the website.
  6. Fire On:
    1. Select options: Click URL does not match RegEx ".*example\.com.+". This makes sure the link is not an internal link to another page on your site. Use your website's domain instead of
  7. Save trigger.

Google Tag Manager trigger configuration

3. Create an Outbound Link Click Event Tag

This tag will use the variable you enabled in step 1 and the trigger you created in step 2 to do the actual work of tracking outbound link clicks.  The tag defines how and when the event should be sent to Google Analytics. Create it by following these steps:

  1. Click "New" on the Tag page to create a new tag.
  2. Replace "Untitled Tag" with a descriptive name like "Outbound Link Click Event".
  3. Choose Product: Select "Google Analytics".
  4. Choose a Tag Type: Select "Universal Analytics" or "Classic Google Analytics", depending on which tracking codes you currently use on your website.
  5. Configure Tag:
    1. Tracking ID: Enter the Tracking ID of the Google Analytics property for your website.
    2. Track Type: Select "Event".
    3. Category: Enter "Outbound links".
    4. Action: Enter "Click".
    5. Label: Enter "{{Click URL}}"
    6. Non-Interaction Hit: Select True.  This means that this event will not change your bounce rate, because it will not be counted as an interaction on your site. This makes sense for outbound links, but for many other events you may want to count the event as an interaction.
  6. Fire On:
    1. Select "Click".
    2. From the "Choose from existing Click Triggers" menu that pops up, select the "Outbound Links" trigger you created in step 2.
  7. Save tag.

Google Tag Manager Tag configuration

4. Save a Version, Test, and Publish

Before you make any more changes to your container, you should save a version of the container so that you can come back to this point if you need to. To do this, click "Create Version".  You can give the version a name that describes what you changed in these steps, for example, “Outbound Links Tracking”, by clicking on the pencil icon next to the current version name (the default is a number).

The tags you just created will not start working until you publish them, but first you should thoroughly test that they are working as expected.  This is especially important when you have created triggers that wait for tags and check validation. You can test the setup with the Publish > Preview and Debug function.  See the Tag Manager Support articles on how to use preview and debugging.

If all goes well, publish your version so that the tags can start working on your site.

If you’ve followed all the steps above, you now have the necessary trigger and tag in your Google Tag Manager container to start tracking outbound links.

Stay tuned in the following weeks for the next parts of this guide! Part two will show you how to track downloads from your website and Part three will introduce tracking form submissions using the example of a contact form.  

If you have any questions about setting up event tracking with Google Tag Manager, please post a comment below or send me an email.


Hi Holly

Thanks for reaching out.

To answer your first question. In Google Analytics the outbound link tracking events will appear in the events report which you can find by clicking on the behaviour section and then Events -> Top Events. It will take a few hours for the events to appear there.

Alternatively, if you want to test in real time you can click on the Real Time section and then Events.

For your second question about multiple fires for each click. Have you set up more then one outbound link tag? i.e. Have you set up one tag for each link? You should only have created one tag that tracks all the outbound links on the site. 

If you have only created one tag then please drop the URL to your website in a comment here and I will see if I can't work out what is going on.

Hope that helps


My fires are being tracked per-page. For example, I have five outbound links on a page and when I click on one of the links, all of the Tags have a click added. How can I fix this? Thanks!

I've followed your instructions and it looks like it's working on the debugging page. It says how many times the trigger has been fired. But I don't see where it is being tracked in Google Tag Manager or Google Analytics. Where should this information be showing up? Thanks!

Hi Vincent

It depends on what data you want to see in your tracking. If you simply want to see the affiliate clicks as a seperate event category then following these steps should do the trick.

1. Create a new trigger that matches the URL Slug you are using for the affiliate link cloaking. So a trigger that fires when the Click URL matches the regex '\/slugName'. should be your sites domain and slugName the name of the URL Slug you are using.

2. Create a Google Analytics Event Tag with:

  • Category: Affiliate Links
  • Action: Clicked
  • Label: {Page URL}

This tag should use the trigger you have just created.

Hope this helps.

One thing that was not immediately clear to me, is that the link URL that is evaluated, is not the literal URL as it is included in the HTML source, but the full URL of the destination page.

In other words, if I use relative links like "/page.html" on my site, it will still match the regular expression ".*example\.com.+"

Also, you can simplify the regular expression in part 2, step 6, to just "example\.com", since regular expressions do substring matching by default. No need to include that there may be random characters before and after (the ".*" and ".+" parts).

If the website uses various subdomains (for example and that need to be treated as external sites, you can write a regular expression such as "//(www\.)?example\.com" to capture only the "" and "" domains.

Hi Kevin,

There are always complexities that can arise due to different implementations/website setups; so you have to debug/test regardless... It is unlikely that you will have issues if you follow the blog step by step, unless you have code that blocks the event from being handled.  

If a new tab is opened, it still registers the event on the current page. To reassure yourself that this will be the case remember to set : "wait for tags to fire" as seen in the third figure/image on the blog. 

With regards to how long it will take until you see the events in Google Analytics. The processing latency can be up to 24-48 hours. You should be able to use "Real Time" to see the events (this usually works). I recommend that you use Tag Mangers Preview Mode to see the tag firing, just to cover your bases.




If my outbound links open a new tab instead of changing my current page will it still be registered as an event?

Additionally, how long should I expect until the events are shown in my Analytics dashboard?


How would I track a cloaked affiliate link?

Hi Jacob

I'm glad you enjoyed the tutorial.

You are absolutely correct. Most special characters need to be 'escaped' - with the preceding \ - when you want regex to view them as part of the string. In regex these are metacharacters that have certain functionality. The unescaped '.' for instance is used to refer to any single character. 

Regex can be a little difficult to get your head around at first. The cheat sheet I've linked to below really helped me as a quick reference point when I started working with regular expressions. Plus it is designed for Google Analytics users with a few helpful examples. I hope it helps in future.



Thanks for a great tutorial.

It's probably worth mentioning that the backslash before a "." in RegEx stops tag manager from reading the "." as a regular expression.
My site has an additional ".au" suffix and I was confused about why the tag was firing on every page (I had ".*example\" - but it should have been ".*example\.com\.au.+").


Add comment