• Courses
    • Courses
    • Course bundles
  • Blog
  • Services
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • About
    • About
    • Contact
  • Login
  • Courses
    • Courses
    • Course bundles
  • Blog
  • Services
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • About
    • About
    • Contact
  • Login

December 8, 2022

Track Clicks with Google Analytics 4 and Google Tag Manager

Updated: December 8th, 2022

If you are just starting to get a grip on Google Tag Manager, click tracking is probably one of the most demanded things you want to implement. There are many clickable elements on your website and you want to understand how website visitors are interacting with them.

In this blog post, we will take a look at how to track clicks with Google Analytics 4 and Google Tag Manager.

First, we will look at some automatic click-tracking capabilities in GA4, and then we will extend the list of tracked events with help of GTM.

By the way, if you are completely new (or just starting) with Google Analytics 4, download my free e-book below.

 

Ready? Let’s get started.

 

Table of contents

+ Hide table of contents +

  • Video tutorial
  • Why track clicks?
  • Automatic click tracking in GA4 (Enhanced Measurement)
  • Track custom clicks
  • Register custom definitions
  • Test your click tracking in Google Analytics 4
  • Track button clicks
  • Mark important clicks as conversions
  • Final words

 

Video tutorials

If you prefer Youtube videos, here’s one from my channel. If you haven’t yet, consider subscribing to stay up-to-date with Google Analytics 4.

Looking for tips specific to Button Click Tracking? Here you go.

 

Why track clicks at all?

Think about this: what are the most common interactions you do on any website? It will *probably* be page views, scrolling, and clicking. You click links and buttons to navigate from one page to another, to reach a particular goal. Your website visitors do that as well.

That’s why it’s crucial to track such interactions – to better understand user/visitor behavior. Capture clicks, send their data to your analytics tool(s), like Google Analytics, and analyze the data.

Here are some of the popular uses cases for click tracking in Google Analytics 4:

  • Button click tracking (say “Add to cart” button clicks)
  • Outbound link clicks (track when a visitor clicks a link leading to an external resource (3rd party website))
  • Contact link clicks (e.g. clicks email addresses or phone numbers)
  • File downloads (when someone clicks a link that contains a file extension, e.g. .pdf, .docx, etc.)

In this blog post, we’ll take a look at how Google Analytics 4 is capable of automatically tracking outbound link clicks and file downloads. Then I will show you an additional example when you might want to track other clickable elements on a website (that are links). And if that is not enough, I will provide additional resources related to button click tracking.

 

Automatic click tracking in Google Analytics 4

When you configure a web data stream in Google Analytics 4, you have an option to use Enhanced Measurement. It is designed to help marketers get as many events in the reports as possible without the need to cooperate with developers or configure in Google Tag Manager.

If you go to Admin > Data Streams > Select the web data stream, the following window will open where you will see a section called Enhanced Measurement.

By default, this feature is enabled and will automatically track the following events:

  • Page view (event name: page_view)
  • Scroll (event name: scroll)
  • Outbound link click (event name: click with the parameter outbound: true)
  • Site search (event name: view_search_results)
  • Video Engagement (events: video_start, video_progress, video_complete)
  • File Download (event name: file_download)

If you want, you can disable/enable events individually and you can do that by clicking the gear icon in the Enhanced Measurement section and then clicking toggle buttons.

Also, some events can be customized additionally. Let’s take a quick look at those events that are related to clicks.

