> ## Documentation Index
> Fetch the complete documentation index at: https://watermelon.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Event listeners

> When using the Chat Widget with a tag management platform like Google Tag Manager, auto event listeners can capture events fired during chatbot interactions.

Whenever a visitor performs an action inside the widget, an event is triggered. These events are sent directly from the widget and can be listened to by any tool running on your website.

**Examples of actions that trigger events include:**

* Opening, loading and closing the widget.
* Sending, receiving messages for both the AI Agent, end user and Human Agent.
* Outbound Clicks.

No configuration is needed—the chatbot automatically sends events to the data layer.

## Available events

| Event name                           | Trigger                                                                                   | **Event Parameters**                                                              |
| ------------------------------------ | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| widget\_loaded                       | Fires when the widget has finished loading on the page.                                   | widget\_platform<br />widget\_id <br />timestamp                                  |
| widget\_opened                       | Fires when a user opens the widget.                                                       | widget\_platform<br />timestamp                                                   |
| widget\_closed                       | Fires when a user closes the widget.                                                      | widget\_platform<br />timestamp                                                   |
| widget\_whatsapp\_clicked            | Fires when a click on the sitelink containing the **WhatsApp** icon is being registered.  | widget\_platform<br />timestamp<br />link\_url<br />link\_type<br />link\_text    |
| widget\_facebook\_clicked            | Fires when a click on the sitelink containing the **Facebook** icon is being registered.  | widget\_platform<br />timestamp<br />link\_url<br />link\_type<br />link\_text    |
| widget\_instagram\_clicked           | Fires when a click on the sitelink containing the **Instagram** icon is being registered. | widget\_platform<br />timestamp<br />link\_url<br />link\_type<br />link\_text    |
| widget\_chat\_clicked                | Fires when a click on the sitelink containing the **chat** icon is being registered.      | widget\_platform<br />timestamp<br />link\_url<br />link\_type<br />link\_text    |
| widget\_email\_clicked               | Fires when a click on the sitelink containing the **email** icon is being registered.     | widget\_platform<br />timestamp<br />link\_url<br />link\_type<br />link\_text    |
| widget\_phone\_clicked               | Fires when a click on the sitelink containing the **phone** icon is being registered.     | widget\_platform<br />timestamp<br />link\_url<br />link\_type<br />link\_text    |
| widget\_custom\_link\_clicked        | Fires when a click on a sitelink containing a **custom link** icon is being registered.   | widget\_platform<br />timestamp<br />link\_url<br />link\_type<br />link\_text    |
| widget\_conversation\_started        | Website visitor sends first message                                                       | widget\_platform<br />timestamp                                                   |
| widget\_message\_sent                | Website visitor sends a message                                                           | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_agent\_message\_sent         | AI agent sends message                                                                    | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_handoff\_requested           | Website visitor requests human handover                                                   | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_user\_joined                 | Human agent joins conversation                                                            | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_user\_left                   | Human agent leaves conversation                                                           | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_handover\_agent              | Conversation is assigned back to the AI Agent                                             | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_user\_typing                 | Human agent typing                                                                        | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_message\_user\_sent          | Human agent sends message                                                                 | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_start\_conversation\_clicked | Conversation started                                                                      | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_conversation\_archived       | Conversation archived                                                                     | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_conversation\_deleted        | Conversation deleted                                                                      | widget\_platform<br />widet\_conversation\_id<br />timestamp<br />total\_messages |
| widget\_gdpr\_accepted               | Website visitor accepts GDPR                                                              | widget\_platform<br />timestamp                                                   |
| widget\_gdpr\_declined               | Website visitor  declines GDPR                                                            | widget\_platform<br />timestamp                                                   |
| widget\_feedback\_submitted          | Website visitor gives feedback to a message                                               | widget\_platform <br />widet\_conversation\_id<br />timestamp<br />agent\_name    |

## **Tracking Events in GA4 from the Widget with Google Tag Manager**

<Steps>
  <Step title="Install the widget">
    Install the website widget code [using this guide](/help-center/developer-resources/install-widget)
  </Step>

  <Step title="Go to Google Tag Manager">
    Log in to Google Tag Manager.
  </Step>

  <Step title="Check that events reach the dataLayer">
    The widget pushes events into the browser’s dataLayer.

    **To verify this:**

    1. Open your website with **GTM Preview Mode** enabled.

           <Frame>
             <img src="https://mintcdn.com/watermelon/hxwsQGC3m8DzrOS4/images/developer-resources/event-listeners/prevew-url-entry.png?fit=max&auto=format&n=hxwsQGC3m8DzrOS4&q=85&s=76d4a573ba7405e8ff61d062f577b05d" alt="Prevew Url Entry Pn" width="1270" height="916" data-path="images/developer-resources/event-listeners/prevew-url-entry.png" />
           </Frame>
    2. Interact with the widget (fire an event).
    3. In the left panel, you should see event names appear under the “Events” section.

    If you see them, you’re ready to track them.
  </Step>

  <Step title="Create a GTM Trigger for a Widget Event">
    You can set up triggers in two ways, depending on your tracking needs:

    **Option 1:** Individual Triggers (One trigger per Event).

    1. In GTM, go to **Triggers → New.**
    2. Choose **Custom Event.**
    3. Enter the event name, for example: **widget\_conversation\_started.**
    4. Set **This trigger fires on**: *All Custom Events*.
    5. Save.

    \*\*Option 2: \*\*RegEx Trigger (Catch multiple Events in one trigger).

    1. In GTM, go to **Triggers → New.**
    2. Choose **Custom Event.**
    3. Select **Use regex matching**.
    4. Enter a pattern to match multiple events:
       1. ^widget\_.\* catches all widget events;
       2. ^widget\_.\*\_clicked\$ catches all click events only;
       3. ^widget\_(opened|closed|loaded)\$ catches specific event groups.
    5. Set **This trigger fires on**: *All Custom Events*.
    6. Save.
  </Step>

  <Step title="Create a GA4 Event Tag">
    To send the captured widget event to Google Analytics:

    1. Go to **Tags** → **New**.
    2. Choose **Google Analytics: GA4 Event**.
    3. Select your **GA4 Configuration Tag**.
    4. Under **Event Name**, use the same event name from the widget, for example:

    ```
    chat_widget_whatsapp_clicked
    ```
  </Step>

  <Step title="Connect events">
    Attach the **Custom Event Trigger** you created earlier and click **save**.
  </Step>

  <Step title="Verify events">
    After publishing, test your events using DebugView:

    1. Go to GA4 → Admin (gear icon, bottom left) → Data Display → DebugView;
    2. Trigger widget events on your site, using PreviewMode in GTM;
    3. Events should appear as blue hits in real-time.

    <Frame>
      <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-debug-view.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=8e70176669fcea3c4e168551fdb8d12c" alt="Gtm Debug View Pn" width="974" height="630" data-path="images/developer-resources/event-listeners/gtm-debug-view.png" />
    </Frame>

    The page\_view is a normal hit, while the chat\_widget\_.\* events are Key Events
  </Step>
