Support
Integrations
Tracking Weply Chat Widget Events with Google Tag Manager

Tracking Weply Chat Widget Events with Google Tag Manager

Updated:
October 15, 2025

This guide will show you how to track chat widget interactions (like when visitors open the chat, start a conversation, or minimize the widget) using Google Tag Manager and send that data to Google Analytics 4.

Important: This method tracks visitor engagement with your chat widget. For tracking actual lead conversions and completed chats, you'll need to use our GA4 integration instead.

Step 1: Add the Weply Widget API Listener to Your Website

First, you need to add a small piece of code to your website that "listens" for the Weply widget to load and prepares to capture events.

Where to Add This Code

Add this code snippet to your website. You can place it in:

  • Your website's header or footer template
  • A custom HTML section in your website builder
  • Custom HTML Tag in Google Tag Manager

The Code to Add

<script type="text/javascript">
 window.weplyWidgetReady = function (api) {
 // Create a dataLayer if it doesn't exist
 window.dataLayer = window.dataLayer || [];

 // List of events we want to track
 var eventsToTrack = [
 'widgetOpen',
 'widgetMinimize',
 'widgetMaximize',
 'chatStarted',
 'chatClosed',
 'proactiveChatBubble',
 'proactiveChatBubbleClosed'
 ];

 // Set up a listener for each event
 eventsToTrack.forEach(function(eventName) {
 api.dataLayers.on(eventName, function(data) {
 // Push the event to Google Tag Manager's dataLayer
 window.dataLayer.push({
 'event': 'weply_' + eventName,
 'weply_sessionId': data.sessionId,
 'weply_browserTabId': data.browserTabId,
 'weply_timestamp': data.time,
 'weply_eventName': data.event
 });
 });
 });
 };
</script>

What this code does

  • Waits for the Weply widget to load on your page
  • Listens for chat widget events (like when someone opens the chat)
  • Sends those events to Google Tag Manager so you can track them

Step 2: Add the Code Using Google Tag Manager

Instead of adding the code directly to your website, you can add it through Google Tag Manager.

Instructions:

2.1. Log in to Google Tag Manager

2.2. Click Tags in the left sidebar

Click on Tags

2.3. Click New to create a new tag

Click on New

2.4. Name your tag: Weply Widget API Listener

Type$ {label}


2.5. Click the Tag Configuration box

Click on Section edit button, click to enable edit mode for this section


2.6. Select Custom HTML

Click on Custom HTML…


2.7. Paste the code from Step 1 into the HTML box

Paste selected text into text area


2.8. Click the Triggering box

Click on Section edit button, click to enable edit mode for this section

2.9. Select All Pages (this ensures the code loads on every page)

Click on All Pages…


2.10. Click Save

Click on Save


You can choose to Publish your changes now, or continue to the next step.

Step 3: Create Custom Event Triggers in Google Tag Manager

Now you need to tell Google Tag Manager to watch for these Weply events.

For each event you want to track:

3.1. Go to Triggers in the left sidebar

Click on Triggers

3.2 Click New

Click on New

3.3 Name your trigger (example: "Weply - Widget Opened")

Type$ {label}


3.4 Click the Trigger Configuration box

Click on Section edit button, click to enable edit mode for this section


3.5 Select Custom Event

Click on Custom Event

3.6 In the Event name field, enter the event name:

  1. weply_widgetOpen
  2. weply_widgetMinimize
  3. weply_widgetMaximize
  4. weply_chatStarted
  5. weply_chatClosed
  6. weply_proactiveChatBubble
  7. weply_proactiveChatBubbleClosed
  8. Click Save

Repeat this process for each event you want to track.

Type "weply_widgetOpen"

Quick Reference: Available Events

Event Name When It Fires Recommended to Track?
weply_widgetOpen When visitor opens the chat widget ✅ Yes
weply_chatStarted When visitor sends their first message ✅ Yes
weply_widgetMinimize When visitor minimizes the widget Optional
weply_widgetMaximize When visitor maximizes the widget Optional
weply_chatClosed When the chat conversation ends Optional
weply_proactiveChatBubble When automatic chat prompt appears Optional
weply_proactiveChatBubbleClosed When visitor closes the automatic prompt Optional

Step 4: Send Events to Google Analytics 4

Now that Google Tag Manager is listening for these events, let's send them to GA4 so they can be tracked.

Create a GA4 Event Tag:

4.1. Go to Tags in Google Tag Manager

4.2. Click New

4.3. Name your tag: GA4 - Weply Widget Opened (adjust name for each event)

4.4. Click Tag Configuration

4.5. Select Google Analytics: GA4 Event6. Configuration Tag: Select your existing GA4 Configuration tag (or create one if you haven't)

4.7. Event Name: Enter a descriptive name like chat_widget_opened or chat_started

4.8. Optional - Add Event Parameters (this gives you more data in GA4):

  • Click Add Row under Event Parameters
  • Parameter Name: session_id
  • Value: {{weply_sessionId}} (you'll create this variable next)
  • Add more parameters as needed

4.9. Click Triggering

4.10. Select the trigger you created in Step 3 (example: "Weply - Widget Opened")

4.11. Click Save

Repeat this process for each event you want to send to GA4.

Step 5: Create Data Layer Variables (Optional but Recommended)

To capture the additional data that comes with each event (like session ID), create variables in GTM.Create Variables:

5.1. Go to "Variables" in the left sidebar

5.2. Under "User-Defined Variables", click "New"

5.3 Name your variable: weply_sessionId

5.4. Click Variable Configuration

5.5. Select "Data Layer Variable"

5.6. Data Layer Variable Name: weply_sessionId

5.7. Click "Save"

Repeat for these additional variables:

  • weply_browserTabId
  • weply_timestamp
  • weply_eventName

Now you can use these variables in your GA4 event tags

Step 6: Test Your Setup

Before publishing, test that everything works:

6.1. Click Preview in Google Tag Manager (top right)

6.2. Enter your website URL and click Connect

6.3. Your website will open with a GTM debug panel

6.4. Interact with the chat widget (open it, start a chat, minimize it)

6.5. Check the debug panel to see if your tags fire correctly

6.6. Look for your custom events in the left column (they'll appear as you trigger them)If everything looks good, click Submit to publish your changes.

Step 7: Verify Events in Google Analytics 4

After publishing, check that events are appearing in GA4:

7.1. Go to your GA4 property

7.2. Navigate to Reports → Realtime

7.3. Interact with your chat widget on your website

7.4. Watch the Realtime report to see your events appear (like chat_widget_opened or chat_started)It may take a few minutes for events to appear.