• Live group demo of Marketing Hub + Data Agent

    Standardize reporting, reduce manual work, and introduce AI without cleanup

    Join us on March 12
  • Marketing that's efficient and human? That's Loop Marketing.

    Explore HubSpot Academy's 39-video playlist and put it into practice.

    Start learning

Connect GA3 Tag to track form submission

ALe48
Member

Hello, 

 

I wanted to track form submission from Google Analytics, and the HubSpot form is embedded in the tracked website. I wonder if anyone can advise me on how to do this. I tried this method, and it's not working. Thank you.

 

Custom HTML tag with the Listener Code

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

0 Upvotes
1 Accepted solution
FarioConsulting
Solution
Top Contributor

Hi,

 

You could usie Google Tag Manager to track HubSpot form submissions in Google Analytics....Google Tag Manager can pass those events to Google Analytics

 

Hope this helps!

 

Cheers,
Harsh
Fario Consulting

View solution in original post

0 Upvotes
1 Reply 1
FarioConsulting
Solution
Top Contributor

Hi,

 

You could usie Google Tag Manager to track HubSpot form submissions in Google Analytics....Google Tag Manager can pass those events to Google Analytics

 

Hope this helps!

 

Cheers,
Harsh
Fario Consulting

0 Upvotes