Tag Manager - Analytics

How To: Track Internal Link Clicks in GA4 Using Google Tag Manager

How To: Track Internal Link Clicks in Google Analytics 4 via GTM

TL;DR:
GA4 doesn’t automatically track ordinary internal link clicks with its default click event. Enhanced Measurement uses the click event for outbound links, so if you want to track which internal links users click, including menu, content and footer links, you’ll need additional tracking. This guide shows how I use Google Tag Manager to send a custom click_internal_link event to GA4, including the link text, destination path, source page and page section.

Does GA4 Track Internal Link Clicks Automatically?

No. GA4 doesn’t automatically record ordinary internal link clicks using its default click event. With Enhanced Measurement enabled, the click event is used for outbound link clicks, where somebody clicks a link that takes them away from your domain.

There are many ways you can enhance your GA4 tracking with bespoke events implemented using Google Tag Manager, and internal link tracking is one of my favourites.

It lets you see how users navigate around your website, including which links they click within your menus, main content and footer.

If you want to know which internal links users actually click, rather than simply seeing the subsequent page view, you need to implement additional tracking.

The following is the approach I use on client websites following a standard website tracking audit. It uses Google Tag Manager to send a custom click_internal_link event into GA4, along with useful information about the link and where it was clicked.

Setting Up Internal Link Click Tracking in GA4

The setup uses Google Tag Manager to detect clicks on links that point to your own website and send them to GA4 as a custom click_internal_link event.

Rather than simply recording that a click happened, I also pass additional parameters with the event so I can see which link was clicked, where it pointed, which page the click happened on and where on the page the link appeared.

This gives you much more useful data for analysing how people navigate around your website, including interactions with menu links, contextual links within your content and links in the footer.

Here’s how I set it up.

Step 1: Create the click_internal_link GA4 Event

The first step is to create the GA4 event that will be sent whenever somebody clicks an internal link.

In Google Tag Manager, create a GA4 event with the event name:

click_internal_link

Configure the event as follows:

Event Tag Config

Step 2: Configure the Internal Link Event Parameters

Recording the event tells us that an internal link was clicked, but the parameters are what make the data genuinely useful.

I use the following parameters to capture information about the link, its destination, the page it was clicked from and its position on the page:

  • click_text
  • click_path
  • page_path
  • page_section
  • click_class
  • click_id

You don’t necessarily need every parameter for every implementation, but this is the setup I use because it gives me plenty of flexibility when I come to analyse and report on internal link clicks.

click_text

This captures the anchor text of the internal link that was clicked. For example:

You can capture this using GTM’s built-in {{Click Text}} variable.

This is useful when the same destination is linked from multiple places or using different anchor text, because you can see which particular internal links users are actually interacting with.

click_path

This captures the path of the page that the internal link points to.

GTM already provides the built-in {{Click URL}} variable, but this returns the full URL, including the domain. For example:

https://daveashworth.co/skills/analytics-and-ad-tracking-consultant/cookie-consent-compliance/

You can track the full URL if you prefer, but because we already know this is an internal link, I generally find the path more useful for reporting.

To remove the domain, create a Custom JavaScript variable using:

function()
{
  var a = document.createElement('a');
  a.href = {{Click URL}};
  return a.pathname + a.search + a.hash;
}

This converts the full clicked URL into:

/skills/analytics-and-ad-tracking-consultant/cookie-consent-compliance/

I then pass this value to GA4 as the click_path parameter.

Keeping the query string and fragment in the returned value also means you can distinguish between internal links that point to different URL parameters or anchors on the same page.

page_path

This captures the path of the page where the internal link was clicked, rather than the destination of the link.

You can capture this using GTM’s built-in {{Page Path}} variable. For example:

/skills/google-tag-manager-consultant/

This means that when you analyse the event in GA4, you can see both:

  • page_path – the page the user was on when they clicked
  • click_path – the page the internal link pointed to

Together, these make it possible to analyse how users navigate from one page to another through your internal links.

If you’d prefer to capture the complete source URL rather than just the path, you can use {{Page URL}} instead.

page_section

This is one of the most useful parameters for me. As well as knowing which internal link somebody clicked, I want to know where on the page that link appeared.

For example, was it:

  • a navigation or menu link in the header
  • a contextual link within the main content
  • a link in the footer

This means the same internal link event can also be used to analyse things such as menu clicks in GA4, rather than requiring a completely separate tracking implementation for your navigation.

Similar approaches can also be used to track clicks on banners, CTAs and other important content areas. Combined with form tracking, this can give you much deeper insight into how users engage with your content and conversion paths.

To capture the page section, I use the following Custom JavaScript variable:

function() {
  // Function to check if an element matches a given selector
  function matchesSelector(element, selector) {
    var matchFn = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector;
    return matchFn ? matchFn.call(element, selector) : false;
  }

  // Get the clicked element from GTM's built-in variable
  var clickedElement = {{Click Element}};

  // Selectors for different sections
  var headerSelector = "nav, nav *, #mbl-menu, #mbl-menu *";
  var contentSelector = ".container, .container *";
  var footerSelector = "footer, footer *";

  // Check if the clicked element or any of its parents match the selectors
  while (clickedElement) {
    if (matchesSelector(clickedElement, headerSelector)) {
      return "header";
    } else if (matchesSelector(clickedElement, contentSelector)) {
      return "content";
    } else if (matchesSelector(clickedElement, footerSelector)) {
      return "footer";
    }
    clickedElement = clickedElement.parentElement;
  }

  // Default return if no section is matched
  return "unknown";
}

You’ll probably need to amend the selectors to match the way your own website is structured.

The important lines are:

headerSelector
contentSelector
footerSelector

If your site uses standard semantic elements such as <nav>, <main> and <footer>, you can target those elements directly. For example:

var contentSelector = "main, main *";

The first selector targets the element itself, while main * also matches elements contained within it.

If your layout uses IDs or classes instead, you can target those in the same way. For example, an ID:

#mbl-menu, #mbl-menu *

Or a class:

.container, .container *

Finally, these lines determine the value sent to GA4:

return "header";
return "content";
return "footer";

You can change these values or add additional page sections if you need more granular reporting.

click_class and click_id

You may also want to capture the CSS class or ID of the element that was clicked.

This can be useful when you want to distinguish between particular types of internal links, such as a “read more” component, a specific CTA or links within a particular part of your navigation.

GTM already provides built-in variables for both, so you can simply pass:

{{Click Classes}}

and:

{{Click ID}}

into the corresponding click_class and click_id event parameters.

I treat these as optional parameters. Whether they’re useful will depend on how your website is built and how granular you want your internal link reporting to be.

Step 3: Create the Internal Link Click Trigger

Next, create the trigger that determines when the click_internal_link event should fire.

In Google Tag Manager, select the trigger type:

Click – Just Links

Then set the condition to:

Click URL – starts with – your domain

For example:

https://daveashworth.co

This means the trigger will fire when somebody clicks a link pointing to a URL on your own domain, rather than an external website.

Trigger Config

If your website operates across multiple subdomains that you also want to treat as internal, you can use a regular expression instead.

For example, if I wanted to capture internal link clicks across both www and shop subdomains, I could use:

^https:\/\/(www|shop)\.daveashworth\.co\/.*
Trigger Config Regex

Adjust this condition to match your own domain and website setup. The important thing is that the trigger captures the internal destinations you consider part of the site without also firing for outbound links.

Step 4: Test the Internal Link Event and Trigger

Before publishing the changes, use Preview mode in Google Tag Manager to make sure the event fires as expected.

Click several different internal links on your website, ideally from different page sections such as the header, main content and footer.

If everything is configured correctly, you should see the click_internal_link event fire in the GTM debugger with the parameters you’ve configured.

GTM Debugger

Check the parameter values as well as the event itself. For example, make sure:

  • click_text contains the expected anchor text
  • click_path contains the destination path
  • page_path contains the page the click originated from
  • page_section correctly identifies the header, content or footer

I’d also test an external link to confirm that the internal link trigger does not fire.

Once you’re happy that everything is working correctly, publish the GTM container.

Step 5: Create Custom Definitions for the Event Parameters

Once the event is live and sending data to GA4, you’ll need to create custom definitions for any custom event parameters you want to use in your GA4 reports and Explorations.

For example, if you want to report on the page_section parameter, go to:

Admin → Data display → Custom definitions → Create custom dimension

Give the dimension a clear name, select Event as the scope, and enter the corresponding event parameter, such as:

page_section

Step 6: Create an Internal Link Click Report

Now that the event and parameters are being collected, you can use the data to analyse which internal links users click and how they navigate between pages.

You can do this directly in GA4 using Explorations, or build a more flexible report in Looker Studio.

Report internal link clicks in Looker Studio

To create an internal link click report in Looker Studio, add the dimensions you want to analyse, such as the source page, destination path, link text and page section.

Use Event count as the metric, then add a filter so the report only includes:

Event name = click_internal_link

This gives you a useful way to analyse which internal links are receiving clicks, where those links appear and how users are navigating through the site.

For example, you could compare header or menu clicks against contextual links within the main content, or identify which destination pages receive the most internal click-throughs.

Once your events and parameters are configured correctly, you can also use them within broader GA4 reporting where appropriate.

Report internal link clicks in GA4 Explorations

If you don’t need a separate Looker Studio report, you can analyse the same event directly within a GA4 Exploration.

Create an Exploration using the relevant dimensions and metrics, then filter the report to:

Event name = click_internal_link

Which reporting method you use is largely down to preference. The important part is that you’re no longer limited to knowing that somebody viewed another page. You can analyse the actual internal link they clicked to get there.

Why Track Internal Link Clicks in GA4?

Internal link tracking gives you a level of behavioural data that you don’t get from standard GA4 page view reporting alone.

Instead of only seeing that somebody moved from one page to another, you can see which internal link they clicked, where that link appeared and which page it took them to.

I find this particularly useful for understanding how people interact with navigation menus, contextual links, calls to action and other routes through a website.

You can then use that data to answer questions such as:

  • Which internal links get the most clicks?
  • Are users navigating through the links within the main content?
  • Which pages receive the most internal click-throughs?
  • Do users interact more with header, content or footer links?
  • Which menu links are actually being used?

It’s a relatively simple addition to a GA4 and GTM setup, but it can give you much more useful insight into how people actually navigate around your website.

If you need help implementing custom GA4 event tracking or configuring GTM for more advanced reporting, take a look at my analytics and tracking consultancy services.




About The Author

I'm Dave Ashworth, a freelance SEO and website optimisation consultant with a background in development and a focus on fixing what's broken, improving what's working, and helping businesses grow through clear, practical SEO.

I combine hands-on technical know-how with years of experience in analytics, content strategy and platform optimisation. Whether it's an audit, a migration, or ongoing performance support, my work's about making websites stronger, faster, and easier to understand for - users, search engines and AI platforms.

When I'm not writing guides or sharing insights, I'm working directly with clients to solve problems, track results, and keep their sites moving in the right direction.

Dave Ashworth

get in touch

If you need some expert website optimisation and configuration, want to find out more, or even just have a question, fill in the form below as I will always be happy to help