Google Tag Manager can track the amount of traffic sent to other websites from links placed on the website. Reports include each link clicked for each page.
External links are links to a different domain. It takes the user from your website to other websites. In this article, I will help you to configure a Google Tag to track external links click on your website. Then see the reports in Google Analytics. What links are getting the clicks and from which page of the site.
This tag is not only helpful in understanding which links are getting the clicks but one can even measure the amount of traffic being sent out. Moreover, it also shows which links from which pages are getting the clicks.
So let us begin.
Step 0: Pre-requisite
You should be aware of Google Tag Manager Lingo. Moreover understand what is a trigger, tag, and the built-in variables available.
The next is, you should have a Google Tag Manager for tracking site’s traffic in Google Analytics. Though it is not a must, we will still need to have the Google Analytics Property ID to be able to send link clicks data to Google Analytics.
If you aren’t sure, refer to my article – How to Connect Google Analytics With Google Tag Manager first and then continue with this article.
Step 1: Create Trigger
We create a “Click Links” Trigger in Google’s Tag Manager and fire it based on the value of the link clicked.
- Trigger name: Anything that you think will help you understand as the name of the trigger. I have it as “External Link Clicks“
- Trigger type: We want to have a trigger for link clicks on our website. So we choose “Click – Just Links“
- Trigger fires: “Some Link Clicks” and select “Click URL” > “does not contain” > “yourdomainname.com”
Note: Replace “yourdomainname.com” with your domain name.
Note 2: Click URL may not be available in the drop-down. Add the variables by selecting the “Choose Built-In Variable …” option and select the variable.
This trigger will fire for link clicks on your website when the url is not from your choice of domain. It means your tag will fire and send data to Google Analytics when an external link is clicked on any pages of your site.
Points to consider for tracking clicks:
- The above trigger works fine for relative URLs or even # base anchor URLs.
- Email links, telephone links or WhatsApp links, may be treated as external links. If you don’t want to see these link clicks being tracked as external links in Google Analytics events report, you may need to add an extra check.
- Old style JavaScript-based URLs may be treated as external link. So if you want, it may be needed to be excluded from the trigger.
Step 2: Create a Tag For the Trigger
Create the external link click tag with the following metrics.
- Tag name: Anything that helps you identify the tag in the future. I have it as “External Link Click“
- Tag type We will be using Google Analytics for our external link click. So we use “Google Analytics – Universal Analytics“
- Track type: Event (Selected from the drop-down menu list)
Event Tracking Parameters
- Category: External link
- Action: {{Page URL}}
- Label: {{Click URL}}
- Value: Leave blank
- Non-Interaction hit: False
- Google analytics settings: {{Google Analytics ID}}
Click Save. The {{Page URL}} and {{Click URL}} are built-ins variable that will send the needed data to Google Analytics.
You can either type the variable name or can even select from the list by clicking on the lego button beside it. If you don’t see those variable in the list of variables, there is + sign in the upper right corner to add one.
Track Your Tag in Google Analytics
Sign in to your Google Analytics account and click Behavior > Events > Overview.
Here we will see the data we have added in the tag. We had the category as “External Link” in step 2 when creating the tag.
Under the External Links event category, we will see the event label with all the links that are clicked by users.
If you wish to see for each link which pages on your site have generated the outflow of traffic, just click the links in Event Label and it will show a report of pages from where the links were clicked.
To view the overall pages where the external links are getting clicks, use the event action link as shown in the image below.
Step 4: AMP External Link Tracking
If you wish to track external link clicks for AMP pages on your site as well, you will have to create the same triggers for the AMP container separately in Google Tag Manager.