Chatlio GTM Event Listener
Track Chatlio Slack-integrated chat widget interactions in GTM. Monitor open, close, messages, and offline events with chatlio_action variable.
chatlioslackchatgtmga4supportdeveloper-tools
Event fired
chatlio_eventKey variable
chatlio_actionChatlio
Overview
Chatlio integrates with Slack, routing chat conversations directly to Slack channels. This listener hooks into Chatlio's JavaScript API to track widget interactions and conversation events.
Event fired: chatlio_event
Variable: chatlio_action
Tracked Events
| chatlio_action | Description |
|---|---|
widget opened | Chat expands |
widget closed | Chat collapses |
conversation started | First message sent |
message sent | Visitor sends message |
message received | Slack agent replies |
offline form submitted | Offline contact form |
feedback submitted | Post-chat feedback |
Installation
html
<!-- GTM Custom HTML Tag: Chatlio Listener -->
<script>
(function() {
function chatlioPush(action, extra) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(Object.assign({
'event': 'chatlio_event',
'chatlio_action': action
}, extra || {}));
}
document.addEventListener('chatlio.ready', function() {
document.addEventListener('chatlio.expanded', function() { chatlioPush('widget opened'); });
document.addEventListener('chatlio.collapsed', function() { chatlioPush('widget closed'); });
document.addEventListener('chatlio.conversationStarted', function() {
chatlioPush('conversation started');
});
document.addEventListener('chatlio.messageSent', function(e) {
chatlioPush('message sent', { messageContent: e.detail && e.detail.text });
});
document.addEventListener('chatlio.messageReceived', function(e) {
chatlioPush('message received');
});
document.addEventListener('chatlio.offlineMessageSent', function() {
chatlioPush('offline form submitted');
});
});
})();
</script>Data Layer Output
json
{
"event": "chatlio_event",
"chatlio_action": "conversation started"
}Trigger Configuration
Trigger Type: Custom Event
Event Name: chatlio_event
GA4 Mapping
| GA4 Event | Condition | Parameters |
|---|---|---|
chat_widget_open | chatlio_action = widget opened | chat_platform: "chatlio" |