Guide 110 · Container · GA4 + Tag Manager
Build a click trigger: fire a tag when a button or link is clicked
Button and link clicks are the most common custom events, and Tag Manager measures them without touching the page code. A click trigger listens for the click event the container already records, then filters on the element that was clicked — its text, its ID or its classes. Google's trigger page lists the two click trigger types, All Elements and Just Links, and the built-in variables page lists the six Click variables the filter can use: Click Element, Click Classes, Click ID, Click Target, Click URL and Click Text. The worked example fires when the Add to cart button is clicked, and only then.
After step 4, Preview mode shows the tag under Tags Fired on the click event for the Add to cart button, and under Tags Not Fired for every other click on the page.
Download the container fragment: the click trigger fragment (JSON) (export format version 2, 1321 bytes, MD5 065c49e22a8ba630de96fe819e5a9058). It holds the click trigger on All Elements with the Click Text condition, and a GA4 event tag that fires on it. The file is a hand-built import template, validated structurally — it was not exported from a live container.
What you need
- The Click built-in variables enabled. The filter compares Click Text, so Click Text must be enabled first — that is the built-in variables guide.
- One element to watch. The worked example is a button whose visible text is exactly
Add to cart. The text must match letter for letter, including case. - Edit access to the container. Creating a trigger is a container edit.
The trace
- Go to Triggers and click New. Triggers live in their own list in the left navigation. Click New and name the trigger
Click - Add to cart button— the name says what was clicked, not which tag uses it. - Click Trigger Configuration and choose Click - All Elements. The trigger types list has two click types: All Elements watches every click on the page, Just Links watches only link clicks. A button is not a link, so All Elements is the right type.
- Set the trigger to fire on Some Clicks. Choose Some Clicks and add one condition: Click Text equals
Add to cart. The trigger now matches only clicks on elements whose visible text is exactly that. The page has 4 buttons with visible text in the worked example — Add to cart, Buy now, Learn more and Sign up — and the condition matches 1 of the 4, so the tag fires on 1 click in 4. - Attach the trigger to the tag and save both. Open the GA4 event tag, click Triggering, pick the new trigger, and save. Preview mode confirms it: click Add to cart and the tag fires; click any of the other 3 buttons and it stays under Tags Not Fired.
Dead ends
DEAD END — JUST LINKS FOR A BUTTON. Just Links only watches clicks on links. A button that runs JavaScript instead of navigating is not a link, so a Just Links trigger never sees it. All Elements watches every click, button included.
DEAD END — CLICK TEXT THAT DOES NOT MATCH. Click Text is the visible text of the element, with its exact spacing and case. A button that reads Add to Cart with a capital C does not match a condition written Add to cart. Copy the text from the page, do not retype it.
DEAD END — A CLICK INSIDE A CLICKABLE PARENT. When a button sits inside a link, the click can register on the parent instead of the button, and Click Text reads the parent's text. If the trigger never fires, check in Preview mode which element the click event actually reports.
End state
One click trigger, Click - Add to cart button, firing only on that button, attached to one GA4 event tag. The same pattern — All Elements plus one Click variable condition — covers every button and link on the site.
Sources
- Tag Manager Help — Trigger types — Click trigger types All Elements and Just Links
- Tag Manager Help — Built-in variables for web containers — the six Click built-in variables, Click Text reading
gtm.elementText
Checked 11 November 2026. The click paths above are the ones in Google's help pages, opened 11 November 2026. No step in this guide was run inside a live Analytics property or a live Tag Manager container, because both need a Google sign-in and this site does not sign in as anyone. The container file was validated structurally instead: export format version 2, every tag's firing trigger resolves, every variable the tags reference exists in the file, and the tag types are the documented ones. Google moves menu items without warning; if a path on this page no longer matches, the linked help page is the current map. The container fragment for this guide is 1321 bytes (1.29 KB, 0.65% of the reported 200 KB container size limit), MD5 065c49e22a8ba630de96fe819e5a9058, and passed 13 structural checks.