</Steps>

### **Create Key Events (optional)**

1. Go to **GA4** → **Admin** → **Data** **Display** → **Events**
2. Click **Create Key Event**

<Frame>
  <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-key-event-setup.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=1d55ca7186a3fe7d849b0e6f11ab2886" alt="Gtm Key Event Setup Pn" width="1124" height="824" data-path="images/developer-resources/event-listeners/gtm-key-event-setup.png" />
</Frame>

3. Add the widget event, with the exact event name, to convert it from a regular hit (blue ball) to a key event (green ball) in DebugView.

<Tip>
  Events will also appear under **Reports** → **Engagement** → **Events** **over** **time**.
</Tip>

## **Use events across multiple platforms**

The widget events aren't limited to GA4. The Custom Event triggers, made in point 5 can be used to fire all other conversion and event tags:

1. Google ads

<Frame>
  <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-ga.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=270acbf6af8084d150ce09708ac14ef0" alt="Gtm Fb Pn" width="1120" height="446" data-path="images/developer-resources/event-listeners/gtm-ga.png" />
</Frame>

2. Facebook ads

<Frame>
  <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-fb.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=a742f1b3ca9242ef557502e96065ad26" alt="Gtm Fb Pn" width="1120" height="690" data-path="images/developer-resources/event-listeners/gtm-fb.png" />
</Frame>

3. LinkedIn ads

<Frame>
  <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-li.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=09eebbff170fdbffcfe007cdc72e17da" alt="Gtm Ga4 Pn" width="1118" height="484" data-path="images/developer-resources/event-listeners/gtm-li.png" />
</Frame>

4. Any other tag-based platform

This allows you to track widget interactions as conversions across your entire marketing stack from a single implementation.

## **How to use the Event Parameters**

Each Widget Event has dedicated, built in Event Parameters, add them  to all you analytics platform tags, like GA4, Matomo or HubSpot.

<Frame>
  <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-event-paramaters.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=af7b8368b505d92698a0da0a6b8ae6db" alt="Gtm Event Paramaters Pn" width="1120" height="434" data-path="images/developer-resources/event-listeners/gtm-event-paramaters.png" />
</Frame>

<Note>
  *Conversion based tags (E.g. Google Ads, LinkedIn Ads, Microsoft UET Ads) do not benefit nor optimize using this information.*
</Note>

Before you can add them to your tags, you have to make the datalayer Variables:

* In GTM, go to **Variables → New.**
* Choose**Data Layer Variable** .
* Enter the datalayer variable name, for example: **widget\_id.**
  * Find these in the datalayer → same as event testing in GTM preview:

    <Frame>
      <img src="https://mintcdn.com/watermelon/griJoRRj8AAEKWeB/images/developer-resources/event-listeners/gtm-preview-ep.png?fit=max&auto=format&n=griJoRRj8AAEKWeB&q=85&s=e97de7aacddc440f84e719d5f05b9fac" alt="Gtm Preview Ep Pn" width="1224" height="824" data-path="images/developer-resources/event-listeners/gtm-preview-ep.png" />
    </Frame>
  * It should look like this:

    <Frame>
      <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-example-vc.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=be3017b3a0efd840f4a7a01e67afd3d5" alt="Gtm Example Vc Pn" width="1118" height="326" data-path="images/developer-resources/event-listeners/gtm-example-vc.png" />
    </Frame>
  * Save.
  * Make all the other variables you need to measure, for example:

    <Frame>
      <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-example-ep.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=934f87183569b49bb4e01bc584d11adc" alt="Gtm Example Ep Pn" width="970" height="300" data-path="images/developer-resources/event-listeners/gtm-example-ep.png" />
    </Frame>
  * Add the individual Datalayer Variables to your Analytics tag, for example GA4:

    <Frame>
      <img src="https://mintcdn.com/watermelon/nQQH0sjUKrJHcygR/images/developer-resources/event-listeners/gtm-analytics-tag.png?fit=max&auto=format&n=nQQH0sjUKrJHcygR&q=85&s=ae4496b5dd29c40d4ac10eedf7a2d2c8" alt="Gtm Analytics Tag Pn" width="1128" height="932" data-path="images/developer-resources/event-listeners/gtm-analytics-tag.png" />
    </Frame>
