How to Track Internal Link Clicks in GA4 (With and Without Google Tag Manager)


How to Track Internal Link Clicks in GA4 (With and Without Google Tag Manager)

It’s important to note that GA4 doesn’t track internal link clicks by default. If you want to gather valuable data on how users are navigating your site, tracking internal link clicks is a must. Understanding which pages users are clicking on, where they go next, and which calls to action are the most effective can help improve your site’s performance.

In this post, we’ll walk through two approaches to tracking internal link clicks in GA4:

  1. Using Google Tag Manager (GTM).
  2. A simple JavaScript solution for those who prefer not to use GTM.

How to Track Internal Link Clicks in GA4 Without Google Tag Manager

The most efficient method to track internal link clicks in GA4 without relying on Google Tag Manager (GTM) is by enabling and properly configuring the Enhanced Measurement feature within your Data Stream settings, which automatically captures link clicks. This option is the easiest way for most users to get foundational data, as it requires no custom code or GTM container setup. Once enabled, GA4 listens for all link interactions, and you can then use a simple Exploration Report filter to exclude your own domain and isolate only the internal clicks you wish to measure.

Option 1: Track Internal Link Clicks with Google Tag Manager

If you’re using Google Tag Manager, the process of tracking internal link clicks is pretty straightforward and doesn’t require much code. Here’s how to set it up:

Step 1: Create a Click Trigger

First, we need to create a trigger that fires when someone clicks on a link:

  • Go to your GTM account and create a new Click – Just Links trigger.
  • For the Trigger Configuration, choose Some Link Clicks.
  • Under “Enable this trigger when,” use the condition Click URL contains <your-domain-name>, so only internal links are tracked.

Step 2: Set Up a GA4 Event Tag

Next, we’ll configure a tag to send the event data to GA4:

  • Create a new GA4 Event Tag.
  • For the Event Name, use something simple like internal_link_click.
  • Add some important parameters:
    • link_url: Set this to Click URL (this is the destination of the link clicked).
    • link_text: Use Click Text to capture the text of the link.
    • link_classes: Capture the classes of the link using Click Classes.

Step 3: Test and Publish

After everything’s set up, use GTM’s Preview Mode to make sure your links are firing correctly. Once confirmed, publish the changes.

Now, when someone clicks on an internal link, you’ll start seeing events in GA4 with the details like the URL, link text, and class names.

Option 2: Track Internal Link Clicks Without Google Tag Manager

If you’re not using Google Tag Manager, you can still track internal link clicks with a simple JavaScript solution. This method works well if you’re comfortable adding a bit of custom code to your site.

JavaScript Code

Add the following JavaScript code to your site to capture clicks on internal links and send the data to GA4:


<script>
document.addEventListener('click', function(event) {
// Check if the clicked element is a link
let link = event.target.closest('a');
if (link) {
let linkHref = link.href;

// Check for tel: and mailto: links
if (linkHref.startsWith('tel:') || linkHref.startsWith('mailto:')) {
// Send event to GA4 for tel: and mailto: links
gtag('event', 'contact_link_click', {
'link_type': linkHref.startsWith('tel:') ? 'telephone' : 'email',
'link_url': linkHref,
'link_text': link.innerText || link.title || link.id || 'unknown',
'link_classes': link.className || 'no-classes',
});
}
// Check for internal links
else if (linkHref.includes(window.location.hostname)) {
// Capture data-* attributes
let dataAttributes = {};
Array.from(link.attributes).forEach(attr => {
if (attr.name.startsWith('data-')) {
dataAttributes[attr.name.replace('data-', '')] = attr.value;
}
});

// Send event to GA4 for internal links
gtag('event', 'internal_link_click', {
'link_url': linkHref,
'link_text': link.innerText || link.title || link.id || 'unknown',
'link_classes': link.className || 'no-classes',
...dataAttributes,
});
}
}
});
</script>

What’s Happening in the Code?

  • Event Listener: We’re adding a listener to detect clicks on all links on the page.
  • Internal Links Only: The script checks whether the link is pointing to an internal page (same domain).
  • Capturing Data: It grabs useful information like the link’s URL, text, CSS classes, and any custom data-* attributes you’ve added.
  • Sending to GA4: The gtag function sends this data to Google Analytics under the event name internal_link_click.

