# Google Tag Manager Whatsapp Widget Tracking

**URL:** <https://community.elfsight.com/t/google-tag-manager-whatsapp-widget-tracking/130845>\
**Category:** General Questions\
**Tags:** whatsapp-chat\
**Created:** [July 11, 2025, 2:55pm UTC](https://community.elfsight.com/t/google-tag-manager-whatsapp-widget-tracking/130845 "2025-07-11T14:55:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akram\_Kefli](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@Akram\_Kefli](https://community.elfsight.com/u/Akram_Kefli)\
**Post date:** [July 11, 2025, 2:55pm UTC](https://community.elfsight.com/t/google-tag-manager-whatsapp-widget-tracking/130845/1 "2025-07-11T14:55:01Z")

</div>

- **Issue description:**

I have the following issue with Elfsight’s Whatsapp Widget:  
I’d like to track clicks on ‘Auf Whatsapp Chatten’ with Google Tag Manager. I am not using Google Analytics.  
So far multiple attempts have ended in failure.

What I’ve done:

I have a custom Trigger with elfsight-form-submit

Added JS Code to the widget itself:

```auto
function sendAnalyticsEvent(config) {
    if (typeof ga !== "undefined") {
        ga('send', 'event', {
            eventAction: config.action,
            eventCategory: config.category,
            eventLabel: config.label
        });
    }

    if (typeof gtag !== "undefined") {
        gtag('event', config.action, {
            'event_category': config.category,
            'event_label': config.label
        });
    }
}

document.addEventListener('click', function (event) {
    const matchingItems = [
        {
            selector: '[class*="Bubble__BubbleComponent"]',
            label: 'Open/Close Chat Widget'
        },
        {
            selector: '[class*="ChatButton__DefaultButtonComponent-sc"]',
            label: 'Click Start Chat Button'
        },
    ];

    matchingItems.forEach((item) => {
        const match = event.target.closest(item.selector);

        if (match) {
            sendAnalyticsEvent({
                action: 'click',
                category: 'Elfsight Chat Widget',
                label: item.label
            });
        }
    });
});

```

When using the GTag Assistant, I do not see anything pushed, event or data-layer wise.

- **Link to the page with the widget in question:**  
[https://www.mt-express.de/](https://www.mt-express.de/)

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [July 11, 2025, 3:01pm UTC](https://community.elfsight.com/t/google-tag-manager-whatsapp-widget-tracking/130845/3 "2025-07-11T15:01:58Z")

</div>

Hi there, @Akram_Kefli and welcome to the Community 👋

Here is a slightly adjusted JS code:

```auto
function sendAnalyticsEvent(config) {
  if (typeof ga !== 'undefined') {
    ga('send', 'event', {
      eventAction: config.action,
      eventCategory: config.category,
      eventLabel: config.label
    });
  }

  if (typeof gtag !== 'undefined') {
    gtag('event', config.action, {
      event_category: config.category,
      event_label: config.label
    });
  }
}

document.addEventListener(
  'click',
  function (event) {
    const matchingItems = [
      {
        selector: '[class*="Bubble__BubbleComponent-sc"]',
        label: 'Open/Close Chat Widget'
      },
      {
        selector: '[class*="ChatButton__DefaultButtonComponent-sc"]',
        label: 'Click Start Chat Button'
      }
    ];

    matchingItems.forEach((item) => {
      const match = event.target.closest(item.selector);

      if (match) {
        sendAnalyticsEvent({
          action: 'click',
          category: 'Elfsight Chat Widget',
          label: item.label
        });
      }
    });
  },
  { capture: true }
);

```

  

Please try it out and let me know if it worked 😉

---

<div class="post-metadata">

**Author:** ![No\_Faff\_Marketing](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@No\_Faff\_Marketing](https://community.elfsight.com/u/No_Faff_Marketing)\
**Post date:** [January 14, 2026, 5:06pm UTC](https://community.elfsight.com/t/google-tag-manager-whatsapp-widget-tracking/130845/4 "2026-01-14T17:06:13Z")

</div>

Can someone please share the most up to date step by step guide on how to track WhatsApp Chat opens or clicks in GTM/GA4?

---

<div class="post-metadata">

**Author:** ![Max](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/max/32/710_2.png) [@Max](https://community.elfsight.com/u/Max)\
**Post date:** [January 14, 2026, 5:12pm UTC](https://community.elfsight.com/t/google-tag-manager-whatsapp-widget-tracking/130845/5 "2026-01-14T17:12:28Z")

</div>

Hi there, @No_Faff_Marketing 👋

The Google Analytics integration is currently built in the widget’s settings, so you don’t have to use any custom scripts now.

Check this post for more details - [Chats: Track user interactions with your widget using Google Analytics integration](https://community.elfsight.com/t/chats-track-user-interactions-with-your-widget-using-google-analytics-integration/140829).

If any questions arise, we’re always here to help 😉
