The reliable way to do HubSpot form tracking in Google Tag Manager is a small Custom HTML listener that waits for HubSpot's own success signal and pushes a hubspot_form_submit event into the dataLayer. Legacy forms send a window message with type hsFormCallback and event name onFormSubmitted. Forms built in the updated editor fire hs-form-event:on-submission:success on the window. One listener can handle both, and GA4 and Google Ads fire from a single Custom Event trigger.
This is for agency owners, PPC managers and developers who track HubSpot forms embedded on client sites that are not HubSpot CMS pages, such as WordPress, Webflow or custom builds. It covers how each embed type submits, why the built-in GTM triggers miss or overcount, a listener you can paste, GA4 and Google Ads setup, the email for enhanced conversions, the redirect setting, avoiding double counts with HubSpot's ads tool, and getting gclid and UTMs into HubSpot properties. Event and method names were checked against HubSpot's developer docs in November 2026.
Why doesn't the GTM Form Submission trigger work on HubSpot forms?
Because HubSpot forms usually render inside an iframe, and GTM only sees events in the page it runs in. A click or submit inside the iframe never reaches your container, so the Form Submission and Click triggers stay silent. That is the most common reason a HubSpot conversion shows nothing in Tag Assistant even though GTM loads fine.
When a legacy form is set as raw HTML, the fields sit in your page and GTM can see the submit. It still is not a good trigger. HubSpot's script validates and sends the data with JavaScript, so a native submit event does not tell you the submission was accepted. GA4's enhanced measurement form interactions have the same blind spots: nothing inside an iframe, and no knowledge of whether HubSpot stored the record.
Thank-you page tracking is the other common fallback. It works until someone reloads or bookmarks the page, until the form is switched to an inline message, or until the same thank-you page serves three forms. HubSpot gives you a proper success signal, so use it. For the general pattern across form tools, see our Google Tag Manager form tracking guide.
Which HubSpot form events can Google Tag Manager listen to?
It depends on which editor built the form: legacy forms post window messages, and new forms dispatch global events on the window. Check the form in HubSpot first. Forms made in the updated forms editor have a different embed snippet from the older hbspt.forms.create code, and HubSpot documents them separately.
| Item | Legacy forms (v2 embed) | Updated editor forms |
| Embed code | hbspt.forms.create({ portalId, formId, ... }) loaded from js.hsforms.net/forms/embed/v2.js | New embed snippet from the form's Share or Embed screen |
| Success signal | Window message event with data.type of hsFormCallback and data.eventName of onFormSubmitted | hs-form-event:on-submission:success on window |
| Form ID | event.data.id | event.detail.formId |
| Field values | event.data.data.submissionValues, an object keyed by property name | HubSpotFormsV4.getFormFromEvent(event).getFormFieldValues(), async, returns name and value pairs |
| Field name format | Internal property name, for example email | Prefixed names, for example 0-1/firstname |
| Unique ID per submission | Not provided in the message | getConversionId(), valid after a successful submit |
| Raw HTML option | Available on qualifying Marketing Hub or Content Hub plans | Not available in the updated editor |
On legacy forms, HubSpot also fires onBeforeFormInit, onFormReady, onBeforeFormSubmit and onFormSubmit. Do not track conversions on onFormSubmit or onBeforeFormSubmit. Both run before the data is stored. Only onFormSubmitted fires after HubSpot has saved the submission. The full list is in HubSpot's legacy forms reference.
For updated editor forms, HubSpot lists hs-form-event:on-ready, hs-form-event:on-submission:success, hs-form-event:on-submission:failed and three multi-step navigation events in its global form events reference. The global object is spelled HubSpotFormsV4 with a capital S. Several blog posts write it as HubspotFormsV4, which is undefined and throws.
How do you set up HubSpot form tracking in Google Tag Manager?
Install one Custom HTML listener on all pages, read the form ID and email from HubSpot's success signal, and push a single dataLayer event. Here is a listener that handles both form types.
<script>
(function () {
if (window.__hsGtmListener) return;
window.__hsGtmListener = true;
window.dataLayer = window.dataLayer || [];
function pushSubmit(formId, version, email, conversionId) {
window.dataLayer.push({
event: 'hubspot_form_submit',
hs_form_id: formId || '(not set)',
hs_form_version: version,
hs_conversion_id: conversionId || undefined,
hs_email: email || undefined
});
}
// Legacy forms: window message from the v2 embed
window.addEventListener('message', function (event) {
var d = event.data;
if (!d || typeof d !== 'object') return;
if (d.type !== 'hsFormCallback' || d.eventName !== 'onFormSubmitted') return;
var values = (d.data && d.data.submissionValues) || {};
pushSubmit(d.id, 'legacy', values.email, null);
});
// Updated editor forms: global form event
window.addEventListener('hs-form-event:on-submission:success', function (event) {
var formId = event.detail && event.detail.formId;
var api = window.HubSpotFormsV4;
var form = api && api.getFormFromEvent(event);
if (!form) { pushSubmit(formId, 'v4', null, null); return; }
var conversionId = form.getConversionId();
form.getFormFieldValues().then(function (fields) {
var email = null;
for (var i = 0; i < fields.length; i++) {
if (/(^|\/)email$/.test(fields[i].name)) { email = fields[i].value; }
}
pushSubmit(formId, 'v4', email, conversionId);
}).catch(function () {
pushSubmit(formId, 'v4', null, conversionId);
});
});
})();
</script>
A few things about this code are deliberate.
- The install guard. The
__hsGtmListener flag stops a second copy of the listener from being added. Without it, a tag that fires on All Pages and again on a History Change trigger adds two listeners, and every submit pushes twice.
- No origin filter on the message. Legacy forms post from different hosts depending on iframe or raw HTML embed. The check on
type and eventName is what filters. If the client runs other widgets that post messages, the type check ignores them.
- The email regex. Updated editor forms use prefixed names such as
0-1/email, so the code matches any name ending in email after a slash, or exactly email.
- Async field values.
getFormFieldValues() returns a promise. The push waits for it, and the catch still pushes the event without the email if the call fails. HubSpot's docs say some data can only be read before or after submission without listing which fields, so confirm the email appears in Preview mode for each form.
- ES5 syntax. Plain functions and
var keep the tag safe in older GTM containers and browsers.
Wire it up in GTM
- Create the listener tag. New tag, type Custom HTML, paste the code, trigger on Initialization or All Pages. It has to be in place before anyone can submit, which is easy since nobody submits in the first second.
- Create Data Layer Variables. One each for
hs_form_id, hs_form_version, hs_conversion_id and hs_email.
- Create the trigger. Custom Event, event name
hubspot_form_submit. To track only some forms, add a condition on the form ID variable. Form IDs are stable, while form names change when someone renames them.
- Add a lookup table for names. Map form IDs to readable names such as
contact or demo_request so reports do not show bare GUIDs.
- Test in Preview. Submit each form with real-looking data. Check that exactly one
hubspot_form_submit appears per submission, that the form ID is right, and that the email is filled. Then submit with a missing required field and confirm nothing is pushed.
- Publish and watch reports. Compare a week of GA4 key events against new HubSpot submissions for the same forms. Some gap from blocked tags and consent is normal. A large gap means something is wrong.
If Preview ever shows two events for one submission, check whether the listener exists twice in the container, or whether the site also loads an old hardcoded listener from a previous agency. Search the page source for hsFormCallback before you publish.
How do you send HubSpot form submissions to GA4 and Google Ads?
Fire a GA4 event and a Google Ads conversion tag from the same hubspot_form_submit trigger, each with its own parameters.
GA4
Create a GA4 Event tag with the event name generate_lead, which is Google's recommended event for lead forms. Add a form_id parameter from the form ID variable and a form_name parameter from the lookup table. Mark generate_lead as a key event in GA4. If you need separate key events for demo requests and newsletter signups, give them separate event names rather than one event with a parameter, since key events are counted by name. Our GA4 key events and naming plan covers how to keep this consistent across clients.
Never send the email, or any other field value, to GA4. Google's terms forbid personal data in GA4, and the email variable exists only for Google Ads.
Google Ads
Create a Google Ads Conversion Tracking tag with the conversion ID and label from the conversion action. Use the same trigger. Two fields are worth filling.
- Transaction ID. Set it to the
hs_conversion_id variable. On updated editor forms this gives each submission a unique ID, so Google Ads can drop a duplicate if the tag fires twice for the same submission. On legacy forms the field stays empty, which is fine.
- Conversion value. Use a fixed value per form if the client has agreed lead values. See assigning conversion values to leads for a way to set them that sales will accept.
Make sure a Conversion Linker tag fires on all pages so the gclid is stored in a first-party cookie. Without it, conversions from Safari and other browsers that limit cookies attribute poorly.
How do you pass the HubSpot form email to Google Ads enhanced conversions?
Read the email in the listener, push it as hs_email, and map that Data Layer Variable into a User-Provided Data variable on the Google Ads conversion tag. GTM hashes it with SHA-256 before sending, so you pass the plain value.
- Turn on enhanced conversions for the account in Google Ads and accept the customer data terms.
- Edit the conversion tag and tick Include user-provided data from your website.
- Create a User-Provided Data variable with manual configuration and set the email field to the
hs_email Data Layer Variable. Add phone the same way if the form collects it.
- Check in Preview that the conversion tag shows user-provided data on the submit event, then check the diagnostics in Google Ads after a few days.
Automatic detection does not work here. The tag scans the page it runs on, and with an iframe embed the email field is not in that page. Google's enhanced conversions with Google Tag Manager guide has the full field list. For the account-side setup and common diagnostics, see our enhanced conversions setup guide.
If the site uses Consent Mode, the conversion tag should respect ad_user_data consent before sending user-provided data. Our Consent Mode v2 guide covers the setup, including sites where HubSpot's own cookie banner is the consent tool.
Does the HubSpot redirect setting break tracking?
It can, because the page starts to unload right after the success signal, and the tags have to send their requests before that. Each HubSpot form has a choice after submission: show a thank-you message, or redirect to another page or URL.
- Inline thank-you message. No navigation, no race. This is the safest setting for tracking.
- Redirect. On legacy forms,
onFormSubmitted fires before HubSpot redirects, and the listener pushes synchronously, so the push almost always lands. On updated editor forms the push waits for getFormFieldValues(), which adds a short delay. Test with DevTools open and Preserve log turned on, and confirm the GA4 collect request and the Google Ads conversion request both leave before the new page loads.
- Redirect plus a thank-you page trigger. If the thank-you page also fires a conversion, you count every lead twice. Pick one. The listener is the better choice, since it carries the form ID and email.
If redirect tests keep dropping hits, the clean fix is a thank-you message in HubSpot and a client-side redirect in the success listener after the push, with a short delay. Only do that when the client agrees to the change in HubSpot, since marketing teams often rely on the redirect.
How do you avoid double counting with HubSpot ads tracking?
Choose one source for each Google Ads conversion action: either your GTM tag or HubSpot's ads conversion sync, never both on the same action as primary.
HubSpot's ads tool can create form submission conversion events for a connected Google Ads account, and it can sync lifecycle stage changes as conversions. It can create a new conversion action or map a form to an existing one. HubSpot's form submission events use enhanced conversions for web, and HubSpot notes that if the Google Ads account is accessed through a manager account, the form data does not sync through enhanced conversions, even though the event can still be created. That matters for agencies that connect client accounts through their MCC. The details are in HubSpot's article on syncing ad conversion events with Google Ads.
| Setup found on the account | Risk | What to do |
| GTM tag and HubSpot form event mapped to the same conversion action | Each lead counted twice | Remove one mapping |
| GTM tag and HubSpot form event on separate actions, both primary | Bidding sees two conversions per lead | Set one to secondary |
GTM tag plus GA4 generate_lead imported into Google Ads, both primary | Two conversions per lead | Keep the Ads tag as primary, GA4 import as secondary |
| GTM form tag plus HubSpot lifecycle stage sync (MQL, SQL) | None if they are different stages | Use the form as secondary or primary, lifecycle stages for deeper optimization |
A sensible split for many lead gen clients: the GTM form conversion carries enhanced conversions and stays primary at first, while lifecycle stage conversions from HubSpot or an offline conversion import from the CRM start as secondary. Once they have enough volume, move bidding to the qualified stage. If you inherit an account that already reports more conversions than HubSpot has contacts, start with Google Ads counting conversions twice.
The same applies to Meta. HubSpot can share events with Meta, and so can a GTM pixel tag. If both send a lead for the same submission without a shared event ID, Meta counts it twice.
How do you pass gclid and UTMs into HubSpot form properties?
Create custom contact properties, add them to the form as hidden fields, and fill them from a first-party cookie set by GTM. Then every contact carries the click ID and campaign you need for reporting and offline imports.
HubSpot auto-fills form fields, including hidden ones, from URL query parameters whose names match the property's internal name. So a hidden field with the internal name utm_campaign fills itself when the URL contains ?utm_campaign=spring. The catch is that this only reads the current page URL. A visitor who lands on a service page from an ad and then clicks through to the contact page arrives without the parameters, and the fields stay empty.
- Create the properties. Single-line text contact properties named
gclid, gbraid, wbraid, utm_source, utm_medium, utm_campaign, utm_term and utm_content. Keep internal names identical to the URL parameter names.
- Add them as hidden fields on every form that receives paid traffic.
- Store values on landing. A GTM tag reads the parameters on the first page and writes them to a first-party cookie, for example 90 days for click IDs. Do not overwrite a stored gclid with an empty value on later pages.
- Fill the fields when the form is ready. On updated editor forms, listen for
hs-form-event:on-ready and call setFieldValue with the prefixed name, such as 0-1/gclid. HubSpot asks you to add on-ready listeners before the embed code runs, so fire this tag on Initialization. On legacy forms, set the values in the onFormReady callback of hbspt.forms.create, which receives the form element.
- Check a test contact. Land with a test gclid on one page, browse to the form, submit, and open the contact in HubSpot.
An example for updated editor forms, reading values your landing tag stored in a cookie called _ag_attr as URL-encoded query string text:
<script>
window.addEventListener('hs-form-event:on-ready', function (event) {
var match = document.cookie.match(/(?:^|; )_ag_attr=([^;]*)/);
if (!match || !window.HubSpotFormsV4) return;
var form = window.HubSpotFormsV4.getFormFromEvent(event);
if (!form) return;
var pairs = decodeURIComponent(match[1]).split('&');
for (var i = 0; i < pairs.length; i++) {
var kv = pairs[i].split('=');
if (kv[0] && kv[1]) { form.setFieldValue('0-1/' + kv[0], kv[1]); }
}
});
</script>
Only set fields that exist on the form. Confirm the exact field names in Preview by logging getFormFieldValues() once, since HubSpot does not document the prefix scheme. With a legacy iframe embed you cannot reach the fields from GTM, because the iframe is a different origin, so the values have to go in through the embed callback on the page that loads the form.
Storing gbraid and wbraid matters for iOS traffic, where Google Ads often sends those instead of a gclid. Our guide to CRM lead source attribution in HubSpot and GoHighLevel covers how these properties feed reporting, and the HubSpot tracking code still needs to be on the site for HubSpot's own source reports and for embedded form analytics.
Getting it fixed for a client
Most broken HubSpot tracking we see comes down to a few things: an iframe form tracked with a click trigger, a thank-you page counted on top of a listener, HubSpot's ads sync and a GTM tag sharing one conversion action, or click IDs that never reach the contact record. Each is quick to spot once you know where to look, and slow to find when you don't. If you want a second pair of eyes on a client's setup, request a free tracking check and we will tell you what is counting, what is missing and what is counted twice.