Subscribe for notification

How to Track Link Clicks on Your Website Using Google Analytics & Google Tag Manager

Google Analytics is a powerful tool to track activities on your web pages. By default, it tracks all page views and provides you with important metrics related to those page views, such as the location, time on page, bounce rate, etc.

But is that really enough? You may want to know how many people clicked a particular link or a button on a page.

You need to do a modified implementation of GA in order to track these other activities on your website, such as clicks on links or buttons, form filling, video play, etc. Let’s learn how to track link and button clicks using GA and Google Tag Manager.

Prerequisites

  1. This tutorial assumes you are using Google Tag Manager (GTM) to implement GA and the code is already tracking page views. If you need help with this setup, check out the GTM help guide.
  2. You need to create a list of buttons or links you want to track. Also, these links should be uniquely identifiable, for instance, with a unique ID or class related to the link. You can also identify links based on the pages they appear in.

Let’s dive into the steps needed to implement this, shall we?

You may want to check out some of our recent content as well…

Step 1: Enable click variables in GTM

As the first step of enabling click tracking, you need to ensure that the click-related variables are enabled in Google Tag Manager. Go to your GTM Container Workspace, click “Variables” and then click “Configure”. Now, scroll down to find the click-related variables and enable them all, as shown in the following image 1.

Image 1.1: Enabling Click-Related Variables

Step 2: Put GTM in Preview Mode

Within your GTM Container, click the “Preview” button at the top right. This puts GTM in the Preview Mode as shown in image 2.

Image 1.2: Enable GTM Preview Mode

The Preview Mode allows you to see your GTM Preview & Debug pane. Simply open your website on a different tab on the same browser to see this pane, as shown in image 3.

Image 1.3: GTM Preview Pane

As you can see the default GA tag has already fired. If you go to your GA dashboard and check the real-time visits, you can see this visit.

Step 3: Create your click trigger for all clicks

Note: Refresh the Preview mode button once to ensure that the settings are saved. Ensure that you do this after any modification on your GTM Container as it will ensure that the modifications are properly saved for preview.

Now we need to ensure that all clicks are accounted for. For this, we will create a trigger that is fired if anyone clicks on any link on your website.

Go to the Triggers section on GTM and click “New”. Put a name for your trigger and under Trigger Configuration, select the trigger type as “Click->All Elements”. You can also select “Just Links” option if you don’t want to track clicks on other elements, such as buttons.

Image 1.4: Setting Trigger in GTM

Now, we need to have the trigger fire only for the one unique link that you want to track.

After your click trigger is created, refresh the Preview and we can check if the trigger is working properly. Go to the web page with a link and let the Preview pane load.

Note: Now, just click the link with the Ctrl key held down. This is to ensure that the click target opens in a new window and you can still see the Preview pane contents.

As soon as you click the link, you can see that a new “gtm.click” event has been fired in the Preview pane. In case of “Just Links” option in step 3, you will see “gtm.linkClick” as the name of the event.

Image 1.5: Click Event Firing in GTM Preview Pane

Click on the “gtm.click” event and then click the “Variables” tab. You will see that all those click-related variables have been captured here with the values associated with them. You need to identify one variable that you can use to uniquely identify the link that you want to track.

For instance, in this case, the “Click ID” variable would be useful to identify this particular click. The value of the variable, as you can see, is “testlink” (without the quotes).

Note: Middle-button clicks cannot be tracked using this setup. So, anyone clicking the middle button to open the link won’t trigger the tag. I’ll publish another tutorial about tracking that soon.

Now we will configure the variable that uniquely identifies the click you want to track in GTM.

Get back to GTM Container Workspace and click the link-click trigger you created. Under Trigger Configuration, click “Click – All Elements” and then select the radio button “Some Clicks”. Here, you need to select the unique variable and value associated with that particular click. As you can see in image 6, I have selected “Click ID” as the variable and “testlink” as the value. The matching operator can be “equals”.

Image 1.6: Configuring Click Trigger to Fire for Only Certain Clicks

If you want to add additional conditions to the trigger, such as make it fire only on certain pages, you can add those conditions using the “+” button. After finishing the setup, click “Save” at the top and refresh the Preview Mode.

Step 6: Implement the GA click tracking tag

Now your trigger setup is complete. We have to now create the GA tag that fires and captures the data associated with the click.

Within GTM Container Workspace, click “Tags” and then click “New”. Name your tag and click “Tag Configuration” to select the appropriate tag. Choose “Universal Analytics” and under the “Track Type”, select “Event” instead of Page View.

All clicks are tracked as Events within GA. There are a couple of parameters that are mandatory for all Events; they are Category and Action. So, type in the Category of the event as “Click” and action can be the URL of the click, which can be implemented using the click variables. Simply click the variable “+” button and select Click URL as the action.

Image 1.7: Google Analytics Event Tag for Click

For the additional, optional parameters Label and Value, you can select additional variables or manually put in the data. For instance, for Label, you can select the “Click Text” as the variable.

Image 1.8: GA Click-Tracking Tag Variable Selection

The Value is ideally the value of the link click. For instance, if it’s a purchase link, the Value may be the revenue from the purchase.

Don’t forget to select the correct GA variable.

Once done with the Tag Configuration, save it and select the click trigger you have already created. Save the tag. Now the new click tracking tag should be visible among your tags.

Step 7: Test the tag

