How to track form submissions in GA4 with Google Tag Manager
The most reliable way to track form submissions in GA4 is a dataLayer event pushed when the form is sent successfully, picked up by a GA4 event tag in Google Tag Manager and marked as a key event. If you cannot change the form code, listen for the form tool's own success event (HubSpot, Calendly, Contact Form 7) or use a thank-you page. Avoid counting button clicks: they include failed and repeated submissions.
- Five ways to track a form, ranked
- The dataLayer method
- HubSpot, Calendly, Contact Form 7 and others
- The built-in Form Submission trigger
- Send the lead to GA4
- Test it
- FAQ
Five ways to track a form, ranked
| Method | Reliability | Needs a developer | Notes |
|---|---|---|---|
dataLayer push on success | High | Yes, once | Fires only when the form really sent; can carry the form name |
| Form tool's success event | High | No | HubSpot, Calendly, Typeform and most WordPress form plugins announce success |
| Thank-you page view | High | Sometimes | Needs a redirect; guard against reloads and direct visits |
| Success message visible | Medium | No | GTM Element Visibility trigger on the confirmation text; breaks when the markup changes |
| Form Submission trigger / Enhanced measurement | Low | No | Misses many AJAX forms and counts others that fail validation |
The dataLayer method
Ask your developer to add one line where the form handles a successful response:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'form_success',
form_name: 'demo_request'
});
In GTM, create a Custom Event trigger with the event name form_success, and a Data Layer Variable for form_name. Never push the visitor's name, email or message: they would end up in analytics.
HubSpot, Calendly, Contact Form 7 and others
Most form tools announce a successful submission. Listen for it with a small Custom HTML tag in GTM that pushes the same form_success event.
HubSpot embedded forms
Classic HubSpot embeds send a browser message when the form is submitted. Newer forms built in HubSpot's updated editor dispatch a DOM event instead; check which one your form uses in GTM Preview.
<script>
window.addEventListener('message', function (e) {
if (e.data && e.data.type === 'hsFormCallback' && e.data.eventName === 'onFormSubmitted') {
window.dataLayer.push({ event: 'form_success', form_name: 'hubspot_' + e.data.id });
}
});
</script>
Calendly
<script>
window.addEventListener('message', function (e) {
if (e.data && e.data.event === 'calendly.event_scheduled') {
window.dataLayer.push({ event: 'form_success', form_name: 'calendly_booking' });
}
});
</script>
Contact Form 7 (WordPress)
<script>
document.addEventListener('wpcf7mailsent', function (e) {
window.dataLayer.push({ event: 'form_success', form_name: 'cf7_' + e.detail.contactFormId });
});
</script>
Fire these listener tags on All Pages (or the pages with the form), after the Google tag. Gravity Forms, WPForms, Typeform and Webflow forms have similar success hooks; the pattern is the same.
The built-in Form Submission trigger
GTM's Form Submission trigger listens for the browser's submit event. Many modern forms send data in the background and never fire it, and others fire it before validation fails. If you use it, tick Check validation and test failed submissions too. GA4's enhanced measurement form interactions has the same limits; it is fine as a rough signal, not as your lead count.
Send the lead to GA4
- In GTM, add a Google Analytics: GA4 Event tag with your measurement ID and the event name
generate_lead. - Add an event parameter
form_namewith the Data Layer Variable as its value. - Fire it on the
form_successCustom Event trigger. - In GA4, mark
generate_leadas a key event, and registerform_nameas a custom dimension if you want to see it in reports. - Use the same trigger for Google Ads, LinkedIn and Meta, so every platform counts the same leads.
Test it
- In GTM Preview, submit the form with an invalid email: nothing should fire.
- Submit it correctly:
form_successappears once, and the GA4 tag fires once. - In GA4 DebugView,
generate_leadappears with the rightform_name. - Reload the thank-you state: no second lead.
FAQ
Why does GA4 show form_submit when nobody sent a form?
Enhanced measurement's form interactions fire on many forms, including search and newsletter boxes, and can fire before validation. Turn it off in the data stream settings if you track leads properly.
Should I use generate_lead or a custom event name?
Use generate_lead. It is a GA4 recommended event for lead generation, and Google's reports and integrations understand it.
Can I track form fields people abandon?
You can send a form_start event on the first field focus, and compare it with leads. Avoid sending field contents.
Does this work with consent mode?
Yes. The tags follow your consent settings like any other GA4 or ad tag. Leads from visitors who decline are not counted in GA4, but still reach your inbox or CRM.
Rather not set this up yourself?
We set up GA4, GTM and ad platform conversions on existing sites: GA4 setup from $450, each ad platform $200–$400.
See GA4 + GTM setup