Freshchat GTM Event Listener
Track Freshchat (Freshdesk Messaging) interactions in GTM. Monitor widget open/close, conversations, messages, and bot interactions with freshEvent_type variable.
freshchatfreshdeskfreshworkschatgtmga4supportsaas
Event fired
freshChat_EventKey variable
freshEvent_typeFreshchat
Overview
Freshchat (part of Freshworks) is a customer messaging platform with AI-powered chatbots, live chat, and team inbox. This listener hooks into Freshchat's JavaScript widget API to track interactions.
Event fired: freshChat_Event
Variable: freshEvent_type
Tracked Events
| freshEvent_type | Description |
|---|---|
widget opened | Chat widget opens |
widget closed | Widget closes |
conversation started | New chat initiated |
message sent | Visitor message |
message received | Agent/bot reply |
bot message received | Bot sends automated message |
conversation resolved | Chat marked resolved |
csat submitted | Customer satisfaction rating |
email captured | User provides email |
Installation
html
<!-- GTM Custom HTML Tag: Freshchat Listener -->
<script>
(function() {
function freshPush(type, extra) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(Object.assign({
'event': 'freshChat_Event',
'freshEvent_type': type
}, extra || {}));
}
var initFresh = function() {
if (typeof window.fcWidget === 'undefined') return;
fcWidget.on('widget:opened', function() { freshPush('widget opened'); });
fcWidget.on('widget:closed', function() { freshPush('widget closed'); });
fcWidget.on('conversation:started', function(data) {
freshPush('conversation started', {
conversationId: data && data.response && data.response.conversationId
});
});
fcWidget.on('message:sent', function(data) {
freshPush('message sent');
});
fcWidget.on('message:received', function(data) {
var isBotMsg = data && data.message && data.message.actorType === 'bot';
freshPush(isBotMsg ? 'bot message received' : 'message received');
});
fcWidget.on('conversation:end', function() { freshPush('conversation resolved'); });
fcWidget.on('csat:submitted', function(data) {
freshPush('csat submitted', { csatScore: data && data.score });
});
};
if (window.fcWidget) {
initFresh();
} else {
window.addEventListener('load', initFresh);
}
})();
</script>Data Layer Output
json
{
"event": "freshChat_Event",
"freshEvent_type": "conversation started",
"conversationId": "conv_12345"
}Trigger Configuration
Trigger Type: Custom Event
Event Name: freshChat_Event
Variables to Capture
| Variable Name | DL Key | Example |
|---|---|---|
| DLV – Freshchat Event Type | freshEvent_type | "conversation started" |
| DLV – Freshchat CSAT Score | csatScore | 5 |
GA4 Mapping
| GA4 Event | Condition | Parameters |
|---|---|---|
chat_widget_open | widget opened | chat_platform: "freshchat" |
chat_rating | csat submitted | rating_value |