Tracking button clicks with Google Tag Manager
A page can have thirty clickable things on it and only three that matter. Tracking button clicks properly means teaching Google Tag Manager to recognise those three and ignore the rest, then sending a clearly named event to GA4 each time one is used. Done carelessly, you end up with a single event called "click" recorded 4,000 times a month, which tells you nothing at all.
This walkthrough assumes Tag Manager is already installed and your GA4 configuration is in place. Interfaces shift over time, so match the concepts rather than the exact button positions on your screen.
Turn on the click variables first
Out of the box, Tag Manager does not expose most click details. Open the Variables section, click to configure the built-in variables, and enable the click group — typically Click Element, Click Classes, Click ID, Click Target, Click URL and Click Text.
Without these you cannot build a trigger that distinguishes one button from another, and this is the step most people skip before wondering why nothing works.
Tag Manager also separates All Elements clicks from Just Links clicks. Use Just Links for anchor tags such as WhatsApp or tel links, and All Elements for buttons, divs styled as buttons and anything that is not a real link.
Find something stable to identify the button
Before creating a trigger, inspect the button in Chrome DevTools. Right-click it, choose Inspect, and look at the HTML for something you can match on.
In order of reliability
- An ID such as id="quote-btn". Unique and stable — the best option.
- A dedicated class such as class="track-cta". Ask your developer to add one purely for tracking so design changes cannot break it.
- The destination URL, ideal for links to wa.me, tel: or a specific page.
- Click Text, for example "Get a quote". Convenient but fragile: the day someone changes the wording to "Request a quote", tracking stops silently.
Avoid matching on framework-generated class names full of random characters. They change every time the site is rebuilt.
Build the trigger
Create a new trigger of type Click — All Elements, and set it to fire on some clicks rather than all. Then add a condition, for example:
- Click ID equals quote-btn
- Click Classes contains track-cta
- Click URL contains wa.me
- Click Text equals Download brochure
Two refinements save trouble later. First, if the same button appears in the header on every page but you only care about the pricing page, add a second condition on Page Path. Second, when a button contains an icon or a nested span, the click may register on the child element rather than the button, which is why "Click Classes contains" is usually safer than "equals".
Send the event to GA4 with a name that survives
Create a GA4 Event tag, select your configuration or measurement ID, give the event a name, and attach the trigger you just built.
Naming rules worth enforcing
- Lowercase with underscores: whatsapp_click, quote_request_click, brochure_download.
- Describe the action, not the design. green_button_click becomes nonsense after a redesign.
- One event name per type of action, with parameters for the variations.
- Avoid reserved GA4 names such as page_view or purchase unless you mean exactly that.
Add parameters rather than multiplying event names. Useful ones include button_location (header, footer, sticky bar), page_path and button_text. Two or three parameters give you plenty to slice by, and each custom parameter you want visible in standard reports needs registering as a custom dimension in GA4 admin.
Write the naming convention in a shared document. In six months, when a colleague adds another tag, that document is the only thing keeping your reports readable.
Test in preview mode before publishing
Tag Manager's preview mode opens your site in a debug window that shows every event as it happens and which tags fired.
- Click Preview in the container and enter your site URL.
- Click the button you are tracking in the preview window.
- Find the click event in the left-hand timeline and confirm your tag appears under Tags Fired.
- If it shows under Tags Not Fired, open it to see exactly which condition failed.
- Check the Variables tab for that event to see the real Click ID, Classes and Text values.
- Click other buttons and confirm your tag does not fire for them.
- Open GA4 DebugView and confirm the event arrived with the right name and parameters.
Step six is the one people skip, and it is the difference between useful data and a tag that fires on every link on the site.
Common problems and their causes
- Tag does not fire at all. Click variables not enabled, or the element is inside an iframe where Tag Manager cannot see it.
- Tag fires, then the page navigates away before the event sends. Rare with modern GA4 tags, but if you see missing data on outbound links, discuss the tag's transport settings with your developer.
- Every click counts twice. Usually two triggers, or both an All Elements and a Just Links trigger on the same tag.
- Works on desktop, not on mobile. The mobile layout often uses a different button markup with different classes.
- Stopped working after a redesign. The classic cost of matching on click text or auto-generated classes.
- Published but no data. Preview mode changes are not live until you submit and publish the container version.
Publish, then review after a fortnight
Publish the container with a clear version name describing what you added, then look at the events report two weeks later. If a button you assumed was vital records 11 clicks while a footer link records 300, that is a design decision waiting to be made. Our team often reviews click data before proposing changes to a landing page, because it shows what visitors actually reach for.
Frequently asked questions
Do I need Tag Manager to track button clicks?
No — a developer can call gtag directly in the button's click handler. Tag Manager is preferred when marketing staff need to add or change tracking without a code deployment each time.
Should every tracked click be marked as a key event in GA4?
Only the ones that represent real business value, such as a WhatsApp or quote-request click. Marking every click as important makes the reports meaningless.
Why does Click Text show something different from the button label?
Click Text returns the text of the exact element clicked, which may be an inner span or icon. Inspecting the Variables tab in preview mode shows you what the trigger actually received.
Can I track clicks on elements loaded after the page?
Yes. Click triggers listen at the document level, so buttons added later by scripts are still detected, as long as they are not inside an iframe.
We can do this for you
See what a package covers and what it costs, or ask us about your own project.

