Don't have one? Create one ↗
← All courses

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

  1. Turn on the click variables

    GTM hides the click variables by default, switch them on so your triggers have something to read.

    1. Go to Variables in the left sidebar and click Configure at the top of the Built-In Variables section.
    2. Switch on Click Element, Click Classes, Click ID and Click URL. (Click ID is the one the CTA trigger reads.)
  2. Trigger: Click - Primary CTA

    This trigger fires only on the one button, matched by its id.

    1. Go to Triggers in the left sidebar and click New.
    2. Click the trigger-type box and choose Click → All Elements.
    3. Set it to Some Clicks so a condition appears.
    4. Set the condition to Click ID contains cta-primary.
    5. Name it Click - Primary CTA and Save.
  3. Trigger: Link Click - All Links

    This one catches every link click, both the in-page link and the outbound link.

    1. Go to Triggers → New again and choose Click → Just Links.
    2. Leave it on All Link Clicks with no conditions.
    3. Name it Link Click - All Links and Save.
  4. Tag: Custom HTML - Test, fired on both triggers

    1. Go to Tags → New and choose Custom HTML.
    2. 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 it Custom HTML - Test.
    3. Under Triggering, add both Click - Primary CTA and Link 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.

  1. In your GTM, click Preview.
  2. Paste the live URL above and click Connect.
  3. Interact with the live page and watch your tag fire in Tag Assistant.

What you should expect to see

In the Tag Assistant timeline, clicking the button adds a 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

0 of 15 lessons complete