How to track outbound links with Google Tag Manager

In this guide we will see how to track clicks on Outbound Links (also called "External Links") on our website using Google Tag Manager.


Why should we care?


Well, there can be so many reasons why I'm interested in tracking external links.


For example, they may be links to affiliate sites, so I'm interested in more information about the clicks they receive. Or these links may refer to resources that belong to us but that are external to our site, such as our social profiles or our videos on YouTube.


Let's see step by step how to do it.


STEP 1 - CREATE THE TRIGGER


The first necessary step is to create the Trigger for clicks on the Outbound Link.


In the menu on the left side click on Trigger> New> Trigger configuration> Click - Link only.


  • We select Wait for Tags and leave 2000 milliseconds set as the maximum waiting time.

  • We also select Check Validation.

  • Enable this trigger when: Page Path matches the regular expression. * (I recommend, dot and asterisk: do this if you want to track all external links on all pages, otherwise select one in particular. ).

  • Then click on This Trigger activates on: Some links clicks.


At the bottom, set two conditions:


Click URL does not contain www.nameofyoursite.com


Click URL does not contain javascript:

(this second condition you need to exclude all those JavaScript calls that programmers often use, to make magical things happen when you click a link that does not really trigger the page change). Now call the Activator for example "Click Link External ". Save.





STEP 2 - CREATE THE TAG


Click on Tags> New> Tag Configuration.

  • Tag type: Universal Analytics.

  • Type of monitoring: Event.

  • Category: Click external link.

  • Action: {{Click URL}}

  • Label: {{Page Path}}

  • Leave Hit from non-interaction set to False.

Now select "Enable settings override" in this tag and enter your UA code or Google Analytics to tracking ID.


Now on Activation we just have to select the Activator created in the previous step: External Click Link.


We call the Tag for example "Outbound clicks". Save.





STEP 3 - CHECK WITH PREVIEW AND DEBUG


As usual, before publishing the Tag I suggest you take advantage of a very useful feature present in Google Tag Manager, or the Preview and Debug mode.


This way you will be able to see if there are any errors even before implementing the Tag.


All you have to do is click on Preview and then on your site, on the page where the external link is located.


In the window that appeared at the bottom, you should see the "Tag Outbound clicks" between the "Tags Not Fired On This Page".


Now, if you click on the Outbound Link, if all went well, the Tag should fire within the Tags Fired On This Page.


Here it is! If it went exactly like this, it means that the Tag works correctly and can be published.


Go back to Tag Manager and click on "Publish" in the upper right. Give the new version a name (the description is optional) and finally Publish.

© 2020 by Luca Tagliaferro. All rights reserved.