Javascript event tracking in hubspot forms

forms

#1

Hi there

I am in the habit of using the onFormSubmit attribute with hubspot forms to allow Google Tag Manager to send an event to Google Analytics as follows.

hbspt.forms.create({
portalId: ‘xxx’,
formId: ‘yyy’,
onFormSubmit: function(){
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
‘event’: ‘formSubmissionSuccess’,
‘formName’: ‘Squeeze’
});
}
});

This works usually but sometimes it appears that it does not. When i compare form submissons in Hubspot with the events being picked up in Google Analytics for our company account there are discrepancies. Of the past 40 successful form submissions, 5 of them were not picked up by GA. There’s no filtering going on in GA to exclude some submissions so as far as i can tell, the only explanation is that sometimes the code in the onFormSubmit() is not firing. Likewise, there are no javascript errors appearing in the console that might be blocking this.

Has anyone else any experience with this or any suggestions about next steps? Any reason why it should not fire sometimes? I should say that whenever i test this myself it works just fine

Thanks
Garry


#2

Garry,

I would take a read through this post.

Your issue might be relevant to this. We are working on this now.


#3

@gviner you might also want to investigate if those 5 submissions might have come from users who had adblockers or tracking blockers enabled. This is becoming more prevalent especially on iOS Safari opening up content blocker technology.


#4

Hi there. Thanks for commenting and sorry for the delayed response from me. The form is definitely connected. And in that post the poster says that the form submission does not make its way into the HubSpot contacts database. That is not the case here. Everything is perfect from the Hubspot end. It’s Google Analytics where the data is missing, and the only likely explanation is that the onFormSubmit function works sometimes and not others.

I don’t suppose you have any other thoughts? This has happened again since i posted.

Thanks
Garry


#5

You might be right about this.The next time it happens we will ask directly if they have one of these extensions. Thanks for the idea