Skip to main content

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_Action

Key variable

chatAction

OnWeb 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

chatActionDescription
chat openedWidget opens
chat closedWidget closes
message sentVisitor sends message
message receivedOperator replies
offline message sentOffline contact form
pre-chat form submittedPre-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.OnWebChat object 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

Related Listeners