click. This is an event for the outbound link click (when a clicked link redirects a visitor to another domain. Together with this event, an additional parameter outbound (with value “true”) is sent. The event with this parameter means that there was an outbound link click. Together with this event, a bunch of other parameters is sent: link_classes, link_domain, link_id, link_url.

If your business operates on several domains, you can go to Configure tag settings (of that very same event stream) > Configure your domains and then enter the domains of your business. All the domains that are listed there will not trigger the outbound link click event.

file_download. This event is sent to GA4 when a link is clicked and that link contains one of the following file extensions: .pdf, .xls, .xlsx, .doc, .docx, .txt, .rtf, .csv, .exe, .key, .pps, .ppt, .pptx, .7z, .pkg, .rar, .gz, .zip, .avi, .mov, .mp4, .mpe, .mpeg, .wmv, .mid, .midi, .mp3, .wav, .wma. In other words, if the link opens/downloads a file. Currently, it is not possible to update the list with other extensions in the GA4 interface.

Once you select which events you wish to track, hit Save in the top right corner and then make sure that Enhanced Measurement is enabled (the toggle is blue).

From that moment, your Google Analytics 4 will start automatically tracking the events. Use DebugView to check if everything is captured properly.

But what if you want to track clicks on other elements (that are not file or outbound links)? Well, let’s move to the next chapter.

 

Track custom clicks with Google Analytics 4

Tip: If you want to learn more about how to track events with Google Analytics 4, read this extensive guide (that also includes a video).

Here’s an example (that I’ve already mentioned in several of my other event-related GA4 guides). Let’s say that I have a demo website and I want to track clicks in the menu bar.

Note: menu link click tracking trigger conditions differ on most websites (because of different click classes, IDs, etc.). Try to do your best to apply this example.

First, I need to create a trigger with correct conditions that distinguish any click from a menu link click. Enable Google Tag Manager’s Preview mode and try clicking any of the menu links on a website. Once you click the first link, you should see the Link Click event in the Preview mode’s left sidebar.

If you don’t see it, you should:

  • have at least one Just Links GTM trigger activated on a page
  • or have “File download” or “Outbound links” tracking enabled in your Enhanced Measurement Settings

Let’s say, that you don’t use Enhanced Measurement in GA4. In that case, we should create a link click trigger. Go to Google Tag Manager > Triggers > New > Just Links. Keep the trigger set on “All link clicks” and save the trigger.

By creating this trigger, we will enable the link-tracking functionality in Google Tag Manager.

Then go to Variables > Configure (in the “Built-in Variables” section) and enable all Click-related variables.

Refresh the preview mode (by clicking the Preview button once again).

Then go to your website and click any of the menu links. Actually, click at least two of them. Return to the preview mode and you should start seeing Link Click events in the preview mode. Click the first Link Click event and go to the Variables tab of the preview mode.

Then click on the second Link Click event. I am currently looking for some variable that I could use to distinguish a menu link click. I don’t want to fire my GA4 event tag on any link click. I want to fire it precisely on a menu link click.

After taking a closer look, I see that both links contain the same Click Classes value, site-nav__link site-nav__link–main. By the way, nav means “navigation” in this context. Great! I will use this in my Just Links trigger.

Go back to the list of triggers in your GTM container and click the previously created trigger for All Link Clicks. We’ll edit it and add a condition: Click Classes contains site-nav__link–main

Save the trigger. Now, it’s time to create a Google Analytics 4 event tag. Go to Tags > New > Google Analytics: GA4 Event. Select your existing GA 4 Configuration tag and then enter the event name. Its value is up to you. Any of the following options are perfectly fine:

  • menu_click
  • menu
  • menu_item_click
  • menu click
  • etc.

These are just some of the examples. Since we are working with a custom event, we can name it whatever we want (as long as we follow the limitations of name length, for example).

In my case, I used menu_click event name. But this time, sending just the event name is not very useful. You’d probably want to know which exact menu items are clicked more often. How about we also send the name of the menu item and the URL?

We could do that by sending additional event parameters. Even though you could use parameters that are already mentioned in the documentation of the Enhanced Measurement (like link_url and link_text), let’s create two custom parameters (because I just want to show you how to configure them).

I am going to pass two parameters, menu_item_url and menu_item_name. I made these parameter names up and you can do it too. That’s what the flexibility of the data model offers.

To send custom parameters, you must expand the Event Parameters section in the Google Analytics 4 event tag and then click Add Row.

Enter the name of the first parameter. In my case, that is menu_item_url. In the Value field, I will insert a variable that returns a clicked URL. Luckily, GTM already offers such a variable, it’s called Click URL. Click the Insert Variable button and then select the {{Click URL}} variable.

Let’s add another parameter, menu_item_name. For that purpose, GTM offers another built-in variable, {{Click Text}}. Insert it as well. Since visitors of your website can translate your page, {{Click Text}} value will also change, hence you will see a more diverse list of collected values in your GA4 reports.

If you want to send more parameters, you are free to do that. You can send up to 25 custom parameters with a single event.

Assign the previously created Just Links trigger to this tag. Save the tag. Refresh the GTM Preview mode and click a couple of your menu items. Go back to the Preview mode and click those Link Click events. Check if the GA4 event tags for Menu Link Clicks have fired.

menu link click event in google analytics 4

Now, you will need to go to Google Analytics 4 and check the DebugView. You will learn more about that in this blog post.

IMPORTANT: even though you will see your custom parameters in Real-time reports and DebugView in GA4, you will not be able to see them in other GA4reports. Unless you register those parameters as custom dimensions in Google Analytics. Read the next chapter of this blog post.

 

Register custom definitions

This applies to any custom parameter that you send to Google Analytics 4. If you want to see/use them in things like Funnel exploration, Free Form, see their reporting cards in standard reports, etc., you must register custom parameters in the GA interface.

In Google Analytics 4, go to Admin > Custom Definitions. Since we sent 2 custom parameters with the menu link click, we must register them here.

Click the Create Custom Dimensions button and then enter:

  • The name of the parameter. You can enter whatever you want. This is just how the dimension will be displayed in your reports. You can name it “menu_item_url”, “Menu item URL”, or anything else.
  • Scope. Since we want to apply this parameter only to one event (and not to all events of the same user), we need to select Event
  • Event parameter. This is where you have to enter its name precisely as you entered it in the GTM tag. If your parameter name is menu_item_url, you must enter it here exactly like that. Don’t worry if the autocomplete feature of that field does not show your parameter yet. Just enter it and save the dimension

Then register a second parameter (in my case, that was menu_item_name) and save it. By the way, I sometimes use the words “custom parameter” and “custom dimension” interchangeably. In general, custom metrics and custom dimensions are both grouped as custom parameters.

And now we wait. Within the next 24 hours, the custom parameters will start appearing in your Google Analytics 4 reports.

 

Test your click tracking in Google Analytics 4

Once you configure your custom events, it’s time to test them. The primary feature built for debugging GA4 data is the DebugView section. You can find it by going to Admin > DebugView.

That’s the place where your debugging should take place. Do not mix this with the GTM Preview and Debug mode. They are two different beasts.

To enable the debug mode in GA4, you have several options (any of them will work):

  • Enable the GA debugger Chrome extension
  • Send a debug_mode parameter together with an event
  • Have enabled Google Tag Manager’s Preview mode on a page that you’re debugging

But since we are working with Google Tag Manager, having the GTM Preview mode enabled automatically enables the debug_mode, thus the data will start appearing in the GA4 DebugView.

When you start seeing data in the DebugView, you can click on every individual event and then a list of parameters will be displayed.

Click on that parameter to see the value that was received by GA4. Now that is some granular debugging!

Also, make sure that you have selected the correct Debug device in the top left corner.

If multiple visitors have enabled the debug view (e.g. they all have enabled the Chrome extension), you will see multiple devices there and it might require some time to find yourself.

Anyway, once you start seeing data in DebugView, things will look like this.

Events are marked with blue icons, conversions with green. In your case, the menu_click event will be blue (not green).

IMPORTANT: Please ignore the fact that I treat menu_click events as conversions. This is just for demonstration purposes 🙂

If you click the event, you will see the parameters that were sent together with an event. Click on the parameter to see its value.

Once you made sure that the data is coming in and it is displayed properly, you should submit your GA4 changes in the GTM container and publish it.

You can do that by clicking the SUBMIT button in the top right corner and then complete all the other steps that the user interface asks you to do.

After that, you should soon start seeing the new data coming in your real-time reports as well.

 

Track button clicks

On some websites, buttons are coded as simple links that just have a style of a button. But on other websites, they are coded as other elements (e.g. with HTML <button> element).

If that’s your case, the aforementioned examples will not help. Then you should refer to this blog post where one of the chapters specifically explains how to track button clicks).

 

