Google analytics event /goal tracking for hubspot forms & chat with google tag manager

Hi Everyone,

I’m going slightly mad while trying to find a solution for tracking HubSpot forms and chats with Google Analytics & Google tag manager as a goal/event.

My config

Tag:

<script type=“text/javascript”>
window.addEventListener(“message”, function(event) {
if(event.data.type === ‘hsFormCallback’ && event.data.eventName === ‘onFormSubmitted’) {
window.dataLayer.push({
‘event’: ‘hubspot-form-success’,
‘hs-form-guid’: event.data.id
});
}
});
</script>

I am unable to make it work…

Hi!

I found this post over on the development forum which might help in adding Google Analytics event tracking for a HubSpot form submission: https://community.hubspot.com/t5/APIs-Integrations/Trigger-Google-Analytics-Event-with-Form-Submission/m-p/223490

I also found this article which might help with the Google Tag Manager set up: Tracking HubSpot Forms with Google Tag Manager - Clarity Global

I hope this helps,

Katie Townsend

Inbound Executive

BBD Boom

And regarding the Chat actions? I´ve been not able to fully understand how to track actions on the live chat such as email submission and open chats.