Now we need to go to the web page and test whether the click tag is firing for the unique link you are tracking. Head over to the page where the link is and refresh the page. Any click you do on the page will automatically trigger the “gtm.click” event. Now, simply click the link with Ctrl key held down. Here, you should immediately see the name of the new click tracking tag being fired.

Image 1.9: Testing the Click Event Tag

Other normal clicks anywhere on the page won’t fire the tag. Only the click on the specific button or link identified with the limiting variable we specified earlier will fire the tag.

Once you see that the tag is fired, you can double-check if the values are properly returned by going to GA real-time view. Go to GA and under Real-Time, click “Events”. You should see the new click event being tracked with the correct Event Category and Event Action. If you click the Event Category, you can see the Event Label also. In my case, the Event Action was the URL of the link and Event Label was the link text.

Image 1.A: GA Real-Time View for Events

Step 8: Ensure to publish the tag and leave the Preview Mode

After you have verified that the tag is firing properly for the links you are tracking, you need to come out of the Preview Mode of GTM and publish the tag in the Container. Simply click the “Submit” button next to the “Preview” button to publish the latest changes.

Conclusion

In order to track button clicks also, the procedure is pretty much the same. Once the tag is implemented correctly, you can immediately see that it’s working properly through GA real-time dashboard. After about 24 hours, the events will be available in your Behavior section.

JOIN ZOOMOWL
TAKE THE SMARTEST PATH TO ONLINE BUSINESS SUCCESS
By subscribing, you agree with our Privacy Policy
Lenin VJ Nair: Lenin Nair has years of experience in marketing for software and technology domains. He is a certified specialist in marketing and enjoys exploring new ways to market products and services for small and medium businesses. He enjoys reading, writing, traveling, and ideating. He holds an MBA in marketing and a bachelor's degree in IT.

View Comments (22)

    • Hi, thank you for the comment. The "Value" is one of the fields you have within event tracking. You can add any variable to any of these fields. So, you can tag the page URL or page title or any of the available variables to it.

  • Lenin,

    Great article. I regret I did not discover it before now, as its a great demonstration on the topic. I've recently inherited a GA account, set up several years ago by other users, and in the "Events" reporting, there are event labeling that isn't always well described, which can't necessarily be inferred by staring at the title. Is there a way to "reverse engineer" an Event label in GA to determine what it's exactly capturing & reporting on?

    TY.

    • Dear Bill, thank you so much for visiting. I understand your issue, but unfortunately, the Events already set up cannot be edited from within GA interface. The best option would be to talk to those who set up the Event labels and find out their meanings.

  • Hi Lenin,

    Your article provides very nice info thanks for sharing it with everybody!
    I am convinced that this article is relevant for any business, in order to help them become successful.
    We actually wrote a similar article on the subject. I recommend you read it: Ideas are updated and slightly different from yours!

    Hope you will like it:
    https://www.codedesign.org/5-steps-phone-call-tracking-with-gtm/

    Thanks

  • Hello Lenin,

    I have a follow-up question ...

    In your document, specific to #6, wrote: "So, select the Category of the event as “Click” and action can be the URL of the click, which can be implemented using the click variables. Simply click the variable “+” button and select Click URL as the action."

    However, in my GTM Tag Configuration (actually, in two completely different GTM instances), I am unable to find a "Category" that is simply labeled as "Click". The VARIABLE NAMES displayed to me (as options from which to chose) are "Click Element", "Click Classes", "Click ID", "Click Target", "Click URL", "Click Text" ...

    I am trying to follow your instructions explicitly, but this is the first place they diverge from options I can find in GTM. Can you please advise on 1) Why can't I find "Click" as you described and depicted it in your screen capture, and 2) which would you advise for me to select among the available options?

    I appreciate your guidance. Your content is very value-added and contributes significantly to knowledge sharing in this space.

    • Hi Bill, I think I should not have mentioned to "select" the Category as "Click." What you essentially do is type in "Click" in that text box. It's not actually a variable that you have, so you can type whatever you want in the box. Variables that you select with the "+" button are distinguished with the {{var}} - double braces.

      Thank you so much for your comments.

  • I have a UTM_Medium source in the element link that I want to track. Which is the right variable to select that properly fires for that, please. Thank you.

  • Hello Lenin,
    I have followed your tutorial but i still cannot get any tags to fire on the event.
    I have tried a trigger on a number of the variables but none seem to work.

    My website is built in HTML5 and it essentially one HTML page that displays the "pages" using JQuery.

  • The best tutorial on setting up GTM link tracking I've found, referenced it on multiple occasions. Thanks for sharing.

  • Hi mate, great article thanks!
    One question: I have various downloadable PDFs on one single page. I’d like to track how many times users download those PDFs.
    To do this, I’ve added a “click ID” for each PDF link and created a trigger to “listen to” every time that link with the specific ID is clicked, so that the Tag can fire. The question is do I have to create one TAG for every downloadable PDF or one tag with multiple triggers assigned to it will do the job? The goal is to track each PDF download as an event in GA.
    Here is the page I’m talking about, at the bottom of it? You’ll see the downloadable PDFs (at the moment I have only assigned the class ID to only one PDF for testing) https://www.phoenixaustralia.org/for-organisations/high-risk-industries/
    Thanks
    Ricky

    • You are using this click ID as one of the parameters in the tag right, like the Label or Value? If so, in the reports, you can filter based on Label/Value and see the total number of downloads per PDF.

By continuing, you accept ZoomOwl's usage of cookies.