Mark important clicks as conversions

Some clicks might be more important to your business than others, thus they should be configured in Google Analytics 4 as conversions. If you want to learn more about conversions (previously known as “goals”), here is a blog post (+ video) on how to do that.

Also, you can watch a video below:

 

Frequently asked questions

If you just skimmed this article and looking for some quick answers, this section might help.

Can Google Analytics track clicks? Yes, Google Analytics 4 tracks clicks. It offers built-in event tracking for document links and outbound links. If you want to track other clicks, you will need to do additional configuration. Everything is explained in this guide.

Can Google Tag Manager track link clicks? Yes, Google Tag Manager can track link clicks, but you will need to have enabled the Just Links trigger and include additional conditions in the trigger. Read this guide carefully, and you will learn how to do that.

Can Google Tag Manager track button clicks? Yes, Google Tag Manager can track button clicks, but you will need to have enabled the All Elements Click trigger and include additional conditions in the trigger. Read this guide carefully, and you will learn how to do that.

Where can I see click data in GA4 reports? First, you will need to register click data as custom dimensions. Then you will see them in reports like Explorations or Reports > Engagement > Events. Read more here and here.

 

How to Track Clicks with Google Analytics 4: Final words

And that’s the end of yet another Google Analytics 4 tutorial. This time, we learned how to track clicks with Google Analytics 4 (and obviously, Google Tag Manager). To sum up, the process looks like this:

  • If you want to file downloads and outbound link clicks, then use the built-in feature of GA4, Enhanced Measurement.
  • Want to track other link clicks? Create custom triggers in GTM and link them to GA4 event tags (like we did with menu link clicks)
  • Want to track buttons (that are not links HTML-wise)? Use the All Element Clicks trigger in GTM (I have linked to another tutorial of mine with some examples).

