Trigger Google Analytics Event with Form Submission
I read this article, which shows you how to add Google Analytics event tracking to a HubSpot form submission:
I applied this to one of my embedded HubSpot forms, but it doesn’t seem to be tracking the event in Google Analytics. I am not using Google Tag Manager.
Here is the code I used:
hbspt.forms.create({
css: ‘’,
portalId: ‘XXXXXXX’,
formId: ‘XXXXXXX-XXX-XXX-XXXXXXX’,
onFormSubmit: function($form) {
"_gaq.push([’_trackEvent’, ‘Contact’, ‘contact_us_form’, ‘Main_Contact_Us’, false]);"
},
submitButtonClass: ‘btn btn-primary btn-hubspot’,
locale: ‘en’,
translations: {
en: {phoneInvalidLengthOrFormat: ‘Please enter a valid phone number.’}
}
});
I realize that this is very similar to the question posed in this forum, but I followed these instructions and am still running into issues.
Trigger Google Analytics Event with Form Submission
Super easy way to do this in a minute (without Google Tag Manager)
I've written a blog post tutorial for the absolutely easiest way to do this. Has a copy-pasteable snippet and a video which shows it step-by-step.
You should not modify the form itself. It's inside an iframe so it will not communicate with your website analytics for valuable info like where the user came from, which pages they visited etc etc. You'll either use Google Tag Manager or a script like mine to listen for the form being submitted inside it's iframe and then sending the event to Google Analytics.
Hope this helps! And feel free to get in touch if you need any 1-on-1 help.
Trigger Google Analytics Event with Form Submission
What you mean to say is you spammed the forums with this link which actually makes you PAY to find out the answer. While i undertsnad you have "rent to pay" this forum is for/by users, so to not actually help or mislead pepople is pretty messed up.
Trigger Google Analytics Event with Form Submission
Hi,
I have a similar problem since we should embed a Google Analytics event tracking code in HubSpot form. Conversion is when a customer clicks a send button of the contact form. My question is that where is the right place for GA Event tracking code? And is this type of code the best option in this case:
Trigger Google Analytics Event with Form Submission
Hi all - battling with this same issue. I really think that the better route to follow is to first implement Google Tag Manager and then republish you GA script but through GTM..
"Google Tag Manager is a tag management system that allows you to create and monitor tags on a user interface, without writing new code each time you want to construct a tag. You simply embed the Google Tag Manager code into each page of your website. This eliminates the manual process of creating tags, making your marketing process more efficient and precise."
Once done - you will be in a much better position to track conversions in Hubspot. With GTM installed here is how you can track HS forms in GTM and GA:
Trigger Google Analytics Event with Form Submission
I have followed this GTM instrucion as followed but the tag is not firing. In the trigger, I used the option to record every embedded form completion. So I used the "hbspt-form" option in the trigger which is found from the page where the form is embedded.
There isn't currently a way to access the onFormSubmit callback globally or via the UI, so you'd need to either replace it with an embedded form or use a workaround like detecting the hsvalidatedsubmit event (see below).
Trigger Google Analytics Event with Form Submission
Hi, I'm trying to trigger GA events from an embedded hubspot form as well, but it's not working after following the instructions. Here is my form code - what have I done incorrectly?
You’ll want to put that inside the onFormSubmit callback, where the _gaq.push call is now. You’ll probably also want to check out the ga.js to analytics.js migration docs, if you haven’t already:
Trigger Google Analytics Event with Form Submission
Hi Derek, I'm trying to replicate this in my form with no sucess... could you please add the onFormSubmit function to the below code? everytime I add it the form doesnt display.... thanks a lot!
Trigger Google Analytics Event with Form Submission
Where you paste that code?
“Here is the code I used:
hbspt.forms.create({
css: ‘’,
portalId: ‘XXXXXXX’,
formId: ‘XXXXXXX-XXX-XXX-XXXXXXX’,
onFormSubmit: function($form) {
”_gaq.push([’_trackEvent’, ‘Contact’, ‘contact_us_form’, ‘Main_Contact_Us’, false]);"
},
submitButtonClass: ‘btn btn-primary btn-hubspot’,
locale: ‘en’,
translations: {
en: {phoneInvalidLengthOrFormat: ‘Please enter a valid phone number.’}
}
});"
I have an hubspot form and i want to do that on click button, but i don’t know where is the place to paste this code p.e. “ga(‘send’, ‘event’, ‘Videos’, ‘play’, ‘Fall Campaign’);”