Tuesday, 15 December 2015 16:35

Tracking Outbound Links with Google Tag Manager

Written by

Use Google Tag Manager to track Outbound Links

This blog article is a follow-on to an earlier article that showed how to Track PDF downloads in the latest version of Google Tag Manager (V2).  This blog will show the same approach used for tracking outbound links - to either an Google Analytics Event or to a Virtual Page View. Login into your Google Tag Manager account and click on the New Variable button - to make sure you will have access to the ""Click URL"" variable, click on the check box next to the ""Click URL"". We will be using this variable to determine whether this is an outbound link.  (We also make the Click Text variable available as well - since it can sometime be a clearer value in the final reporting.  Keep in mind that every variable adds a little bit more JavaScript on your users browser.)

Create an Outbound Link Click Trigger

Next we need to set up our Link Click Trigger to track outbound links.  First select Create a Trigger Select the 'Click' trigger from the type and then specify a 'Link Click'.  This creates code that will listen for when users click on a link, next we will tell the trigger to fire when the link is to a PDF file.  We do this by setting up a rule: Click URL does not contain mycoolwebsite.com If your URLs have different structures - you can use the technique from Simo Ahava that uses the hostname of the URL - http://www.simoahava.com/gtm-tips/track-outbound-links-in-gtm-v2/.

Create the Event Code

Just like in our PDF download example we can create an event to track the outbound links. This tag is a Universal Analytics tag that will look like this: You can define the Category, Action and Label as you see fit, my preference is as follows: Category: Outbound Action: link Label: {{click Text}} or {{click URL}} depending on which variable will best describe the link in your reporting.

GoogleTagManager Outbound Link EventTag 480x614

Alternate Create a Virtual Page View

In some cases you might want to create a virtual page view instead of an event.  In this case your outbound links will appear in your Behavior->All Pages reports and other pages reports.  Keep in mind that you will be affecting the pageview count for the website. Your Tag in this case will be a 'Pageview' tag and the Page Field (Document URL) will be updated with the {{click URL}} or {{click Text}} again depending on what best describes the link.  The Tag will be setup like this: Page: {{click Text}}  

GoogleTagManager Outbound Link VirtualPageviewTag 480x598

As you can readily see whether you opt for tracking using an Event or a Virtual Pageview - this approach quickly scales. As soon as you publish this tag you will be tracking your outbound links! Hope you find this post informative and let me know other topics you would like to cover.

Read 44647 times Last modified on Thursday, 21 November 2019 23:56
Jay Murphy

Jay Murphy is a digital analytics expert and founder of Trionia, where he specializes in transforming data into actionable insights for large and mid-sized businesses. With over thirty years of experience and a passion for Google Analytics since its inception, Jay has honed his skills to bridge the gap between technical data analysis and strategic business planning. An educator at heart, he has developed and taught comprehensive digital marketing courses at both the undergraduate level and within organizations, enriching minds with his deep understanding of the digital analytics landscape.

His career, which began in systems analysis for spacecraft guidance, has evolved through roles that blend technical acumen with strategic vision across various sectors, including Fortune 500, Higher Education and Non-Profits. Certified in Google Analytics since 2011, Jay's leadership at Trionia has spearheaded successful online campaigns and innovative marketing strategies, underlining his commitment to leveraging data for growth. Jay's approach goes beyond the numbers; he's a storyteller who uses data to drive business success, making him a pivotal figure in the digital marketing world.

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.