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_ActionKey variable
ChatActionChaport 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
| ChatAction | Description |
|---|---|
chat opened | Widget opens |
chat closed | Widget closes |
chat started | Conversation begins |
message sent | Visitor sends message |
message received | Operator replies |
operator online | Agent available |
operator offline | Agent 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