Also, don’t forget to register click event parameters as custom definitions (if you plan to use them in your GA4 reports).

 

Julius Fedorovicius
In Google Analytics Tips
22 COMMENTS
Manfred Lotz
  • Feb 5 2021
  • Reply

Thank you for this post! I really like how clearly you have explained GA4 and click tagging, especially explaining how to name event parameters.

Sephane
  • Mar 3 2021
  • Reply

Thank for your post, there are still a few left for GA4.
Maybe you can help me.
When i create a custom analysis, i vainly seek to recover outboung link paramaters values, more particularly the link_value.
Normally, no need to go through tag manager because as you indicate, outbound links are automatically tracked.
In the real time report, the url values of the outbound links are easily accessible. How to do it from the analysis center?

    Julius
    • Mar 3 2021
    • Reply

    Hi, please re-read the guide once again. Because the answer is there https://www.analyticsmania.com/post/track-clicks-with-google-analytics-4-and-gtm/#register-custom-definitions

Jade
  • Mar 26 2021
  • Reply

Thank you for this comprehensive guide. I'm still struggling to implement the tracking to pick up clicks to call and clicks to email as conversion events.

I've also not yet got the thank you page view as a conversion working.

I'm setting it up in the GA4 interface.

Can you help please?

    Tyler
    • Mar 28 2022
    • Reply

    I also have this question, regarding click-to-email and click-to-phone-call. Can these be set up within GA4, or do we have to implement GTM as a prerequisite? Thank you!

      Ben
      • Oct 11 2022
      • Reply

      I was under the impression that GA4 automatically tracked phone and email clicks, but that's clearly not the case. Can you provide any clarity to Jade and Tyler's comments on the best way to implement?

        Julius Fedorovicius
        • Oct 12 2022
        • Reply

        Create a trigger where click url contains "mailto" or "tel:" and then that will track those clicks

Pauline
  • Jun 11 2021
  • Reply

Hi Julius,

Your content is great. All of it, the book, the posts, the videos.

