LOG IN OR SIGN UP
Log in to your account
Sign up

Track HubSpot Live Chats Using GTM

03 August 2024 | 0 comments | Posted by Che Kohler in nichemarket Advice

Tracking Hubspot live chat forms in GTM

HubSpot Live Chat is a tool that allows businesses to engage with website visitors in real-time through a chat interface. It offers a direct communication channel to address queries, provide support, and convert visitors into leads.  

It's easy to install.

You can inject the HubSpot script into the head tag of all your pages and enable the Live Chat function in our account, or you can run it through GTM.

The implementation will have the bot up and functioning on your site, and customers can find it on any page where you enabled the script. As customers engage with the chatbot, leads from these bot chat logs will filter into your HubSpot account but not trigger anything in your Google Analytics.

If you do want to track these engagements as a lead, GA4's auto tracker will not cut it, and you'll need to create a custom javascript listener (the same goes for HubSpot forms) to scrape page interactions for HubSpot engagements first and then pass that on to your GA4 account.

Tracking live chat forms is crucial for several reasons:

  • Lead Generation: It helps identify the effectiveness of live chat in generating leads.
  • Conversion Rate Optimisation: By analysing chat interactions, you can optimise chat scripts and agent behaviour to increase conversions.
  • Customer Satisfaction: Tracking chat volume and resolution times can help measure customer satisfaction.
  • Sales and Marketing Alignment: Understanding how chat leads convert into customers can improve sales and marketing collaboration.

Setting Up the Tracking with GTM and GA4

The best way to do it without involving your developers is to set up GTM on your site. Google Tag Manager (GTM) is a tag management system that allows you to manage and deploy marketing tags (such as Google Analytics, conversion pixels, etc.) on your website without needing to modify the code.

Here's a step-by-step guide to tracking HubSpot live chat forms with GTM and GA4:

  • Create a Custom HTML Tag in GTM to listen for Hubspot chat events:
  • This tag will listen for HubSpot's live chat events and push data to the data layer.

Create a new Custom HTML tag in GTM.  

Paste the following code, into the HTML field and set the listener to fire on all pages or any page you have the live chat enabled on.

JavaScript is as follows:

function onConversationsAPIReady() {

window.HubSpotConversations.on('contactAssociated', function(payload) {

window.dataLayer.push({

'event': 'hubspot_chat',

'eventCategory': 'hubspot',

'eventAction': 'contact_associated',

'eventLabel': payload.conversation.conversationId

})

});

window.HubSpotConversations.on('conversationStarted', function(payload) {

window.dataLayer.push({

'event': 'hubspot_chat',

'eventCategory': 'hubspot',

'eventAction': 'conversation_started',

'eventLabel': payload.conversation.conversationId

})

});

}

if (window.HubSpotConversations) {

onConversationsAPIReady();

} else {

window.hsConversationsOnReady = [onConversationsAPIReady];

}

Create Data Layer Variables in GTM:

The way the listener works it fires off a custom event along with a few parameters you might be interested in. To ensure you pass on this data to your GA4 account, consider creating variables to capture information from the HubSpot live chat form, such as:

  • Variable name: DLV – eventCategory
  • Variable type: Data layer variable
  • Data layer variable name: eventCategory
  • Data layer version: version 2

  • Variable name: DLV – eventAction
  • Variable type: Data layer variable
  • Data layer variable name: eventAction
  • Data layer version: version 2

  • Variable name: DLV – eventLabel
  • Variable type: Data layer variable
  • Data layer variable name: eventLabel
  • Data layer version: version 2

Create a Trigger in GTM:

  1. Head over to triggers
  2. Create a new Custom Event trigger in GTM.  
  3. Set the event name to "hubspot_chat" as per the listeners' definition
  4. Save the trigger

Create a GA4 Event Tag in GTM:

  1. Create a new GA4 Event tag in GTM.  
  2. Add your GA4 ID
  3. Configure the tag to fire with a unique event name - "lead_live_chat" trigger.
  4. Set the event name and parameters to capture relevant information from the data layer variables. Parameters:
  5. event_Category: {{dlv - Event Category Variable}}
  6. event_Label: {{dlv - Event Label Variable}}
  7. event_Action: {{dlv - Event Action Variable}}
  8. Append the trigger you created earlier
  9. Click save and submit your changes

GTM tag

    Your tag should look like this once completed

    Test and Debug:

    • Thoroughly test the setup to ensure data is being sent to GA4 correctly.
    • Use the GTM Preview mode to debug any issues.  
    • Check that the events and their custom parameters are pulling through to your GA4 account using the debug view

    Create Custom Dimensions and Metrics in GA4:

    Once you're pushing these events to GTM, you will need to create additional events manually based on the events you want to track, for example, "conversation started", etc.

    Since you're using event action, level, and event, there shouldn't be a need for custom dimensions for these metrics to capture additional information about live chat leads.

    If, however, you do have issues, you can add them manually or if you've changed the naming conventions for some reason.

    Additional considerations

    • Data Privacy: Handle visitor data with care and comply with relevant privacy regulations.
    • Chat Quality: Track chat quality metrics like average chat duration, customer satisfaction, and first response time.
    • Integration with CRM: Connect your live chat data with your CRM to nurture leads effectively.

    By following these steps, you can effectively track HubSpot live chat forms and gain valuable insights into your lead generation process. We hope this was straightforward and wish you many happy days of tracking.

    If, on the off chance, this guide isn't enough to get your tracking working, is now outdated due to HubSpot changes, or you need a fresh pair of eyes to review your tracking, please feel free to reach out; we're more than happy to help you.

    Contact us

    If you want to know more about digital marketing or feel this entire GA thing is too much of a bother and you need it sorted by experts, then we’re happy to assist. Simply contact us, and we can sort out your data migration for you.

    Are you looking to promote your business?

    Business owners can create their free business listings on nichemarket. The more information you provide about your business, the easier it will be for your customers to find you online. Registering with nichemarket is easy; all you will need to do is head over to our sign-up form and follow the instructions.

    If you require a more detailed guide on creating your profile or listing, we highly recommend you check out the following articles. 

    Recommended reading

    If you enjoyed this post and have a little extra time to dive deeper down the rabbit hole, why not check out the following posts about Google Analytics?

    Tags: Tracking, Data, Big Data

    Previous: {{ previousBlog.sTitle }}

    Posted {{ previousBlog.dtDatePosting }}

    Next: {{ nextBlog.sTitle }}

    Posted {{ nextBlog.dtDatePosting }}

    You might also like

    Building recurring revenue with eCommerce

    How Small eCommerce Businesses Can Generate Recurring Revenue

    22 August 2024

    Posted by Mia Johnson in Shopaholics


    A deeper look into the subscription models as a monetisation strategy and how retail stores can generate reliable revenue through automated billing c...

    Read more
    An introduction to Crypto Guarda Wallet

    What Is Guarda Wallet?

    06 September 2024

    Posted by Josh Welman in Money Talks


    Whether you're looking to store, trade, stake, or exchange assets, Guarda Wallet offers everything you need in one convenient package for desktop and...

    Read more

    Leave us a comment


    {{comment.sUserName}}

    {{comment.iDayLastEdit}} day ago

    {{comment.iDayLastEdit}} days ago

    {{comment.sComment}}

    Sign up for our newsletter