Lesson 1 of 15
Click & Link Tracking
① Connect your GTM container
Paste your container ID to load it into this page. It only ever runs here.
Advanced: use a specific environment
Most of the clicks you'll ever want to track, buttons, in-page links, outbound links, push nothing to the dataLayer. GTM can still catch them with its built-in Click and Just-Links triggers, which listen to the page directly.
You'll turn on the click variables, build one trigger scoped to a specific button and one that catches every link, then fire a single Custom HTML tag on both and watch them light up in Tag Assistant. The tag does nothing on purpose, the point is the wiring, not the payload.
Goal
Fire one tag on both a specific button click and any link click, using GTM's Click and Just-Links triggers, no dataLayer required.
Build it in GTM
Turn on the click variables
GTM hides the click variables by default, switch them on so your triggers have something to read.
- Go to Variables in the left sidebar and click Configure at the top of the Built-In Variables section.
- Switch on
Click Element,Click Classes,Click IDandClick URL. (Click IDis the one the CTA trigger reads.)
Trigger: Click - Primary CTA
This trigger fires only on the one button, matched by its id.
- Go to Triggers in the left sidebar and click New.
- Click the trigger-type box and choose Click → All Elements.
- Set it to Some Clicks so a condition appears.
- Set the condition to
Click IDcontainscta-primary. - Name it
Click - Primary CTAand Save.
Trigger: Link Click - All Links
This one catches every link click, both the in-page link and the outbound link.
- Go to Triggers → New again and choose Click → Just Links.
- Leave it on All Link Clicks with no conditions.
- Name it
Link Click - All Linksand Save.
Tag: Custom HTML - Test, fired on both triggers
- Go to Tags → New and choose Custom HTML.
- Paste
<script></script>as the HTML (it fires but does nothing, so you're just watching it run) and leave Support document.write unchecked. Name itCustom HTML - Test. - Under Triggering, add both
Click - Primary CTAandLink Click - All Links, then Save.
Debug in Tag Assistant
Copy this lesson's live URL and paste it into GTM Preview, that is the page Tag Assistant connects to. It has the clickable elements, so this page stays clean for reading.
- In your GTM, click Preview.
- Paste the live URL above and click Connect.
- Interact with the live page and watch your tag fire in Tag Assistant.
What you should expect to see
Click event (All Elements) and clicking a link adds a Link Click event (Just Links). Select either one and Custom HTML - Test appears under Tags Fired, with Click ID and Click URL reflecting what you clicked. Because the tag's <script> is empty, nothing visibly happens on the page, that's expected; you're confirming the trigger-and-tag wiring, not a real pixel.Verify your container
Built it? Export your container, Admin → Export Container, choose your workspace, then drop the JSON here to check it against this lesson.
Drop your container .json here
or browse · checked in your browser, nothing is uploaded