This article will show a way for you to track all Link Clicks using Google Tag Manager.
You’ll learn how to setup a single link click tag in Google Tag Manager, and then how you can filter internal and outbound link clicks in Google Data Studio.
Creating an ‘All Link Clicks’ trigger in GTM
The first step is to create your trigger that will fire when a link is clicked. Click to create a new trigger.
Then choose the Click > Just Links trigger type from the list.
You can name it ‘Click – All link clicks’. The firing setting should be ‘This trigger fires on > Some Link Clicks“.
Include the following criteria for the link click trigger to fire: ‘Click URL > starts with > http‘. This prevents seeing “undefined” link clicks in your Google Analytics data.
Now that you have your trigger, it’s time to create your Google Analytics tag.
Creating an ‘All Link Clicks’ Google Analytics tag in GTM
The next step is to create your tag to send your link click data to Google Analytics. Click to create a tag and then choose the ‘Google Analytics: Universal Analytics’ tag type.
Then set up your tag in the following way:
Track Type = Event
Category = Link click
Action = {{Click URL}}
Label = {{Click Text}}
Non-Interaction Hit = False
Google Analytics setting = Your GA tracking code variable
And for the trigger choose the ‘Click – All link clicks’ trigger you have previously created.
Your trigger is now completed, so let’s test if it’s working in Google Tag Manager’s Preview mode.
Testing ‘All Link Clicks’ trigger in GTM preview mode
Turn on Google Tag Manager’s preview mode to take a look if your link click tag is working correctly.
If you click to open a link in a new tab on your website, then the tag should fire, as shown below. Below you can see that when clicking the link to the blog post, the “GA – All link clicks” tag fires.
Now that you’ve confirmed that the tag is working correctly in GTM, it is time to see whether the correct information is appearing in Google Analytics.
Testing whether the tag is working using Google Analytics Real-time report
To test whether the tag is sending the correct information to Google Analytics, navigate to the Real-time > Events section.
Make sure you view an unfiltered view of your website, so that your own clicks are included.
If you click on the Event Category “Link click”, you can see a table showing Event Action and Event Label.
The Event Action is the URL that was clicked. The Event Label was the Click Text. If there was no Click Text, for example a user clicked an image that linked to a new page, the Event Label appears as (not set).
So the link click tag is working correctly and sending the correct information to Google Analytics.
How to differentiate between Internal and Outbound Link clicks in Google Data Studio
Now that you have link click tracking using a single tag, use a CASE statement in Google Data Studio to differentiate between the different types of clicks.
The CASE statement says that whenever an Event action contains the text “michaelhoweely.com” (replace with your own domain) then it will categorize it as an “Internal Link”. If the clicked URL does not contain the site URL (“michaelhoweely.com”) then it should be listed as an “Outbound Link”
In Data Studio it should look something like this.
How the end result looks in Data Studio
Using the new “Internal or Outbound links” dimension, you can filter between the two types of link clicks in Google Data Studio. You can see a sample screenshot below in the Data Studio report.
Note: In the full article (link below) the Data Studio report is embedded and shows live data. You can choose different dates, click on internal and outbound links and see how such report would look like when configured properly.
Furthermore, you can also add in a Page table and filter by what pages the events occurred on. But I’ve chosen to keep the above Data Studio report simple just as an example report.
Conclusion
If you want to see what specific links are getting clicks on your website, you can set it up with Google Tag Manager, configure in Google Analytics and have a nice report in Google Data Studio.
You can even go a step further and have a report per each page, to see where exactly those link clicks occurred.
How to track all Link Clicks using Google Tag Manager
PS. What’s the purpose of gathering all the data if you don’t do anything useful with it? This ☝ is definitely useful.