Tracking of link clicks at Google Tag Manager 2.0

Several weeks ago I wrote a post about how to track clicks at Google Tag Manager.
Firstly, the division into “Clicks” and “Link clicks” may seem strange. What is the difference?

With the help of “Clicks” listener we can track clicks at ALL DOM-elements, but with the help of “Link clicks” – only clicks at links.

But why we can’t track link clicks with the help of “Clicks” listener?
After link click we have a redirection on an another page or a domain.That is why to send a hit (an event, a virtual pageview, etc.) to Google Analytics we should have enough time after a click on a link and before the redirection. This is a very short period of time (milliseconds) and sometimes GA does not have enough time to send a hit and we lose data.

“Link clicks” listener at Google Tag Manager allows “to wait”, while a hit will be successfully sent to Google Analytics, and only after that it makes a redirection on an another page. All process still takes milliseconds (and a user does not notice the difference), but data absolutely will be sent to Google Analytics.

Let’s say we want to track click on links from header menu:
Example of links at top menu

And we will send an event to Universal Analytics with several parameters:
Category: Links
Action: click
Label: “About me” or “Home” (depending on clicked link)
Value: 1

1. Check the variables settings

Let’s go to “Variables” menu at Google Tag Manager interface and make sure that variables at “Clicks” section are active:
Example of variables settings

I activated all of these variables, however, at this post I’ll use only “Click Text” variable.

2. Create triggers

Click “New” at “Triggers” menu for creation a trigger, which will track a click on links at header menu.

2.1. “Choose event” – choose “Click”

2.2. “Configure trigger”
a) Name your tag at “Trigger name” field(for example, “T – Links – Header”).
b) Choose “Link click” at “Trigger type” field and after that activate checkboxes “Wait for tags” and “Check validation”.

2.3. “Enable when” – there I used I used only one filter:
[ Page URL ] [ matches RegEx ] [ .*]
That means, that my link clicks will be listened at all of the website pages.

2.4. “Fire when”
a) Choose “Some clicks”
b)As I want to track clicks on links with the text “Home” or “About me”, I will have only one filter:
[ Click text ] [ matches RegEx(ignore case) ] [ (home)|(about me) ]

My tag configuration looks like following:
Example of trigger settings
Let’s click on “Save Trigger” and go to the next step.

3. Create a tag

Go to “Tags” menu and click on “New”.

3.1. “Choose your tag” – choose “Google Analytics”.

3.2. “Choose a tag type” – choose “Universal Analytics” and click “Continue”.

3.3. “What triggers this tag to fire?”
a) Choose “Click”
b) Choose a trigger at the popup window , which we have created at p.2, and click “Save”.

3.4. Configure your tag
Tag name: for example, “UA – Links – Header”.
Tracking ID: this means you should enter a Universal Analytics Tracking ID(UA-XXXXXXXX-X), which you can find at Google Analytics interface: “Admin -> Property -> Property settings”. I saved this string at a separate GTM variable “{{UA ID}}”.
Enable Display Advertising Features: – activate, if it is necessary.

The following settings are made for a certain event, which will be sent to Universal analytics after linking a click:
Track Type: Event
Category: Links
Action: click
Label: {{Click Text}} – I chose a variable “Click Text”, it’s value will be “Home” or “About me” depending on the text of the clicked link.
Value: 1

Non-iteraction hit: I did not make any changes at this option

My tag configuration looks like this:
Tag settongs example
Click on “Create Tag”.

4. Publish the container and check the results

Open Overview tab, click on “Publish” and click on “Publish now” at a popup window.

Go to “Real-Time -> Events” at Universal Analytics interface. If a tag was set up correctly, you will see an event at your reports after a click on “Home” link:
Results at Universal Analytics

Summary

This approach allows to track clicks on website links(both internal and external) and to be sure, that the data about clicks will be 100% sent to Google Analytics.

Digital analytics consultant.

Want to improve your website performance?
Contact me!

  • BK Mitesh

    Hi Ruslan,

    Thanks for a wonderful post, explain nicely. Looking for more post relate to GTM 2.0

    1) I have query that instead of click text if i use click classes is that okay? 2) For my ecommerce site if create above tags for different different url’s will my site speed will go slow? 3) Above steps if i use for banner click, navigation click, drop down clicks, image click will it be okay?

    Thanks!
    BK Mitesh

  • Ruslan Konygin

    Hi,
    1) Sure, you can use “click classes” instead of “click text” depending on your needs. For examle, if you have link with class “top-menu-link”, it is much more convenient to use “click classes”.
    2) If you have a lot of internal links, I do not sure, does it make sense to track them all? I think, that if you planning to track thousands of links on every website page, your website speed may slow down.
    3) a) I think, this is very useful for banners tracking. Especially if you place 3rd party(or your own) banners on your website and want to track, how often visitors click them.
    b) Of course, you can track navigation and image clicks
    c) Not sure about dropdown – it depends on your case. For example, if you mean dropdown menu, which contain <a> tags – then yes.
    But if you mean dropdown, made by HTML-tags <select> and <option> – you should use another techniques.

  • BK Mitesh

    Thank you so much Ruslan, i will implement it for my site and if any query will get back to you.

  • Hi Ruslan,

    We are starting with GTM and this is really simple to understand in how to track clicks in any part of your website 🙂

    Thanks and keep on going 🙂

  • harini

    I dont have RegEx is it possible to track internal links clicks? If it is poosible please suggest me how to do it..