Lead Capture Tools

sebastianstr
Participant

Google Analytics event tracking in embedded Hubspot form

Hello everybody,

 

we need to track the submission of our embedded Hubspot forms as event in Google Analytics. I followed the instructions from this post already: https://community.hubspot.com/t5/Marketing-Integrations/Google-Analytics-Event-Tracking/m-p/29831#M2...

 

My code looks like this and doesn't work:

 

<!-- [if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
  hbspt.forms.create({
	portalId: "xxxxxxxx",
	formId: "xxxxxxx",
        onFormSubmit: function($form) {
		gtag('event', 'Newsletter registration', {
  			'event_category': 'contact',
  			'event_label': 'hubspot'
		});
        }
});
</script>

Does anyone knows how we could modify the code to track the event correctly?

 

Best, Sebastian

0 Upvotes
2 Replies 2
Daniel_Bleich
Key Advisor

Google Analytics event tracking in embedded Hubspot form

Just to make sure before going in deeper, did you add your portal ID and Form ID?

Daniel Bleichman
Marketing | AudioCodes

Danielbleichman@gmail.com
Did my post help answer your query? Help the Community by marking it as a solution
sebastianstr
Participant

Google Analytics event tracking in embedded Hubspot form

Hey Daniel, yes I did 😄 I thought it could be better do replace it before starting this post.

0 Upvotes