How to Track a Button Click in Google Tag Manager?

Data AnalyticsStep by Step Guides

Tracking button clicks on your website is super important for understanding what your visitors are doing and making your site work better for them. By knowing which buttons people are clicking, you can get valuable insights into their behaviour, what they like, and how effective your site’s design and calls to action are. This info can help you make smart decisions about your website’s layout, content, and functionality, leading to a better user experience and higher conversion rates.

Google Tag Manager (GTM) makes this whole process easy and powerful without needing to mess around with your site’s code. With GTM, you can manage and deploy marketing and analytics tags on your website without any coding hassle. This means you can set up tracking for button clicks and other interactions quickly and efficiently, saving time and reducing the risk of mistakes.

With GTM, you can create triggers and tags to capture specific actions, like button clicks, form submissions, and page views. You can then send this data to Google Analytics or other analytics platforms to analyse and understand your users’ behaviour better.

In this guide, we’ll walk you through how to track a button click using Google Tag Manager. By following these steps, you’ll be able to track button clicks on your website and get the data you need to optimise your site for better performance and happier visitors.

Step 1: Set Up Variables

Navigate to “Variables” in the left-hand menu.

In the Built-in Variables section, click “Configure”.

Select variables such as Click URL, Click Text or Click ID that your button can be differentiated from other buttons. (It’s good to select all and find out what is uniquely identifiable in Preview mode.)

Step 2: Set Up a Click Trigger

Log into Google Tag Manager and select your container.
Navigate to Triggers in the left-hand menu and click on New.

Name your trigger (e.g., “Click – [Button name]”).
Click on Trigger Configuration and choose Click – All Elements.
Configure the trigger:
Select Some Clicks.
Set the conditions to identify your button. This could be based on the button’s ID, Click URL, Click Text, or other attributes. For example, if your button has a specific ID, you could set:

Click ID equals [button-id].

Click Save to create your trigger.

Step 3: Create a Tag

Navigate to Tags in the left-hand menu and click New.

Name your tag (e.g., “[UA/GA4] – [Button Name]”).
Click on Tag Configuration and choose your tag type. Common choices are Google Analytics: Universal Analytics or GA4 Event.

For Universal Analytics:
Track Type: Event.
Category: Button Click.
Action: Click.
Label: Use the variable you created (e.g., {{Click ID}}).

For GA4 Event:
Configuration Tag: Choose your GA4 configuration tag.
Enter the Measurement ID that belongs to the Google Analytics property you’d like to send the even to
Event Name: [Button Name]_click. For example: contact_us_click.

Click on Triggering and choose the trigger you created earlier (e.g., “Click – [Button name]”).
Click Save to create your tag.

Step 4: Publish Your Container

Once you have set up your tag, trigger, and variable, click on Submit in the top-right corner.
Add a version name and description, then click Publish.

Step 5: Test Your Tag

Click on Preview to enter the GTM preview mode.
Navigate to your website and perform the button click.
Check the GTM debug panel to ensure the tag is firing correctly.
It’s also good to go into Google Analytics and check debug mode to see if the event is sending to Google Analytics.

By following these steps, you’ll be able to track button clicks on your website using Google Tag Manager, providing you with valuable data to optimise your site and improve user experience.

Need help setting up GTM on your website? Contact Metric Labs for expert assistance in configuring and optimising your Google Tag Manager and Google Analytics.


Like this step by step guide?

Sign up to our email newsletter – Lab Report – and never miss a new one!