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.
<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>
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
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.
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.