How to track external link clicks in GA4

Being able to track which pages are driving clicks to which websites can be really valuable for many websites, especially affiliate marketers. This is particularly true if you have individual articles linking to multiple sites as a way of driving revenue. Knowing which articles are driving clicks to which sites can be beneficial for the following purposes:

  • Content optimisation
  • Ordering list-type articles
  • Conversion rate optimisation
  • Testing potential affilaite schemes
  • Content ideation

The last point is particularly useful, if you can easily see what type of content drives traffic to which sites, you can use that to create more content to target clicks to those sites.

Being able to create and save custom reports is one of the big strengths of GA4. In this articles, we will show you how to do this in just a few easy steps.

Check it's working correctly

First of all, we need to check that your GA4 account is tracking external clicks correctly. This is built in to the standard GA4 setups so in most cases you won't need to do anything, but its worth checking anyway.

Go to "Admin > Data Streams. In the Enhanced measurement section, under events, there is a list of events that get tracked by default. Check that Outbound clicks is included in the list, as shown below. If its not included, go to settings and there should be an option to add it there.

data stream events, showing outbound click measurement

Next you need to check that these events are being tracked correctly. Go to "Reports > Realtime" and go to the Event Count widget. After clicking on some of the links on your site, you will see the "click" event appear. Click on this and you will see a list of parameters associated with this event. Check that "link_url" is included in this list. Once you can see it, you're ready to go.

realtime eventsclick events

Create a custom dimension

 Now that we know that GA4 is tracking outbound links correctly, you need to create a custom dimension so that it will appear in your reports. Go to "Admin > Custom Definitions" and then Create custom definitions. Here you need to create a new dimension for the link URL parameter you checked earlier. From here, enter the following settings:

  • Dimension name - this can be whatever you like, I called it Link_URL
  • Scope - Event
  • Event parameter - link_url

The description field is optional.

create custom definition in GA4

Next, you need to wait. As with Universal Analytics, you can't retrospectively track historic data so the new dimension will only start gathering data AFTER it has been created. After a couple of days of people clicking your outbound links, you'll be ready to create your dashboard.

Create Dashboard

GA4 has two default ways of creating dashboards; Reports and Explore. Both allow you to create custom dashboards to track any metric. However, at the time of writing, the Reports section does not allow you to create filters for custom dimensions. We're hoping that Google will fix this in the future, but in the meantime, you will need to use the Explore dashboard.

Go to Explore and create a new free form exploration, calling it "External link click report". Here, you need to import the dimensions and metrics that you need. In this screen, click the "+" next to Dimensions, select your new custom dimension (we called it Link_URL) and "Page path + query string". Then drag these dimensions over to where it says "Rows". For Metrics, select "Event Count" and then drag that over to where it says "Values".

Once you've selected the date range you require, your table will appear. However, when I did this the top URL is (not set). This is because it is tracking internal links as well as external. In order to fix this, create a filter, as shown below, to exclude link URLs matching "(not set)".

Once applied, your table will now look something like this:

external click GA4 dashboard

And that's it! Unfortunately, I've not found a way to change the column widths, but the report should still give the the jist of things. You can also export the data to feed it into any of your spreadsheets or reports to manipulate however you like. Adding extra filters (or even completely new dashboards) allow you to check for individual articles or websites to drill down your data for more in depth analysis.

Note

It occurred to me that the Explore section doesn't actually need you to create a custom dimension as you can add any parameter as a dimension. However, I'm hoping that the glitch preventing custom dimensions in filters for the Reports section will be fixed in the future. This would allow you to import this report into your standard library.