Hubspot Livechat on Google Tag Manager

Thanks so much for sharing, @stuartbrameld! I was just about to take a look at your question from Monday.

Since authoring my original solution, I’ve found that it only fires if it loads after window.HubSpotConversations. This tends to be unpredictable so the if/else statement with window.hsConversationsOnReady is often a more reliable option. (This is also outlined in the API’s documentation.)

Hi Isaac,

From some the past posts you have made, you indicated using the javascript API method and custom event. This is for Enterprise clients only, is that correct? And if it is, is there any other work around?

Thanks,

Sam

Hi, @SamOrton.

Apologies for the delayed response.

Custom analytics events do require a Marketing Hub Enterprise subscription, however, depending on your goal, they may not be necessary.

Are you trying to trigger custom Google Tag Manager events on HubSpot pages? That use case does not require an Enterprise subscription.

Figured it out. Thanks Isaac.

Sam

Hey, where do we place this code in order for it to tack the Hubspot Live chat submissions? Is the tag type custom HTML in GTM? What’s the trigger?

Hi, @KB56.

There is no single correct way to use Google Tag Manager to process HubSpot conversation events. An optimal solution depends on your goals and your current setup.

First, can you specify the “code” to which you are referring (e.g. @stuartbrameld’s solution)?

It’s possible to implement custom JavaScript like this in a GTM “Custom HTML”-type tag. just as it’s possible to embed directly on your page.

If you’re planning to implement window.dataLayer.push() via a GTM “Custom HTML” tag, then an “All Pages” or “Page View” trigger might be your best bet.

If you’re embedding the script directly on your page and triggering implement window.dataLayer.push() from there, the trigger for subsequent tags in GTM will be your chosen event name (e.g. hubspot-conversation-started).

Hi,

This script is not wokring for me. Im using this wordpress plugin to intergrate the chat widget. HubSpot All-In-One Marketing – Forms, Popups, Live Chat – WordPress plugin | WordPress.org

I tried adding the script through the tag manager as well as through the theme. But none of them working.

Hi Tom, did you ever get this working? I have the same setup as you and am using the WordPress plugin.

Hi,
Are these solutions still working?
I have tried all the triggers and tags mentioned in this Topic, however, I’m still not being able to track the conversations started in the Chat. I might be using the wrong trigger or tag type or something (not advanced with GTM).

Would it be possible for anyone to add the step-by-step here of the trigger and tag I have to create in GTM for it to work? With the types I have to use, please, non-techie here :slightly_smiling_face:

thanks!

Hello @IsaacTakushi ,

Thank you but I don’t understand what should I do with this ?

window.HubSpotConversations.on('conversationStarted', payload => {
 dataLayer.push({'event': 'hs_chat_started'});
});

Use in Custom HTML ? If yes, with which trigger ?

Thanks

Hi, @LaetitiaS.

If you are asking about the snippet in general, yes, you can place that within <script></script> tags within your page’s HTML.

You may have to change the event name from hs_chat_started to match the Google Tag Manager event you have configured.

Could you clarify your question about the trigger? The HubSpot conversationStarted event is a trigger of sorts since it will trigger a callback, but are you referring to a different trigger? If so, what are you looking for the trigger to do?

Hi, @IsaacTakushi

What would the event script be if we wanted to track the email submission of a chat engagement in GTM?

Thanks,

Severin

Welcome, @Severin.

Are you referring to the automated chatflow prompt corresponding to the Ask visitors for their email address setting?

If so, responses to that prompt cannot be accessed via the Conversations JavaScript API at this time.

If you have an Enterprise-level subscription and are using bots, however, you can leverage either the bot webhook or code snippet actions to interact with this email.

Thanks for your help here, Isaac.

Just to clarify, the purpose of tracking this is for Google Analytics and Google Ads conversions. Therefore, I only want to see/track that the email address was successfully submitted via a chat form. I don’t need to see or record the actual email address for this purpose.

Does that help clarify?

Thanks again.

Severin

Hey, @Severin.

It does but unfortunately the answer is the same… at this time, HubSpot chat widgets do not emit an event or signal when an email address is submitted.

The closet alternatives I can think of are the two bot chatflow actions I outlined above.

Also, I know you’re not referring to HubSpot forms, but they have global events which trigger when submissions are received and persisted.

Can you please specify how this works in google tag manager?

In case you find it helpful, I created a Google Tag Manager (GTM) recipe to track the Hubspot Live Chat Conversation API events in Google Analytics 4 and Universal Analytics. Check it out.

@IsaacTakushi can you help me with this? My end goal is to count a Hubspot chat as a conversion in google ads and google analytics.

Same as @DDemagistris here, @IsaacTakushi . How can I track Hubspot chats that came from paid campaigns and organic search? I need to measure this.

I have the same question
If anybody can share step by step template on how the did it