i neet to set advanced conversions in tag manager, but it can’t recognize embedded hubspot form as a form so i can’t use tag mager form variable or trace email form data field in the thank you page
Hey @Salvoni, thank you for posting in our Community!
For advanced conversions with embedded HubSpot forms in Tag Manager, try using a click trigger on the submit button instead of a form submission trigger. Alternatively, add a Custom JavaScript trigger that listens for HubSpot form submissions. You can use the onFormSubmit callback to push events to the data layer, allowing GTM to capture the form interaction. Finally, verify the setup in GTM Preview mode and check conversions in Google Analytics or Google Ads.
@danmoyle and @Anton do you have any recommendations?
Thank you,
Pam
Thanks for the tag @PamCotton!
Hi @Salvoni and welcome to the HubSpot Community. I did a little research, as I haven’t personally solved this issue before. Here’s what I found.
Setting up advanced conversions in Google Tag Manager for an embedded HubSpot form requires a slightly different approach: Custom Event Tracking. HubSpot forms typically trigger custom events when submitted. You can use these events to track form submissions in Google Tag Manager.
Create a Custom Event trigger:
- Go to Triggers > New > Custom Event
- Set the Event name to “hubspot-form-submit” (or the specific event name used by your HubSpot form
Create a Data Layer Variable for the email:
- Go to Variables > New > Data Layer Variable
- Set the Data Layer Variable Name to “hubspotEmail” (or the specific variable name used by HubSpot)
Create a Google Analytics 4 (GA4) tag for the conversion:
- Go to Tags > New > Google Analytics: GA4 Event
- Configure the tag with your GA4 Configuration
- Set the Event Name (e.g., “form_submission”)
- Add a parameter for the email using your Data Layer Variable
Add custom JavaScript to your website to push the form data to the data layer:
window.addEventListener('message', function(event) {
if (event.data.type === 'hsFormSubmit') {
var email = event.data.data.email;
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'hubspot-form-submit',
'hubspotEmail': email
});
}
});
This code listens for the HubSpot form submission event and pushes the email to the data layer.
Hopefully that helps a bit!
P.S. Here’s one of the sources I found with more information.
Thank you so much for the information.