Hubspot Chat Tool: Recording Conversions in Analytics/Adwords

SOLVE
Occasional Contributor

Does anyone have any solutions/suggestions for recording live chat conversions in Analytics/Adwords? Can I record contacts created from live chat in Analytics and then create a goal that could translate to a conversion in Adwords? 

We are using the Hubspot chat tool.

We would like to use chat on our ppc landing pages, but because we cannot record chats and conversions, we have not yet set them up.

1 Accepted solution

Accepted Solutions
Esteemed Contributor | Diamond Partner

UPDATE:

 

Actually, digging into this further, tracking when the "conversation is started" is possible. 

 

 

<script>
window.addEventListener( 'message', function(event) {
  if ( event.origin !== 'https://app.hubspot.com' )
    return false;
  
  var eventData = JSON.parse(event.data);
  var eventAction = false;
  
  switch( eventData.type ) {
    case 'closed-welcome-message':
      eventAction = 'Closed - Welcome Message';
    break;
    case 'open-change':
      eventAction = ( eventData.data ) ? 'Opened - Window' : 'Closed - Window';
    break;
    case 'external-api-event':
      if ( eventData.data.eventType = 'conversationStarted' )
      	eventAction = 'Conversation Started';
    break;
    default:
      eventAction = false;
    break;
  }
  
  if ( eventAction ) {
    dataLayer.push({
      'event': 'Send Event',
      'event_category': 'Live Chat',
      'event_action': eventAction,
      'event_label': eventData.uuid,
      'event_value': 10
    });
  }
  
});
</script>

 

 

However, there isn't a way to track when a user provides their email address - which is really when you would truely count a conversation as a "lead" for analytical purposes. So this above script would track the following (assuming you use Google Tag Manager):

 

  • Users who open/close the chat window
  • Users who close the chat welcome message (if you're using one)
  • Users who start a new conversation
14 Replies 14
Advisor

Hi @ErinGerg,

 

Which chat app are you using?  HubSpot or another tool?  We use Comm100 for Chat and they have an off-the-shelf stock integration for Google Analytics.  

 

- Trevor

-Trevor

If my post resolves your issue, please accept my post as a solution.
Reply
0 Upvotes
Occasional Contributor

Hi Trevor,

 

Sorry if I was not clear. We are using the Hubspot chat tool, and it does not have an integration. I do not believe that we are currently open to changing tools as we are working on a lead tracking process for the client.

 

Thanks!

 

Erin

Reply
0 Upvotes
Advisor

Hi @ErinGerg,

 

You should be able to use event tracking in Google Analytics along with jQuery to do this.  More on that in this thread:

 

https://community.hubspot.com/t5/Marketing-Integrations/Google-Analytics-Event-Tracking/td-p/29831

 

-Trevor

-Trevor

If my post resolves your issue, please accept my post as a solution.
Reply
0 Upvotes
Occasional Contributor

Hi Trevor,

 

We cannot apply event tracking to the chat code because we do not have access to Hubspot chat's code. We just turn it on on the landing page.

Reply
0 Upvotes
Esteemed Contributor | Diamond Partner

@ErinGerg 

 

I recently looked into this for our agency as well.

 

Unfortunately, I wasn't able to track when a visitor actually sent a message. What I was able to do was implement interaction tracking on the chat window itself using the following code (note that this has some customizations for our Google Tag Manager setup).

 

<script>
window.addEventListener( 'message', function(event) {
  if ( event.origin !== 'https://app.hubspot.com' )
    return false;
  
  var eventData = JSON.parse(event.data);
  if ( eventData.type == 'open-change' ) {
  	dataLayer.push({
      'event': 'Send Event',
	  'event_category': 'Live Chat',
      'event_action': ( eventData.data ) ? 'Opened Chat' : 'Closed Chat',
      'event_label': eventData.uuid,
      'event_value': 10
    });
  }
});
</script>

That will push a dataLayer event for opened/closed click interaction, which isn't perfect, but it's a start.

 

HubSpot needs to implement a window message event for "message sent" so we can truely know when a chat has been started (not just assuming a click = a conversation). 

Reply
0 Upvotes
Esteemed Contributor | Diamond Partner

UPDATE:

 

Actually, digging into this further, tracking when the "conversation is started" is possible. 

 

 

<script>
window.addEventListener( 'message', function(event) {
  if ( event.origin !== 'https://app.hubspot.com' )
    return false;
  
  var eventData = JSON.parse(event.data);
  var eventAction = false;
  
  switch( eventData.type ) {
    case 'closed-welcome-message':
      eventAction = 'Closed - Welcome Message';
    break;
    case 'open-change':
      eventAction = ( eventData.data ) ? 'Opened - Window' : 'Closed - Window';
    break;
    case 'external-api-event':
      if ( eventData.data.eventType = 'conversationStarted' )
      	eventAction = 'Conversation Started';
    break;
    default:
      eventAction = false;
    break;
  }
  
  if ( eventAction ) {
    dataLayer.push({
      'event': 'Send Event',
      'event_category': 'Live Chat',
      'event_action': eventAction,
      'event_label': eventData.uuid,
      'event_value': 10
    });
  }
  
});
</script>

 

 

However, there isn't a way to track when a user provides their email address - which is really when you would truely count a conversation as a "lead" for analytical purposes. So this above script would track the following (assuming you use Google Tag Manager):

 

  • Users who open/close the chat window
  • Users who close the chat welcome message (if you're using one)
  • Users who start a new conversation
Highlighted
Occasional Contributor

Honestly Hubspot, Can you just build a Google Analytics integration already?  Gravity forms has one.  Basically every platform has realized Google is the statistics of record for the Internet.  Let's play nice with google analytics please.  It would be a huge gain for the platform.  

Visitor

I agree completely. We have our Google  Ads campaigns based partially around using chat activity as an indicator for number of conversions and conversion value, pulling that information from Google Analytics. It seems that isn't really possible now.

 

I'm not sure why HubSpot chat doesn't really seem to be showing ANY events in Google Analytics. This seems like a major oversite. At least give us the data on what is happening by triggering events.

Reply
0 Upvotes
New Contributor

Hi there, Could you walk me through the settings needed with GTM in order set correctly this tag?

 

Thanks a lot!

Reply
0 Upvotes
Esteemed Contributor | Diamond Partner

Sure, DM me and I can help you.

New Member

Hi,

 

How to install de chat tracking in Google Tag Manager?

 

Thanks!

Reply
0 Upvotes
New Contributor

derekcavaliero's code works really well. Thank you!

 

Here's what we did to install via GTM and start writing data to GA. At a high level, the flow runs like this:

 

Event Tracking > GTM Event > GTM Variables > GTM Trigger > GA

 

1. Add derekcavaliero's code using a custom HTML tag, and make sure it fires on all pages.

Screen Shot 2019-09-26 at 9.11.27 AM.png

 

2. Next, register each data layer from the code (event, event_category, event_action, event_label, event_value) as a user-defined variable.

Screen Shot 2019-09-26 at 9.13.34 AM.png

3. Here's a sample:

Screen Shot 2019-09-26 at 9.14.30 AM.png

 

4. Next, visit "Triggers" and register the event name from the code. In our case, we're using: "Widgets." derekcavaliero's default is "Send Event."

Screen Shot 2019-09-26 at 9.17.42 AM.png

Here's our example:

Screen Shot 2019-09-26 at 9.21.06 AM.png


5. Finally, go back to "Tags" and register a new GA tag. Include the event variables and fire on the trigger you created in step 3.

Screen Shot 2019-09-26 at 9.23.12 AM.png

 

6. After you publish the update, you'll see the events in Google Analytics:

Screen Shot 2019-09-26 at 9.26.07 AM.png

You can see this solution live on our marketing intelligence solution's marketing in China and marketing benchmarks pages. This Chrome extension can be helpful for previewing events.

Regular Visitor

Dear oqm4,

Thank you for sharing your implementation. I've implemented your way accordingly and it works. However, I am facing one issue, which is: It is actually tracking the event "Conversation started" multiple times - once I sent a chat message, once the agent replies and then continuing from every other message.

Is there any way on how to reduce it to counting this event only once, as a conversation can only be started once? I've tried firing the tag only once per page within GTM, but it doesn't work. I would certainly appreciate any kind of help.

I know there are unique events within GAnalytics, but if you set it up as conversion in GA, how to make it count only once?

With kind regards, Christian

Reply
0 Upvotes
Occasional Contributor

Hello,
I have met your post and we have managed to send sales to Google Ads, Analytics and send click and lead event with the HubSpot chat.

I am not a technician but it still helps you with your development team.

1. We collect variables such as clientid and gclid in each user's session cookie (client with Google Analytics and Google Ads, and gclid to attribute sales to campaigns in Ads).

2. You must save this information as a contact property in HubSpot. And save it as a hidden field in a form.

3. With this information you can generate a Webhook that you can send to the different platforms by API in Google Ads (complicated by Google documentation) and Measurement protocol by Google Analytics (I do not know if there is another way but surely this is the easiest ).
In this way you can send the information in a workflow and webhook when there is a sale, lead or any action (for example).

4. For the chat, we have recently been able to send all user information. To do this you must activate the possibility of creating contacts in HubSpot without the need for email. Then after a chat action event (click or conversation), send the information via the HubSpot API and create a form with the user token to associate the Chat conversation and the information collected with the contact. (look this post)
Then in the logic of the chat you can send a webhook to Google Analytics or Google Ads to send the event.


In short, this is what we have implemented to be able to collect and send events with the integral and measured funnel.

 

Your post and requirement has time, but I hope it helps you or someone else.

 

Smiley Happy