SnapEngage GTM Event Listener
Track SnapEngage chat interactions in GTM. Monitor open, close, messages, lead capture, and case creation with SnapEngage_eventAction variable.
snapengagechatgtmga4healthcareenterprisesupport
Event fired
snapEngageEventKey variable
SnapEngage_eventActionSnapEngage
Overview
SnapEngage is an enterprise-grade live chat platform with HIPAA-compliant options, popular in healthcare and regulated industries. This listener hooks into SnapEngage's JavaScript callback system to track interactions.
Event fired: snapEngageEvent
Variable: SnapEngage_eventAction
Tracked Events
| SnapEngage_eventAction | Description |
|---|---|
chat opened | Visitor opens chat |
chat closed | Widget closed |
chat started | Conversation begins |
message sent | Visitor sends message |
operator message | Agent sends message |
lead captured | Lead form submitted |
case created | Support case opened |
chat offline | Offline contact submitted |
proactive chat shown | Proactive invitation shown |
proactive chat accepted | Proactive invitation accepted |
proactive chat declined | Proactive invitation declined |
Installation
html
<!-- GTM Custom HTML Tag: SnapEngage Listener -->
<script>
(function() {
function snapPush(action, extra) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(Object.assign({
'event': 'snapEngageEvent',
'SnapEngage_eventAction': action
}, extra || {}));
}
var initSnap = function() {
if (typeof window.SnapEngage === 'undefined') return;
SnapEngage.setCallback('Open', function() { snapPush('chat opened'); });
SnapEngage.setCallback('Close', function() { snapPush('chat closed'); });
SnapEngage.setCallback('StartChat', function(email, msg, type) {
snapPush('chat started', {
chatVisitorEmail: email,
chatVisitorType: type
});
});
SnapEngage.setCallback('MessageSubmit', function(email, msg) {
snapPush('message sent', { chatVisitorEmail: email });
});
SnapEngage.setCallback('ChatMessageReceived', function(agent, msg) {
snapPush('operator message', { chatAgentName: agent });
});
SnapEngage.setCallback('Lead', function(email, msg) {
snapPush('lead captured', { chatVisitorEmail: email });
});
SnapEngage.setCallback('ChatEnded', function() { snapPush('chat closed'); });
SnapEngage.setCallback('ProactiveClose', function() { snapPush('proactive chat declined'); });
};
window.addEventListener('load', initSnap);
})();
</script>Data Layer Output
json
{
"event": "snapEngageEvent",
"SnapEngage_eventAction": "lead captured",
"chatVisitorEmail": "lead@example.com"
}Trigger Configuration
Trigger Type: Custom Event
Event Name: snapEngageEvent
Variables to Capture
| Variable Name | DL Key | Example |
|---|---|---|
| DLV – SnapEngage Action | SnapEngage_eventAction | "chat started" |
| DLV – SnapEngage Email | chatVisitorEmail | "user@example.com" |
GA4 Mapping
| GA4 Event | Condition | Parameters |
|---|---|---|
chat_widget_open | chat opened | chat_platform: "snapengage" |
generate_lead | lead captured |
HIPAA Note
SnapEngage can be configured for HIPAA compliance. If you handle PHI (Protected Health Information), do not push message content to the dataLayer, as this could expose PHI to your analytics tools.