Objective
Track user clicks (on buttons, links, icons, etc.) and send them to Google Analytics 4 as custom events using Google Tag Manager.
Step 1: Enable Click Variables in GTM
- In Google Tag Manager, go to Variables
- Click “Configure” (top-right)
- Under the Clicks section, enable the following:
- Click ID
- Click Classes
- Click Text
- Click URL
- Click Element (optional)
Step 2: Enable Click Trigger for Testing
- Go to Triggers → Click “New”
- Name the trigger: Click – All Elements Trigger
- Choose Trigger Type: All Elements
- Choose: “All Clicks”
- Click Save
Step 3: Preview the Site to Identify the Element
- Click Preview in GTM
- Enter your website URL and connect
- Interact with the element you want to track (e.g., click a button)
- In the Tag Assistant debug window:
- Click the click event
- View the values of variables like Click Text, Click Classes, or Click ID
Choose a value that’s unique to this button or link (e.g., the button text is “Download This File“)
Step 4: Create a Specific Click Trigger
- Go to Triggers → Click New
- Name it: Click – Download This File
- Trigger Configuration → All Elements
- Choose: “Some Clicks”
- Set a condition, for example:
- Click Text equals Download This File
- Click Classes contains btn-download
6. Click Save
Choose the most reliable selector based on your site’s code.
Step 5: Create the GA4 Event Tag
- Go to Tags → Click New
- Name it: GA4 – click_download_file
- Tag Configuration → Select Google Analytics: GA4 Event
- Choose your GA4 Configuration Tag
- Set Event Name to: click_download_file
- Add Event Parameters (optional but helpful):
| Parameter Name | Value |
| button_text | {{Click Text}} |
| page_path | {{Page Path}} |
| click_url | {{Click URL}} |
7. Scroll to Triggering → Select your click trigger (Click – Download This File)
8. Click Save
Step 6: Preview and Test
- Click Preview again in GTM
- Click the button/link on your site
- In the Tag Assistant window:
- Check that your click event appears
- Confirm your GA4 Event tag fires
- See that the correct parameters are passed
- Go to GA4 > Realtime Report to see if the event appears
Step 7: Publish the Container
- Click Submit → Publish
- Name the version: GA4 Click Tracking – Download Button
Note
- Use unique Click Text or IDs for accuracy
- For multiple buttons, consider a Lookup Table or a more dynamic setup
- If you’re tracking links, you can use a trigger type: Just Links instead of All Elements