October 10, 2023
Missing Link Text of Outbound Clicks in GA4?
Updated: October 10th, 2023
Even though Google Analytics 4 can track events automatically (not just page_views), there are also some problems. One of the challenges is missing Link Text (link_text) of outbound link clicks. If you try to build a report using the Link Text dimension with the click event, you won’t succeed (at least when I write this blog post).
I expected that GA4 would do that automatically (because link_text is automatically tracked with file downloads), but unfortunately, that’s not the case.
In this blog post, I will show you a workaround where you build your own outbound link click tracking with Google Analytics 4 that replaces the built-in feature and tracks the missing link_text parameter (this will be later available as a Link Text dimension in the reports).
Table of Contents
– Hide the table of contents –
- Google Tag Manager
- Configure the trigger and variables
- Create a GA4 event tag
- Test everything
- Disable outbound click tracking in Google Analytics 4
- View outbound click data in the reports
- Final Words
Google Tag Manager
We will use Google Tag Manager for this task because I believe it’s the most flexible way. If you are not familiar with it and haven’t installed it on a website, take a look at this tutorial first.
Configure the trigger and variables
First, let’s start with variables. In Google Tag Manager, go to Variables and check if you see Click variables (e.g. Click ID, Click Text, etc.) enabled.
If not, click Configure next to that list and enable all variables that start with “Click”.
Then go to Triggers > New > Trigger Configuration > Just Links and enter the following conditions:
- Click URL does not contain [enter your own domain here]. If your website is www.mywebsite.com, then enter mywebsite.com.
- Also, include the following rule: Click URL does not match regex (ignore case) mailto:|javascript:void|tel:
That second rule will exclude things like email links, phone links, and other non-outbound links.
Save the trigger.
Create a GA4 event tag
The last part of the configuration is the event tag. It will send the data to Google Analytics 4.
First, you must have a Google tag (a.k.a. Google Config tag) already set in the Google Tag Manager container. Here’s a sample configuration of it (keep in mind that your Measurement ID will be different):
I entered the measurement ID as a constant variable because I believe it’s a better practice than copy-pasting ID from tag to tag.
If you’re not familiar with this tag, then read this tutorial first.
Create the event tag. In Google Tag Manager, go to Tags > New > Tag Configuration > Google Analytics > Google Analytics: GA4 Event. Then, select your existing configuration tag and enter the event name.
The default name (suggested by Google) is click but, in my opinion, this is too generic. Click can mean anything: outbound link, document link, menu link, etc. That’s why I would suggest using outbound_click as an event name instead.
In the “Event parameters” section, insert all click-related dimensions that Google Analytics 4 reports recognize:
- link_url
- link_id
- link_classes
- link_text
- outbound
- link_domain
And as their values, insert variables.
- link_url variable should be {{Click URL}} (it’s one of the GTM built-in variables)
- link_id should be {{Click ID}}
- link_classes should be {{Click Classes}}
- link_text should be {{Click Text}}
- in outbound enter true (that’s just what GA4 tracked automatically with the click event, so we are just replicating that)
- link_domain parameter requires an additional variable. Go to Variables > New > Auto-event variable and enter the following conditions:
Then use that variable as the link_domain parameter’s value.
In the Triggering section of the tag, select the aforementioned Link click trigger.
The final configuration of the event tag should look like this:
Save the tag.
Test everything
To verify if this is working fine, click the Preview button in the top-right corner of the GTM interface.
Then enter the URL of your website where you will test the outbound click tracking and hit Start.
A new tab/window will open with your website. Click any outbound link and go back to the Preview mode. You might notice that there are two Link Click events on the left stream. Don’t worry. This is normal (because the built-in tracking in GA4 is still active).
Check both of those Link click events. On one of them, your GA4 event tag must be displayed in the “Tags fired” section.
Now go Google Analytics 4 > Admin > DebugView. Find your device there.
And then eventually, you should see the outbound_click event appear in the feed. Click it, and check if all the link-related parameters are displayed correctly.
If debug view is not working for you, read this article.
Disable outbound click tracking in Google Analytics 4
In your Google Analytics 4 property, click Admin and then choose “Data Streams”.
Select your web data stream. In the Enhanced measurement section, click the gear icon.
Disable Outbound clicks and click Save.
Once you do that, go to Google Tag Manager and publish your changes (so that the new outbound click tracking would go live to the website visitors. You can do that by clicking the Submit button.
View outbound click data in the reports
The last (but not least) step is to learn where you can find the outbound click data in Google Analytics 4 reports. Weirdly enough, it’s not as intuitive as you would think. That’s why I have published a separate blog post explaining all the steps. You can find that tutorial here.
Missing Link Text in Outbound Clicks: Final Words
Weirdly, Google Analytics automatic event tracking (a.k.a. Enhanced Measurement) is not capable of tracking link_text automatically.
Luckily, we can implement a workaround and replace that with Google Tag Manager. The process (described in this article) looked like this:
- We configured click-related variables and a trigger
- Then we created a GA4 event tag that sends the outbound click to Google Analytics
- We disabled the built-in outbound click tracking in GA4 + published changes in Google Tag Manager. This replaced the default Google Analytics 4 feature.
- Finally, you should learn where to find that data later in your Google Analytics 4 reports.
Hopefully, Google Analytics 4 will fix this in the future so that no workarounds are needed.
4 COMMENTS
This is very helpful, thank you! Once word gets out (and it will) that GA4 enhanced measurement outbound link tracking doesn't capture "link_text" people will be looking for a solution and I hope your blog post comes up.
This is very helpful on how to replicate and improve the default outbound click event.
I have one question: is there a reason you didn't re-use the default GA4 outbound click event name (click) and instead made a new event name (outbound_click)? Would it cause any issues if we tried to re-use the "click" event name if we're turning off the default event capture?
Thanks for the article. Based on my experience with this, I would suggest using javascript: instead of javascript:void in regex condition, since this is also sometimes used (although probably not as frequently as the 'void' version). In my case, this regex caused the entire tag to work incorrectly.
Hey Julius,
Please tell me if I don't follow the rule @Also, include the following rule: Click URL does not match regex (ignore case) mailto:|javascript:void|tel:", will I be able to see clicks on the email address?