Zopim Chat (Zendesk Chat) GTM Event Listener
Track Zopim / Zendesk Chat interactions in Google Tag Manager. Monitor chat start, messages, and end events with zopimChatAction variable.
zopimzendesk-chatchatgtmga4supportecommerce
Event fired
zopimChatKey variable
zopimChatActionZopim Chat (Zendesk Chat)
Overview
Zopim was acquired by Zendesk and rebranded as Zendesk Chat. This listener hooks into the $zopim JavaScript API to track chat widget interactions and push them to the GTM dataLayer.
Event fired: zopimChat
Variable: zopimChatAction
Common Use Cases
- Track chat engagement on eCommerce and support sites
- Fire GA4 events on chat start and message exchanges
- Build audiences of users who engaged with Zendesk Chat
- Measure support chat impact on conversion rates
Tracked Events
| zopimChatAction Value | Description |
|---|---|
chat initiated | Visitor opens chat |
chat started | Conversation begins |
message sent | Visitor sends message |
message received | Agent replies |
chat ended | Session closes |
chat rated | Visitor submits rating |
Installation
html
<!-- GTM Custom HTML Tag: Zopim Chat Listener -->
<script>
(function() {
function zopimPush(action, extra) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(Object.assign({
'event': 'zopimChat',
'zopimChatAction': action
}, extra || {}));
}
var initZopim = function() {
if (typeof window.$zopim === 'undefined') return;
window.$zopim(function() {
window.$zopim.livechat.setOnChatStart(function() { zopimPush('chat started'); });
window.$zopim.livechat.setOnChatEnd(function() { zopimPush('chat ended'); });
window.$zopim.livechat.setOnStatus(function(status) {
zopimPush('agent status changed', { agentStatus: status });
});
window.$zopim.livechat.window.setOnShow(function() { zopimPush('chat initiated'); });
window.$zopim.livechat.setOnUnreadMsgs(function(count) {
if (count > 0) zopimPush('message received', { unreadCount: count });
});
});
};
if (window.$zopim) {
initZopim();
} else {
window.addEventListener('load', initZopim);
}
})();
</script>Fire on: Window Loaded.
Data Layer Output
json
{
"event": "zopimChat",
"zopimChatAction": "chat started"
}Trigger Configuration
Trigger Type: Custom Event
Event Name: zopimChat
Variables to Capture
| Variable Name | DL Key | Example |
|---|---|---|
| DLV – Zopim Action | zopimChatAction | "chat started" |
GA4 Mapping
| GA4 Event | Trigger Condition | Parameters |
|---|---|---|
chat_widget_open | zopimChatAction = chat initiated | chat_platform: "zendesk_chat" |
Note on Zendesk Chat API
Zendesk also provides a newer zE API. For newer implementations, use:
javascript
zE('messenger:on', 'open', function() {
dataLayer.push({ event: 'zopimChat', zopimChatAction: 'chat initiated' });
});