Tracking External Links With Google Tag Manager

Tracking External Links With Google Tag Manager

Recently I was asked if it’s possible to track all clicks on a website which leave the website. Sometimes links to external websites are required if the website needs to link to a brand or manufacturer or a third party website such as a booking system.

Having external links can cause metrics such as bounce rate to report inaccurately. It’s always better to keep a visitor on the website rather than sending them elsewhere but unfortunately, this isn’t always possible. Often a visitor needs to leave a website to complete a conversion or access additional information such as a PDF or verify a claim.

The most straightforward and simplest way to track external link is to implement Google Tag Manager or GTM as it’s better known and record these in Google Analytics as an Event.

How to create the Trigger in Google Tag Manager

  • In the first drop-down, you will need to create a ‘Trigger’ and select ‘Click – Just Links’ once selected you’ll have a couple of checkboxes and a drop-down. 
  • Enable the following: Wait for Tags and Check Validation.
  • In the dropdown you need to select Page URL with a condition of ‘matches RegEx’ and the value being ‘.*’
  • Once this has been completed below you’ll see to radio select options ‘All Link Clicks’ & ‘Some Link Clicks’. The option we need to select here is ‘Some Link Clicks’.
  • When you have selected this you’ll be presented with another dropdown. ‘Click URL’ isn’t available by default so you’ll need to select ‘Choose Built-in Variable…’ and enable ‘Click URL’.
  • Once the ‘Click URL’ becomes available the first field will be ‘Click URL’ you’ll need to set the condition to ‘does not match RegEx’ and the value being ‘.*martynb\.co\.uk.+’ update this to match your domain and finally save this trigger.
How it should look once all the steps are complete for creating the trigger.

Secondly you’ll need to create a Google Analytics – Universal Analytics Tag firing the trigger which we have just created.

How to create the Tag in Google Tag Manager

As we are going to be tracking an ‘Event’ we need to select this from the Event Type drop down. The following parameters can be unique to you but in order to pass the value of the link clicked you’ll need to define ‘{{Click URL}}’ under label.

This is how it should look once completed.

If you need further help feel free to get in touch or leave a comment.