I have already taken courses (LinkedIn Learning, Online,...) and your stuff is BY FAR the most comprehensive and easy to follow as well as implement. Congratulations! It is clear that you not only are up-to-date and master the subject matter, but that you are talented at transferring your knowledge.

Thank you for taking the time to create 10x content, and shoot awesome videos.

    Julius
    • Jun 11 2021
    • Reply

    Thanks for the kind words! My paid courses are even better than my free stuff :) and they are also updated.

Michal Novacek
  • Oct 12 2021
  • Reply

Hi thanks for great blog post. I have set up new parameter to event from enhaneced measurement and the event is sent twice. One from enhaneced measurement second one is my "custom" from GTM. Is it possible to expand parameters for events from enhaneced measurement?

I put question on stackoverflow with detailed description.

Thanks for any help

Michal Novacek

    Michal Novacek
    • Oct 12 2021
    • Reply

    https://webapps.stackexchange.com/questions/159548/events-in-google-analytics-4-are-sent-twice

    Julius Fedorovicius
    • Oct 12 2021
    • Reply

    Disable that particular event in enhanced measurement. Build that event tracking in GTM

Craig
  • May 6 2022
  • Reply

Link Clicks is working but My Click Classes in the variables is showing "". When I inspect elements on the page they have a class of menu-item.

How can I get this value to show in Click Classes?

    Julius Fedorovicius
    • May 6 2022
    • Reply

    If click classes is empty, it means that your link does not have it. Then you would need to go advanced and learn CSS selector fundamentals.

Jacob Mann
  • Sep 22 2022
  • Reply

Great tutorial- works almost exactly how I want it to! What I seem to be missing is a longer range of data? I don't seem to be able to go back more than 60 days... but I've had GA4 running for more than a year.

    Julius Fedorovicius
    • Sep 22 2022
    • Reply

    You need to change data retention settings in GA4 property to 14 months

      Jacob Mann
      • Sep 27 2022
      • Reply

      Indeed I do! Found it shortly after asking. Thanks for the quick response!

allie williams
  • Oct 12 2022
  • Reply

Hi Julius,

Is there a reason why it is beneficial to create custom event parameters like "menu_item_url" instead of using built-in parameters like "link_url"?

I'm wondering if we can preserve a couple of custom dimension slots by using link_url and link_text instead of customized options.

Thanks!

    Julius Fedorovicius
    • Oct 13 2022
    • Reply

    No, there isn't. In reality, you should use link_url.

    Snippet from the article: "Even though you could use parameters that are already mentioned in the documentation of the Enhanced Measurement (like link_url and link_text), let’s create two custom parameters (because I just want to show you how to configure them)."

      allie williams
      • Oct 13 2022
      • Reply

      Thanks, Julius!

JB
  • Nov 15 2022
  • Reply

Hello Julius,

Do you know if we can, for native events such as click/scroll/first_visit/... either:
- send custom dimensions
- override dimensions such as the page_location (pagePath)

I'm asking in the scope of a manual implementation wih gtag.

I have 2 reasons to want this:
1/ We could use my custom dimensions for those events
2/ In the "Pages and Screens" report, we get a lot a pagePath with 0 views. I assume those are pages where we have overridden the pagePath for the page_view event, but it's still the original one for click/scroll/... events.

Thanks, and thanks for the great content.

Julia
  • Jan 22 2023
  • Reply

Hi Julius, thank you for sharing your knowledge! I set up and fine-tuned my GA4 events mostly with your guides.

I have a quick question and really appreciate your answer =)
Did I get it right, if I need a bunch of different link tracking like header menu clicks, footer menu clicks, some click interactions on the page and blog, etc - I need to set them up as events (tag_trigger) and only then they appear as events in GA4, correct?

There is no other way I can analyze those click interactions in GA4 reports without custom events? I am afraid of too many tags fired on the page and how useful are those events...

Thank you!

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • Cannot See the Google Tag Manager Option in Google Ads Conversion?
  • A Guide to Conversion rate in Google Analytics 4
  • Google Ads Conversion Tracking with Google Tag Manager
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings