This guide explains how to use Google Tag Manager (GTM) to track specific button clicks on your Discourse site, such as “Sign Up”, “Log In”, or “Reply”.
Required user level: Administrator with Google Tag Manager access
Track button clicks with Google Tag Manager
Tracking how users interact with specific buttons provides valuable data for understanding user behavior and conversion paths. While Discourse tracks many events out of the box, you may want to monitor specific UI elements like the “Sign Up” button. Using Google Tag Manager (GTM) preview mode is the most efficient way to identify the correct elements and set up accurate triggers.
Summary
To track a specific button, you must first identify how GTM “sees” that button when it is clicked. The process involves enabling click variables, creating a generic debug trigger, using the Tag Assistant to identify the element’s unique properties, and then creating a specific tag for that button.
Enable click variables
Before you can track clicks, you must ensure GTM is capturing the necessary data from the browser.
- Navigate to Variables in your GTM workspace.
- Select Configure.
- Under the Clicks section, check all available boxes:
Click Element,Click Classes,Click ID,Click Target,Click URL, andClick Text.
Create a generic click trigger
You need a “catch-all” trigger to see every click event in the debug console while you are testing.
- Navigate to Triggers and select New.
- Click Trigger Configuration and choose Click - All Elements.
- Select All Clicks.
- Name the trigger “All Clicks - Debug” and Save.
Use the Tag Assistant extension
The Tag Assistant Companion extension helps you trace exactly which element GTM receives when you interact with your site.
- Install the extension in your browser.
- In your GTM workspace, select Preview in the top right corner.
- Enter your site URL (
discourse.example.com) and click Connect.
Identify specific button elements
Once the preview window is open, you can find the unique identifiers for your target button.
- Click the button you wish to track (for example, the Sign Up button) on your site.
- Switch back to the Tag Assistant tab.
- Locate the latest Click event in the left-hand summary pane.
- Select the Data Layer tab to see the properties of the clicked element.
To target the Sign Up button specifically, you can use its unique class: sign-up-button.
When creating your permanent trigger, use a CSS Selector to ensure it captures clicks even if the user clicks the text inside the button. For the Sign Up button, use:
button.sign-up-button, button.sign-up-button *
The
*(wildcard) at the end of the selector ensures that if a user clicks the text span inside the button, the trigger still fires.
Best practices
- Use descriptive names: Name your triggers and tags clearly, such as “GA4 - Event - Sign Up Button Click”.
- Test anonymously: When testing clicks for buttons like “Sign Up”, it is often best to use an incognito window or log out of your Discourse site to ensure the button is visible.
- Validate before publishing: Always check the Summary pane in Tag Assistant to confirm your specific tag fires only when the intended button is clicked.
Additional resources
- Set up Google Analytics events in Tag Manager - Tag Manager Help
- Preview and debug containers - Tag Manager Help
Last edited by @MarkDoerr 2026-02-11T17:08:42Z
Check document
Perform check on document:




