Crisp Chat GTM Event Listener
Track 7 Crisp chat interactions in Google Tag Manager including chat initiated, messages sent/received, email capture, helpdesk queries. Capture CrispSessionID and CrispEmail.
crispchatgtmga4supportlead-generation
Event fired
CrispInteractionsCrisp Chat
Overview
Crisp is a multi-channel customer messaging platform. This listener hooks into Crisp's JavaScript API to capture 7 distinct user interactions, from widget open/close to email capture and helpdesk queries.
Event fired: CrispInteractions
Variables:
chatAction, the specific interaction typeCrispSessionID, unique session identifierCrispEmail, user-submitted emailCrispPhone, user phone number
Common Use Cases
- Track chat engagement rates (opens vs. messages sent)
- Capture email addresses from Crisp for Enhanced Conversions
- Build audiences of users who contacted support
- Measure helpdesk query volume in GA4
- Correlate chat usage with conversion metrics
Tracked Events
| chatAction Value | Trigger |
|---|---|
chat initiated | User clicks chat widget |
chat widget opened | Widget expands |
chat widget closed | Widget collapses |
message sent | User sends a message |
message received | Agent replies |
email captured | User submits email |
helpdesk query | User searches knowledge base |
Installation
html
<!-- GTM Custom HTML Tag: Crisp Chat Listener -->
<script>
(function() {
function crispPush(action, extra) {
window.dataLayer = window.dataLayer || [];
var push = {
'event': 'CrispInteractions',
'chatAction': action,
'CrispSessionID': window.$crisp ? $crisp.get('session:identifier') : '',
'CrispEmail': window.$crisp ? ($crisp.get('user:email') || '') : '',
'CrispPhone': window.$crisp ? ($crisp.get('user:phone') || '') : ''
};
if (extra) Object.assign(push, extra);
window.dataLayer.push(push);
}
window.CRISP_READY_TRIGGER = function() {
window.$crisp.push(['on', 'chat:initiated', function() { crispPush('chat initiated'); }]);
window.$crisp.push(['on', 'chat:opened', function() { crispPush('chat widget opened'); }]);
window.$crisp.push(['on', 'chat:closed', function() { crispPush('chat widget closed'); }]);
window.$crisp.push(['on', 'message:sent', function() { crispPush('message sent'); }]);
window.$crisp.push(['on', 'message:received', function() { crispPush('message received'); }]);
window.$crisp.push(['on', 'user:email:changed', function() { crispPush('email captured'); }]);
window.$crisp.push(['on', 'helpdesk:queried', function() { crispPush('helpdesk query'); }]);
};
})();
</script>Fire on: All Pages (DOM Ready).
Data Layer Output
json
{
"event": "CrispInteractions",
"chatAction": "email captured",
"CrispSessionID": "session_abc123",
"CrispEmail": "user@example.com",
"CrispPhone": "+1234567890"
}Trigger Configuration
All Crisp Events
Trigger Type: Custom Event
Event Name: CrispInteractions
Conversion-Only (Message Sent)
Trigger Type: Custom Event
Event Name: CrispInteractions
Condition: DLV – Chat Action | equals | message sent
Variables to Capture
| Variable Name | DL Key | Example |
|---|---|---|
| DLV – Crisp Action | chatAction | "message sent" |
| DLV – Crisp Session ID | CrispSessionID | "session_abc123" |
| DLV – Crisp Email | CrispEmail | "user@example.com" |
GA4 Mapping
| GA4 Event | Trigger Condition | Parameters |
|---|---|---|
chat_widget_open | chatAction = chat widget opened | chat_platform: "crisp" |
generate_lead | chatAction = email captured | chat_platform, email |
Debugging
| Problem | Cause | Fix |
|---|---|---|
$crisp is not defined | Crisp not loaded | Use Window Loaded trigger |
CRISP_READY_TRIGGER not called | Crisp init after listener | Add fallback check on window.load |