Comparing GTM vs. JavaScript

Feature GTM JavaScript
Ease of Use User-friendly interface Requires custom code
Setup Time Fast for GTM users Takes a bit longer to implement
Customization Limited by GTM’s capabilities Fully customizable with code
Data Tracking Basic (URL, text, classes) Advanced (e.g., data-* attributes)

Viewing the Data in GA4

Once you’ve set up either GTM or JavaScript to track internal link clicks, you can view the data in GA4:

  1. Go to Reports > Engagement > Events.
  2. Look for the event internal_link_click.
  3. You can drill down into the event parameters such as link_url, link_text, link_classes, and any custom data-* attributes you’re tracking.

Why Track Internal Links?

Tracking internal link clicks provides invaluable insights into how users interact with your website:

  • Optimize Navigation: See which pages people are clicking and how they move around the site.
  • Measure CTA Effectiveness: Understand which calls-to-action are driving clicks and conversions.
  • Improve User Flow: Analyze how users engage with different areas of your site and where they might be getting stuck.

By tracking internal link clicks, you can make data-driven decisions to improve your website’s user experience and conversion rates.

Next Steps

Whether you choose to use Google Tag Manager or JavaScript, implementing internal link tracking in GA4 is simple and highly beneficial. It gives you a clearer picture of user engagement, helping you make smarter decisions about site structure and content.

Got any questions or need help getting this set up? Contact me.

Implementing internal link tracking in GA4 is a pivotal step toward understanding user navigation patterns and optimizing your website’s performance. If you’re seeking to leverage these insights for more effective advertising strategies, consider exploring my Google Ads management services to enhance your campaign’s efficiency and ROI.

Related Resources:


Internal Link Tracking in GA4: Frequently Asked Questions

General Questions

What is internal link click tracking in GA4?

It's the process of recording an event in Google Analytics 4 (GA4) every time a user clicks on a link that points to another page on the same domain. This helps you understand user navigation and engagement on your website.

Why do I need to set this up? Doesn't GA4 track clicks by default?

GA4 has Enhanced Measurement that tracks outbound clicks (links going to a different website) by default, but it does not automatically track clicks on internal links. You must set up custom tracking to capture this data.

Why is tracking internal link clicks important?

Tracking these clicks provides valuable data to: Optimize Navigation; Measure CTA Effectiveness; and Improve User Flow.

Tracking with Google Tag Manager (GTM)

What are the three main steps to set up GTM tracking?
  1. Create a Click Trigger: Set a Click – Just Links trigger that fires only when the Click URL contains your domain name.
  2. Set Up a GA4 Event Tag: Create a new GA4 Event Tag with a custom name (e.g., internal_link_click).
  3. Add Parameters: Include parameters like link_url and link_text to send details about the link clicked.
What are the main advantages of using GTM?

The GTM method is generally considered easier to use for those already familiar with GTM, as it relies on a user-friendly interface and does not require writing or debugging custom code.

Tracking with Custom JavaScript

What extra data can the JavaScript method track that GTM can't easily?

The custom JavaScript method allows for advanced customization. The provided script can automatically capture any custom attributes prefixed with data-* that you might have on your links, which gives you more flexibility in the data sent to GA4.

Which method should I choose?

Choose GTM if you prefer an interface and are already a GTM user. Choose JavaScript if you don't use GTM or need to track advanced data (like data-* attributes).

Viewing the Data in GA4

Where can I see the click data in Google Analytics 4?

You can view the data in the Reports section of your GA4 property, specifically under Engagement > Events. Look for the custom event name you set up (e.g., internal_link_click).

How do I see the specific URL and text of the links that were clicked?

You can analyze the specific event parameters you configured (link_url, link_text, etc.) to see the details for each event instance.


About the Author

Jacob Lett is the founder of Bootstrap Creative, a digital marketing consultancy that helps Michigan manufacturers generate qualified leads through HubSpot, technical SEO, and Google Ads. With over a decade of hands-on experience, he acts as a direct partner for B2B companies seeking measurable ROI from their marketing investment.



Tags: ,

| Read My Editorial Policy

Want to Get Email Updates of New Articles?

Join My Email Newsletter