When I use the new form editor (in beta), I discovered that the form tracking in GTM doesn't work. Form submits with 'old' embedded Hubspot forms still work. I used the code that's referred to all over the internet:
I've already checked the Hubspot documentation but can't find changes in how to track form submits with this new editor. Does anybody have a solution for this?
Jul 25, 20243:00 AM - edited Jul 25, 20243:01 AM
Contributor
Update: For people experiencing the same problem: I also reported this to the support team and I eventually received this response:
It has been very tricky to identify and test the new form editor to capture events in GTM. - Seems like at the moment this is not supported by the new editor, and we reached out to our engineering team, and we were not given any specific expectations if this is something that they plan to implement in the future. At least not during the BETA version of form submissions. In the meantime, the recommendation is to keep using the legacy form editor so you can continue keeping track and creating events for GTM.
In short, the conversion tracking does not work with the new editor and will not work during the beta. I am very surprised that a company like Hubspot did not think about conversion tracking during development. The new editor works nicely, but I will certainly not use the new editor for this reason.
Please support my idea to integrate this functionality in the new editor.
I've researched internally, and our team suggests that the new form editor (i.e., Forms 2.0) uses a different event name. Kindly refer to the New Form Global Events doc to set up form events with GTM. For anything dev- or troubleshooting-related to this topic, it would be best to consultHubSpot Developer Supportor theDeveloper Community.
- The correct event property is event.detail, not event.data. HubSpot uses the standard CustomEvent object, and the data is stored under .detail.
- You’re opening a block (with a curly bracket) directly after console.log(event.data); without a closing bracket — that’s a syntax error. Solution: remove the unnecessary curly bracket.
I’ve tested the new global events that @RobertColson suggested — they work great!
You can use the following code in your Custom HTML tag and trigger it on DOM ready to ensure all relevant events are captured:
Hi! My bad I was OOO so I didn't catch the news on this matter... If needed, I was working on a custom HTML GTM that listen the old and new Hubspot form submissions:
<script> var eventName = "hubspot-form-success"; var includeFormData = true;
if (includeFormData && event.data.data && event.data.data.submissionValues) { for (var field in event.data.data.submissionValues) { if (event.data.data.submissionValues.hasOwnProperty(field)) { var cleanedField = field.replace(/[^\w]/g, "_"); var key = "hs-" + cleanedField; formData[key] = event.data.data.submissionValues[field]; } } }
After hours of trial and error trying to find an equivalent to the legacy form solution, I've found that the below javascript works. It captures both the submission event, pushes the success event to the dataLayer, and captures the form ID as per the original code snippet, using the HubSpot recommended methods (as described on the HubSpot global forms page😞
After hours of trial and error trying to find an equivalent to the legacy form solution, I've found that the below javascript works. It captures both the submission event, pushes the success event to the dataLayer, and captures the form ID as per the original code snippet, using the HubSpot recommended methods (as described on the HubSpot global forms page😞
I've researched internally, and our team suggests that the new form editor (i.e., Forms 2.0) uses a different event name. Kindly refer to the New Form Global Events doc to set up form events with GTM. For anything dev- or troubleshooting-related to this topic, it would be best to consultHubSpot Developer Supportor theDeveloper Community.
- The correct event property is event.detail, not event.data. HubSpot uses the standard CustomEvent object, and the data is stored under .detail.
- You’re opening a block (with a curly bracket) directly after console.log(event.data); without a closing bracket — that’s a syntax error. Solution: remove the unnecessary curly bracket.
I’ve tested the new global events that @RobertColson suggested — they work great!
You can use the following code in your Custom HTML tag and trigger it on DOM ready to ensure all relevant events are captured:
Thanks a lot for this code, I've modified it on my side to get all form fields values but you helped a lot 🙂
Just a question, did you manage to associate the "form_navigate_next" dataLayer event with the step ? I mean, if my form have 4 steps, I didn't figure out how to differenciate them... And I didn't find any help in the Hubspot API documentation
By default, the hs-form-event:on-submission:success event does not expose the user's form input data (like email), so you can't directly grab the email address at that point. The data has already been sent to HubSpot, and it's no longer accessible via the DOM or the event object. You could listen for the user's input in the email field and when it has been filled, store it in sessionStorage. Then you can use it in you success-event. Below you can find a code example. Your input HTML field should have a name=“email” attribute for this to work.
How to Track the User's Email (for Enhanced Conversions)
Listen for the user's input in the email field
Capture the value when the user types it and store it in sessionStorage:
This way, you can send the email address to the dataLayer alongside the success event, making it compatible with enhanced conversion setups (e.g. in Google Ads or GTM server-side tagging).
Additionally, I think it's best to only fire this code on pages that contain a HubSpot form. You can do that by creating a custom JavaScript variable with the following code:
I've been working with a colleague on a new version of the listener and everything seems to work so far! We are making the last modifications but I can keep you updated when everything will be accessible so you can try on your side if you want?
Hi! My bad I was OOO so I didn't catch the news on this matter... If needed, I was working on a custom HTML GTM that listen the old and new Hubspot form submissions:
<script> var eventName = "hubspot-form-success"; var includeFormData = true;
if (includeFormData && event.data.data && event.data.data.submissionValues) { for (var field in event.data.data.submissionValues) { if (event.data.data.submissionValues.hasOwnProperty(field)) { var cleanedField = field.replace(/[^\w]/g, "_"); var key = "hs-" + cleanedField; formData[key] = event.data.data.submissionValues[field]; } } }
We are looking to roll out these forms for a couple of clients, and I'm wondering if there have been any updates on tracking capabilities since the latest updates, please?
Hi @JAalbers, I just wanted to check to see if you have heard anything about the new form editor working with GTM now that it's December/almost the end of the year.
Mar 11, 20256:35 AM - edited Mar 11, 20256:35 AM
Participant
March 11st 2025 / It looks like there is still no solution 😕 Does someone found one? It's crazy that we cannot track form submission with GTM with the new hubspot form editor, can't understand how, it's so important for all companies like mine...
Hi, it seems that there is no event sent at all when form is submitted, I don't have anything when i submit the form and by checking with: console.log(event.data.type)
I hope they will work on this for the beta because this is a huge loss...