Skip to main content

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.

hubspotchatcrmgtmga4supportsalesconversational-marketing

Event fired

conversationBegan

HubSpot 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

html
<!-- 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

json
{
  "event": "conversationBegan",
  "conversationId": "conv_12345"
}

Trigger Configuration

TriggerEvent NameUse For
CE – HS Chat StartedconversationBeganGA4, Google Ads, Meta
CE – HS Chat LoadedhubspotChatLoadedWidget load timing

GA4 Mapping

GA4 EventParameterValue
chat_widget_openchat_platform"hubspot"
chat_widget_openconversation_idDLV – Conversation ID

Debugging

ProblemCauseFix
HubSpotConversations is undefinedHubSpot not loadedFire on Window Loaded
Callback not registeringTag fires after HubSpotUse hsConversationsOnReady array push

Best Practices

  1. Always use hsConversationsOnReady array pattern, never call HubSpotConversations directly in case it hasn't loaded
  2. Combine with HubSpot Form tracking for complete HubSpot funnel visibility

Related Listeners