HubSpot Chat GTM Event Listener
Track HubSpot live chat and chatbot interactions in Google Tag Manager. Monitor conversation started, widget load, and visitor messages using HubSpot's hsConversationsOnReady API.
Event fired
conversationBeganHubSpot Chat
Overview
HubSpot Chat is the live chat and chatbot component of HubSpot's CRM platform. It uses the window.HubSpotConversations API with an hsConversationsOnReady callback. This listener hooks into that callback to track when a conversation begins.
Event fired: conversationBegan
Why Use This Listener
HubSpot chat conversations create CRM contacts automatically, but you also need to track these interactions in your analytics stack (GA4, Google Ads) for attribution and audience building. This listener bridges that gap.
Common Use Cases
- Track chat conversation starts as high-intent engagement events
- Build GA4 audiences of users who engaged with HubSpot chat
- Attribute sales-qualified leads from chat sessions
- Fire Google Ads remarketing tags on conversation start
- Correlate chat engagement with pipeline creation in CRM
How It Works
HubSpot exposes window.hsConversationsOnReady, an array of callbacks executed when the chat widget is ready. The listener pushes a callback that fires conversationBegan when a new conversation is detected.
Installation
<!-- GTM Custom HTML Tag: HubSpot Chat Listener -->
<script>
window.hsConversationsOnReady = window.hsConversationsOnReady || [];
window.hsConversationsOnReady.push(function() {
window.HubSpotConversations.on('conversationStarted', function(payload) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'conversationBegan',
'conversationId': payload.conversation.conversationId
});
});
window.HubSpotConversations.on('widgetLoaded', function() {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'hubspotChatLoaded'
});
});
window.HubSpotConversations.on('unreadCountChanged', function(payload) {
if (payload.unreadCount > 0) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'hubspotMessageReceived',
'unreadCount': payload.unreadCount
});
}
});
});
</script>Fire on: All Pages (Pageview). Must load before HubSpot's script initializes.
Data Layer Output
{
"event": "conversationBegan",
"conversationId": "conv_12345"
}Trigger Configuration
| Trigger | Event Name | Use For |
|---|---|---|
| CE – HS Chat Started | conversationBegan | GA4, Google Ads, Meta |
| CE – HS Chat Loaded | hubspotChatLoaded | Widget load timing |
GA4 Mapping
| GA4 Event | Parameter | Value |
|---|---|---|
chat_widget_open | chat_platform | "hubspot" |
chat_widget_open | conversation_id | DLV – Conversation ID |
Debugging
| Problem | Cause | Fix |
|---|---|---|
HubSpotConversations is undefined | HubSpot not loaded | Fire on Window Loaded |
| Callback not registering | Tag fires after HubSpot | Use hsConversationsOnReady array push |
Best Practices
- Always use
hsConversationsOnReadyarray pattern, never callHubSpotConversationsdirectly in case it hasn't loaded - Combine with HubSpot Form tracking for complete HubSpot funnel visibility