APIs & Integrations

yudhi_hamzah
Member

Hubspot Livechat on Google Tag Manager

SOLVE

Hi,

I have been trying to track Hubspot Livechat on Google Tag Manager (GTM). More specifically people who are coming from Google Ads then click the Livechat.

Is there any way to do that? I asked Hubspot Support, but apparently there is no way to do that from Hubspot.

Thank you in advance.

3 Accepted solutions
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Hubspot Livechat on Google Tag Manager

SOLVE

Hi, @Pier.

 

Since this discussion was last active, we released a Conversations Live Chat Widget API. The features include these widget events, which you could use to trigger a Google Tag Manager event.

 

For example, the following script would listen for the start of a chat and trigger a GTM event named hs_chat_started.

 

 

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

 

 

Isaac Takushi

Associate Certification Manager

View solution in original post

stuartbrameld
Solution
Participant

Hubspot Livechat on Google Tag Manager

SOLVE

@gabrielxyzmkt got it working yesterday, here you go 🙂

 

<script type="text/javascript">
  function onConversationsAPIReady() {
    //console.log("HubSpot Conversations API Available");
    window.HubSpotConversations.on( 'conversationStarted', function( payload ) {
    //console.log("HubSpot Conversation Started");
      window.dataLayer.push({
        'event': 'hubspot-conversation-started',
        'hs-conversation-id': payload.conversation.conversationId
      })
    });
  }
  /*
   If external API methods are already available, use them.
  */
  if (window.HubSpotConversations) {
    onConversationsAPIReady();
  } else {
    /*
      Otherwise, callbacks can be added to the hsConversationsOnReady on the window object.
      These callbacks will be called once the external API has been initialized.
    */
    window.hsConversationsOnReady = [onConversationsAPIReady];
  }
 </script>

View solution in original post

Djones
Solution
Participant

Hubspot Livechat on Google Tag Manager

SOLVE

I wrote a step by step guide with screenshots on how I track Hubspot live chat with Google Tag Manager

View solution in original post

52 Replies 52
IsaacTakushi
HubSpot Employee
HubSpot Employee

Hubspot Livechat on Google Tag Manager

SOLVE

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.

Isaac Takushi

Associate Certification Manager
SamOrton
Participant

Hubspot Livechat on Google Tag Manager

SOLVE

Figured it out. Thanks Isaac.

 

Sam

gabrielxyzmkt
Participant

Hubspot Livechat on Google Tag Manager

SOLVE

Friend, tell me if I did it right:

1 - create the listener tag as you said in All Pages
2 - create a trigger - custom event "hubspot-conversation-started"
3 - create a google ads tracking tag triggered by the "hubspot-conversation-started" trigger

Just this?

0 Upvotes
stuartbrameld
Participant

Hubspot Livechat on Google Tag Manager

SOLVE

@gabrielxyzmkt yup that's pretty much it. this link explains how to do it for HubSpot forms, the approach is pretty much exactly the same for chat, should give you everything you need. note: the link will automatically expire in a couple of weeks https://app.growthmethod.com/playbook/fyea0zyy9twh9gccx1dr8c50sfj20j.

gabrielxyzmkt
Participant

Hubspot Livechat on Google Tag Manager

SOLVE

Your code is working fine. Thanks for sharing.

0 Upvotes
jteglgaaard
Member

Hubspot Livechat on Google Tag Manager

SOLVE

Can you share the complete code/script here? I'm interesting in counting the chat starts.

0 Upvotes
RiccardoPisani
Top Contributor

Hubspot Livechat on Google Tag Manager

SOLVE

thanks a lot @IsaacTakushi  🙂

0 Upvotes
Pier
Participant

Hubspot Livechat on Google Tag Manager

SOLVE

Hi @IsaacTakushi 

 

Thank you so much. I will try to track chat conversation.Unfortunately I'm not super competent with Google Tag Manager for custom tracking, a step by step guide would have been helpful.

 

I will try until I can! Fingers crossed.

 

Thank you again

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Hubspot Livechat on Google Tag Manager

SOLVE

Hi, @Pier.

 

Happy I could be of assistance.

 

There are many step-by-step tutorials on tracking in Google Tag Manager available. Here are two I found:

Isaac Takushi

Associate Certification Manager
0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Hubspot Livechat on Google Tag Manager

SOLVE

Hi @yudhi.hamzah,

While it's not possible to track clicks to open the live chat widget in HubSpot, there may be a way in Google Tag Manager.

Most of the live chat modal is loaded through an iframe, so its elements can't be tracked through GTM. The iframe exists within a div with the id hubspot-messages-iframe-container, however, so you may be able to create a click trigger with that id. See below.

Isaac Takushi

Associate Certification Manager
0 Upvotes
yudhi_hamzah
Member

Hubspot Livechat on Google Tag Manager

SOLVE

Hi @Isaac_Takushi it still don't work. There is "hubspot-messages-iframe-container" ID in my HTML but somehow the trigger is not fired.

I think the click is happening in the iframe. That is why I can't recognize the action (click).