To begin open the account associated Tag Manager account. If you haven’t yet set one up, please refer to this link.
In Google Tag Manager click into triggers
Create a just links trigger
Title the trigger “Link Clicks”
We want to track all links at this point to see if this trigger works
Save
Refresh preview mode
Test an outbound link click
Link click should populate in the Tag Assistant window (see image for reference)
Once we see that this trigger works we want to differentiate between internal site clicks and outbound clicks
Go back to Tag Manager and click on Variables
Scroll down to “User-Defined Variables” and click new
In the dropdown menu select “Auto Event Variable”
Title the variable “aev – Outbound Link” Under variable type select “Element URL”
Under component type select “Is Outbound”
Within affiliated domains, you can add URLs for sites that you do not want to count as an external link click
If multiple separate by commas
If outbound click should be tracked as external do not add here
Once complete save and refresh preview mode.
Test the variable by clicking on your outbound link
Within the link click trigger you should see your “aev – Is Outbound” variable
If added as an affiliated link the value should be false. (See image reference)
Once we see the variable working go back to Tag Manager
Click into triggers and select the Link Click trigger we created previously
Update title to “Link Click – Outbound Links”
Under “this trigger fires when” select some clicks
Under “Fire this trigger when an Event occurs and all of these conditions are true” in the first box select the “aev – Is Outbound” variable > in the second box select “equals” > in the third box enter “true”
Now select wait for tags > Another drop down will appear > In the first box select “Page URL” > In the second box select “Matches RegEx” > In the third box enter “.*” this (.*) matches up to any URL that GTM is installed on)
Save
Now that we have created a Trigger, we move on to building out the Tag.
Action: Click into variables and select {Click Text}
Label: Click into variables and select {Click URL}
Non-Interaction Hit: Select “true”
Under Google Analytics setting select the google analytics variable that should have been created during the basic GTM setup
Trigger: Select the “Link Click – Outbound Links” trigger we just created
Save
Now it is time to test again!
Refresh preview mode to test
I tested out a click to a link that I listed as affiliated first, when I click into it the link click trigger fires but no tag fires (see image)
To test that the outbound tag fires on unaffiliated external links, I clicked into the Instagram extension, and our GA – Event – External Link Clicks tag fired!
This shows that we are properly tracking outbound link clicks (see image 2)
Congratulations! You have now mastered the art of outbound link tracking.