How to Track Internal Link Clicks with GA4 and GTM?

You may want to analyze which links your site visitors click on. In addition, the CTR (click-through rate) of the anchor texts is important for SEO. Therefore, on-site link clicks are metrics that should be followed and changes should be made according to the analysis result.

In this post, I will show you how you can track which links your visitors click on how many times and which anchor texts they prefer to click with GA4 and GTM. The simple setup consists of 5 steps.

  1. Create a trigger
  2. Create a tag
  3. Check variables
  4. Create custom definitions
  5. Control

Contents

Step 1: Log into the GTM account that your GA4 account is linked to and create a new Trigger.

gtm create a trigger

You can write your Trigger name as Internal Link Click Trigger or a similar name of your own choosing. Then select Just Links in the Trigger Configuration section.

gtm just links

Here we indicate that we are only interested in clicks. Since our topic is internal link clicks, add the filter Click URL > contains > yourdomain.com (you should add your own site address here). Thus, only the clicks on the own domain within the site will be tracked.

gtm trigger filter

Save your trigger and let’s move to the Tags.

Step 2: Create a tag

Go to the Tags section from the GTM menu and create a new one. You can name your tag such as Internal Link Clicks Tag for GA4 or something like this.

In the Tag Configuration section, select Google Analytics: GA4 Event.

gtm ga4 event create

Next, you need to select the Configuration Tag. If you have a GA4 tag installed in the GTM, you can choose or can choose None – Manually Set ID. If you want to proceed with the Manually Set ID, you need to type the Measurement ID of the GA4 property. (Find it in GA4 > Admin > Data Streams > Measurement ID.)

Write your own Event name which will be shown in GA4.

Your tag is ready. But you also need to say which parameters you want to follow through the tag. So add two parameters.

  1.  Parameter name: internal_link_url, Value: choose Click URL.
  2. Parameter name: internal_link_text, Value: choose Click Text.

In this way, you will be able to follow the destination of the link with the first parameter and the text of the link with the second parameter.

After scrolling down the page you will see the Triggering. In this area, you need to connect the tag you created with the Trigger. Select and save the Trigger you created in the previous step.

gtm internal link click tag

Save your tag and let’s move to the Variables.

Step 3: Check your Variables

In the Variables section, we only need to check whether the Clicks elements are selected in our operations. You can check this by clicking the Configure button. All click elements under Clicks must be selected.

gtm clicks variables

Our steps in the GTM are done. Now we need to go to our GA4 property and create custom definitions.

Step 4: Create custom definitions

After accessing the GA4 property, go to Configure > Custom Definitions and hit to Create Custom Definitions button.

Now we need to create a dimension to follow the parameters we created in the GTM. We can write the name and description that we will constantly see and follow in our GA4 property. Scope must be chosen as Event.

In the Event parameter section, we will select the parameter names that we have determined in GTM before.

ga4 internal link dimension

We have to create two separate dimensions for Link Clicks & Link Texts. Name your dimension as Clicks and choose the internal link URL Event parameter for that. Then, name your dimension as text and choose the internal link text parameter. We will have two custom dimensions as a result.

All done. We are completely ready for controls.

Step 5: Control & Check it’s working.

Let’s go back to GTM and use Preview mode. Also, let’s keep the DebugView page open in GA4. Here we will see the results of our checks in real-time. Let’s click on a random link text on the site. Then let’s switch to the GA4 DebugView tab.

After waiting a few minutes, we will see the events taking place on the site. If all goes well, we should get a result similar to the screenshot below.

ga4 debug view mode

We see that the tags we created are recognized as events. Here you can see the internal link text and internal link URL by clicking on the details of the events.

2 thoughts on “How to Track Internal Link Clicks with GA4 and GTM?”

  1. I’m finding that the parameter names chosen in GTM aren’t not showing up in G4A under the Event Parameter drop down when creating custom definitions.

    Reply

Leave a Comment