How to track outbound links in Google Analytics 4

Uitgaande links tracken in Google Analytics 4

If you have a website, it’s very likely that you’re using Google Analytics to measure the number of visitors to your site, which pages they’ve visited and how they landed on your site. Would you also like to know which links your visitors have clicked? In Google Analytics’ previous version, the site owner was required to add some custom code to their site. However, with Google Analytics 4, outbound clicks can be measured automatically. In this blog post I’ll explain you how to track outbound links in Google Analytics 4.

Automatically track clicks on outbound links with GA4 enhanced measurement

One big advantage of GA4 compared to its predecessor is that more things can be measured automatically, without having to manually tag those on your site. For example, GA4 automatically measures how far users scroll on your page, internal search, file downloads and external link clicks.

Elegant Themes offers two amazing WordPress
themes (Divi en Extra) for just $89 per year
OR $249 for lifetime access!

The only thing you’ll need to do is check whether your GA4 property is using Enhanced Measurement. You can verify this by going to Admin > Data Streams in Google Analytics. Then open your site’s data stream:

Data Streams in Google Analytics 4
Open your site’s Data Stream

Once you’re in the Data Stream, check whether Enhanced Measurement is activated

Enhanced Measurement for Google Analytics 4 Data Stream
Check if Enhanced measurement is enabled for your Data Stream

If Enhanced Measurement is not yet enabled, activate it. Your GA4 property will now start tracking outbound clicks. Also, file downloads, video views and site search will be tracked automatically by Google Analytics 4.

Note: After activating enhanced measurement, it can take up to 24 hours to see data in your GA4 reporting. Also, make sure you’re using the latest version of GA4’s tracking code (and not the “old” Universal Analytics trackingcode).

Where to find data on outbound clicks in your GA4 reports

Now that you’ve verified that Enhanced Measurement is enabled for your GA4 property, you should be able to find outbound clicks in your Google Analytics 4 reports.

Test using Realtime Analytics

To test whether outbound clicks are being measured, I use Realtime Analytics. I open my website in a private browsing (or Incognito) window and then check if I see “myself” in the Realtime reports.

To test the link tracking, click an external link on your website. After waiting a little bit, we should see the “click” in the Event count list:

Events Google Analytics 4 realtime
Events in the Realtime view of Google Analytics 4

If you click on the “click” row, you’ll see a view with more details about the clicks that happened. For example, the link_url property will show you on which exact URL the user has clicked:

link_url shows which URL has been clicked
link_url shows which URL has been clicked

Engagement report

In Google Analytics 4’s Engagement report, you’ll find all statistics related to clicks and other events that occur on your website. Many of these statistics are collected automatically by the Enhanced Measurement that we enabled before. You can find this under Engagement > Events.

Tracking internal links in GA4

Sometimes, you may also want to track clicks on certain internal links. For example, affiliate links that you’ve cloaked. On this website for example, I have affiliate links to SiteGround and Elegant Themes. When you click on such link, you’ll notice that the URL is, which looks like an internal link but in fact is a redirect to the affiliate link. I do this so that when the affiliate link changes, I only have to change it in one location ;-).

Unfortunately, GA4 by default will not track these internal link clicks. For this, you will need to use Google Tag Manager rather than the GA4 default tracking code. If you’re already using Tag Manager, please continue reading. If not, please migrate to Google Tag Manager (GTM) first before setting up internal link tracking.

Enable Click Variables

In GTM, go to Variables and then click Configure.

Google Tag Manager Variables

Now scroll and find the Clicks variables and check all the Click Variables checkboxes:

Click Variables in Google Tag Manager
Click Variables in Google Tag Manager

Enabling the right Triggers

Now go to Triggers in Google Tag Manager and click New:

Triggers in Google Tag Manager
Triggers in Google Tag Manager

Click Choose Trigger Type and choose “All Elements” where it says Click:

Select All Elements
Select All Elements

Now select Some Clicks to prevent measuring literally every click on your website. Then apply the relevant conditions for measuring this click. In my case, it would be “Click URL” contains “”. This way I’ll be able to measure clicks on my cloaked affiliate links. This should look something like below:

Click Trigger
Click Trigger

Now click Save on the top right corner.

Configure a Tag for our custom event

Finally, we’ll need to configure a Tag for our Custom Event. For this, go to Tags and create a new one. Select “Google Analytics: GA4 Event” as Tag Type. Then choose GA4 as the Configuration Tag and give your tag a name (e.g. “affiliate-link”). Finally, make sure to select the Trigger that we have created in the previous step and click Save.

Configure a Click Tag in GA4
Configure a Click Tag in GA4

Now that you’ve saved this, we can finally test and enable the changes in our Google Tag Manager container. Again, use Realtime Analytics to verify whether your event is being measured correctly:

Custom event in Google Analytics 4
Custom event in Google Analytics 4


Need to switch from a regular GA4 tracking code to Google Tag Manager? Soon I’ll publish a blog about how to do this.

Thanks for reading my blog!
If this blog post helped you, please consider following me on Twitter or subscribing to my YouTube channel. You can also leave a comment below this article. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *