# Track Button Clicks on Discourse with Google Tag Manager

**URL:** https://meta.discourse.org/t/track-button-clicks-on-discourse-with-google-tag-manager/395803
**Category:** Site Management
**Tags:** how-to
**Created:** [February 11, 2026, 2:27pm UTC](https://meta.discourse.org/t/track-button-clicks-on-discourse-with-google-tag-manager/395803 "2026-02-11T14:27:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [February 11, 2026, 2:27pm UTC](https://meta.discourse.org/t/track-button-clicks-on-discourse-with-google-tag-manager/395803/1 "2026-02-11T14:27:28Z")

</div>

> 🔖 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.

1. Navigate to **Variables** in your GTM workspace.
2. Select **Configure**.
3. Under the **Clicks** section, check all available boxes: `Click Element`, `Click Classes`, `Click ID`, `Click Target`, `Click URL`, and `Click Text`.

 ![Enable click variables](https://global.discourse-cdn.com/meta/original/4X/9/b/d/9bd8d81be478f41cee012dbf003e04b61a7f80e4.png)

## Create a generic click trigger

You need a “catch-all” trigger to see every click event in the debug console while you are testing.

1. Navigate to **Triggers** and select **New**.
2. Click **Trigger Configuration** and choose **Click - All Elements**.
3. Select **All Clicks**.
4. Name the trigger “All Clicks - Debug” and **Save**.

 ![Generic click trigger](https://global.discourse-cdn.com/meta/original/4X/e/5/6/e56d35c1938c1ada3e078afc3adafd997d2e4258.png)

## Use the Tag Assistant extension

The [Tag Assistant Companion](https://chromewebstore.google.com/detail/tag-assistant-companion/jhdnefejjfcdgdbgehpgaoijhugnband) extension helps you trace exactly which element GTM receives when you interact with your site.

1. Install the extension in your browser.
2. In your GTM workspace, select **Preview** in the top right corner.
3. Enter your site URL (`discourse.example.com`) and click **Connect**.

 ![Tag Assistant extension](https://global.discourse-cdn.com/meta/original/4X/f/7/b/f7bd71c62f1c7e3f8c81467d7a8122a14ea06bf2.png)

 ![Preview mode](https://global.discourse-cdn.com/meta/original/4X/1/1/0/110281506b7640a5540b4298184115bcab2d5e08.png)

## Identify specific button elements

Once the preview window is open, you can find the unique identifiers for your target button.

1. Click the button you wish to track (for example, the **Sign Up** button) on your site.
2. Switch back to the **Tag Assistant** tab.
3. Locate the latest **Click** event in the left-hand summary pane.
4. Select the **Data Layer** tab to see the properties of the clicked element.

 ![Locate click events](https://global.discourse-cdn.com/meta/original/4X/1/d/7/1d7dd847a4e3c9bd686bb30cbadc191a7d9cb891.png)

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](https://support.google.com/tagmanager/answer/13034206?hl=en)
- [Preview and debug containers - Tag Manager Help](https://support.google.com/tagmanager/answer/6107056)

> Last edited by @MarkDoerr 2026-02-11T17:08:42Z
> 
> > **Check document**
> >
> > Perform check on document:
