OnWeb Chat GTM Event Listener
Track OnWeb Chat interactions in GTM. Monitor widget open, close, messages, and offline events with chatAction variable.
onweb-chatchatgtmga4supportsmall-business
Event fired
onWebChat_ActionKey variable
chatActionOnWeb Chat
Overview
OnWeb Chat is a live chat tool for customer engagement. This listener tracks widget interactions including open, close, and messaging events.
Event fired: onWebChat_Action
Variable: chatAction
Tracked Events
| chatAction | Description |
|---|---|
chat opened | Widget opens |
chat closed | Widget closes |
message sent | Visitor sends message |
message received | Operator replies |
offline message sent | Offline contact form |
pre-chat form submitted | Pre-chat form |
Installation
html
<!-- GTM Custom HTML Tag: OnWeb Chat Listener -->
<script>
(function() {
function onwebPush(action, extra) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(Object.assign({
'event': 'onWebChat_Action',
'chatAction': action
}, extra || {}));
}
var initOnWeb = function() {
if (typeof window.OnWebChat === 'undefined') return;
OnWebChat.on('open', function() { onwebPush('chat opened'); });
OnWebChat.on('close', function() { onwebPush('chat closed'); });
OnWebChat.on('messageSent', function() { onwebPush('message sent'); });
OnWebChat.on('messageReceived', function() { onwebPush('message received'); });
OnWebChat.on('offlineMessage', function() { onwebPush('offline message sent'); });
OnWebChat.on('prechatSubmit', function() { onwebPush('pre-chat form submitted'); });
};
window.addEventListener('load', initOnWeb);
})();
</script>Note: OnWeb Chat API method names may vary by version. Inspect the
window.OnWebChatobject in DevTools to confirm event names.
Data Layer Output
json
{
"event": "onWebChat_Action",
"chatAction": "message sent"
}Trigger Configuration
Trigger Type: Custom Event
Event Name: onWebChat_Action