ChatStack GTM Event Listener
Track ChatStack live chat interactions in GTM. Monitor chat open, messages, and offline events with chatStack_Action variable.
chatstackchatgtmga4support
Event fired
chatStackEventKey variable
chatStack_ActionChatStack
Overview
ChatStack is a live chat software solution. This listener hooks into ChatStack's JavaScript API to track widget interactions.
Event fired: chatStackEvent
Variable: chatStack_Action
Tracked Events
| chatStack_Action | Description |
|---|---|
chat opened | Widget opens |
chat closed | Widget closes |
message sent | Visitor message |
message received | Operator reply |
operator online | Agent available |
operator offline | Agent unavailable |
offline message | Offline form submitted |
Installation
html
<!-- GTM Custom HTML Tag: ChatStack Listener -->
<script>
(function() {
function csPush(action, extra) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(Object.assign({
'event': 'chatStackEvent',
'chatStack_Action': action
}, extra || {}));
}
var initCS = function() {
if (typeof window.ChatStack === 'undefined') return;
ChatStack.on('open', function() { csPush('chat opened'); });
ChatStack.on('close', function() { csPush('chat closed'); });
ChatStack.on('messageSent', function() { csPush('message sent'); });
ChatStack.on('messageReceived', function() { csPush('message received'); });
ChatStack.on('operatorOnline', function() { csPush('operator online'); });
ChatStack.on('operatorOffline', function() { csPush('operator offline'); });
ChatStack.on('offlineMessage', function() { csPush('offline message'); });
};
window.addEventListener('load', initCS);
})();
</script>Note: ChatStack's API method names may vary. Consult ChatStack documentation for your version.
Data Layer Output
json
{
"event": "chatStackEvent",
"chatStack_Action": "message sent"
}Trigger Configuration
Trigger Type: Custom Event
Event Name: chatStackEvent