Analytics — How-to
How to track button clicks with Google Tag Manager & GA4.
Set up click tracking for any button in about 15 minutes — then mark it as a key event so you can see which pages and channels drive action.
Quick answer
- In Google Tag Manager, enable the built-in Click variables.
- Create a click trigger that matches your button's ID, class or text.
- Create a Google Analytics GA4 event tag (for example
cta_click) fired by that trigger. - Test in Preview, publish, then mark the event as a key event in GA4.
Before you start
- Google Tag Manager is installed on your site, with your GA4 Google tag set up in the container.
- You know which button you want to track. A unique
idorclasson the button (for exampleid="hero-cta") makes tracking much more reliable than matching text. - Check whether you need GTM at all: GA4's enhanced measurement already tracks outbound link clicks and file downloads automatically.
Step 1: Enable the built-in click variables
In GTM, go to Variables → Built-In Variables → Configure and turn on Click Element, Click Classes, Click ID, Click Text and Click URL.
Step 2: Create a click trigger
- Go to Triggers → New and name it, for example "Click – Hero CTA".
- Choose Click – All Elements for buttons, or Click – Just Links if the button is a regular link.
- Select Some Clicks and add a condition, such as Click ID equals hero-cta or Click Classes contains cta-button.
- Save.
Tip: if your button contains an icon or a span, clicks can land on the inner element. Matching on a class, or using Click Element matches CSS selector with #hero-cta, #hero-cta *, catches every click.
Step 3: Create the GA4 event tag
- Go to Tags → New and choose Google Analytics → Google Analytics: GA4 Event.
- Enter your GA4 Measurement ID (it starts with
G-). - Set the event name in lowercase with underscores, such as
cta_click. - Add event parameters:
button_text= {{Click Text}},button_id= {{Click ID}} andpage_path= {{Page Path}}. - Attach the trigger from Step 2 and save.
To report on your parameters in GA4, register them as custom dimensions under Admin → Custom definitions.
Step 4: Test in Preview mode
Click Preview, enter your site address and connect. Click the button, then confirm in Tag Assistant that your tag fired on that click. In GA4, open Admin → DebugView to watch the event arrive with its parameters.
Not sure your tracking is right?
We audit GA4 and Tag Manager setups and fix what's broken.
Step 5: Publish the container
Click Submit, add a version name that describes the change (for example "Hero CTA click tracking"), and Publish.
Step 6: Mark the click as a key event
Key events are what GA4 used to call conversions. To make your click count as one, go to Admin → Data display → Events and click the star next to cta_click. If the event hasn't arrived yet, create it under Admin → Events → Create event with "Mark as key event" turned on — GA4 will treat it as a key event once it's collected.
Frequently asked questions
Why isn't my click event showing in GA4 reports?
Standard reports can take 24–48 hours to update. Use DebugView or the Realtime report to confirm the event is arriving right away.
Should I use "All Elements" or "Just Links"?
Use Just Links for anchor links and All Elements for buttons and anything else. All Elements works for both, but needs a tighter condition so it doesn't fire on every click.
Can I track every button with one tag?
Yes. Give all your call-to-action buttons a shared class, trigger on that class, and send the button text as a parameter so you can tell them apart in reports.
What's the difference between a key event and a conversion?
In GA4, key events are the actions you mark as important. "Conversions" now refers to key events imported into Google Ads for bidding.