Skip to main content

Chaport Chat GTM Event Listener

Track Chaport live chat interactions in GTM. Monitor chat open/close, messages, and operator availability with ChatAction variable.

chaportchatgtmga4supportsmall-business

Event fired

chaport_Action

Key variable

ChatAction

Chaport Chat

Overview

Chaport is an all-in-one messaging platform with live chat and chatbot features. This listener hooks into Chaport's JavaScript API to track widget interactions.

Event fired: chaport_Action Variable: ChatAction

Tracked Events

ChatActionDescription
chat openedWidget opens
chat closedWidget closes
chat startedConversation begins
message sentVisitor sends message
message receivedOperator replies
operator onlineAgent available
operator offlineAgent unavailable

Installation

html
<!-- GTM Custom HTML Tag: Chaport Listener -->
<script>
(function() {
  function chaportPush(action, extra) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push(Object.assign({
      'event': 'chaport_Action',
      'ChatAction': action
    }, extra || {}));
  }

  var initChaport = function() {
    if (typeof window.chaport === 'undefined') return;
    chaport.on('open', function() { chaportPush('chat opened'); });
    chaport.on('close', function() { chaportPush('chat closed'); });
    chaport.on('chatStarted', function() { chaportPush('chat started'); });
    chaport.on('messageSent', function() { chaportPush('message sent'); });
    chaport.on('messageReceived', function() { chaportPush('message received'); });
    chaport.on('online', function() { chaportPush('operator online'); });
    chaport.on('offline', function() { chaportPush('operator offline'); });
  };

  window.addEventListener('load', initChaport);
})();
</script>

Data Layer Output

json
{
  "event": "chaport_Action",
  "ChatAction": "chat started"
}

Trigger Configuration

Trigger Type: Custom Event Event Name: chaport_Action

Related Listeners