Skip to content
Faisal Mahmud TusherDigital marketing, SEO & analytics
with Faisal Tusher

Marketing Analytics › Google Tag Manager

Tracking Forms with Tag Manager

Implement form tracking in Tag Manager: confirmed submissions from the data layer, form starts, validation errors, multi-step forms and the tests.
Tutorialintermediate9 min readUpdated

What to record for each form

A form has a Funnel of its own, and the forms guide lists its stages: the first interaction, the fields, the submit attempt, the error and the successful submission. Four events cover them for most sites. Each carries the form's name as an event parameter, so one event serves every form, as the events and parameters guide recommends.

EventFires whenParametersAnswers
form_startThe visitor first interacts with any field, once per form per pageform_nameDoes the page get people into the form?
form_errorThe form shows a validation error, or the server rejects the submissionform_name, field_name, error_typeWhich field and rule stops people?
form_stepA step of a multi-step form is completed and acceptedform_name, step_number, step_nameWhere in a long form do people leave?
generate_leadThe server has accepted the submissionform_name, lead_typeHow many real enquiries did each form produce?

generate_lead is one of the recommended events the events guide lists; use sign_up instead for account creation, because a lead and a registration mean different things to the business. The other three are custom events with names your tracking plan fixes. None of them carries anything the visitor typed. Field values are personal data far more often than anyone expects, and the guide to keeping personal data out of analytics lists form fields among the commonest routes by which it leaks.

Before you start

  • The building blocks. The tags, triggers and variables guide covers custom event triggers and data layer variables, and warns that form triggers fire on attempts.
  • A data layer contract. The data layer guide explains pushes, timing and the contract table; every event below is a row in it.
  • A developer who can change the forms, or for a form you cannot change, the section near the end of this page.
  • The GA4 configuration in the container, built as the GA4 through GTM tutorial shows, and a property role that can register custom definitions.
  • The lead system's own count for a recent closed day, from the CRM or quote system, to reconcile against after publishing.
  • Preview mode working on the site, with a test address the sales team knows to ignore, following the debugging tutorial.
  1. List every form and how it submits

    Walk the site and record every form: the page or template, a short controlled name such as quote_home or contact, what a submission means to the business, and how the form submits. Four patterns cover most sites. A form that reloads to a thank-you page; a form submitted by script, which shows a message without leaving the page; a multi-step form; and a form embedded from another service in a frame. The method decides the build: the browser's own submit can be seen by a form trigger, a script submission may never produce one, and an embedded form runs in someone else's page. Note who owns each form's code and whether it can change. The inventory becomes rows in the tracking plan and, later, the list the tests walk through.

  2. Agree the success push with developers

    The success signal is a data layer push sent after the server accepts the submission, never on the click. For a script-submitted form, the push goes in the success callback; for a reloading form, it is rendered once on the confirmation the server returns, not on a thank-you address that anyone can reload or bookmark. Agree the keys and their allowed values, and add the row to the contract.

    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      event: "generate_lead",
      form_name: "quote_home",
      lead_type: "quote"
    });
    

    If the page navigates away immediately after the push, the data layer guide describes the eventCallback and eventTimeout options that let the container's tags send before the browser leaves.

  3. Build the submission trigger and tag

    In the container, create data layer variables for form_name and lead_type, a custom event trigger on generate_lead, and one GA4 event tag with the event name generate_lead and both parameters read from the variables. In the property, register both parameters as event-scoped custom dimensions so reports can split leads by form; the events guide explains that unregistered parameters never reach reports. Remove or pause the old form submission or click trigger in the same workspace, because running both counts every lead twice. Marking generate_lead as a Key Event and choosing its counting method belong to the key events guide.

  4. Add the form start event

    A form start is the first interaction with any field, recorded once per form per page however many fields are touched. The cleanest source is the site: a listener on the form pushes form_start with the form name on the first input and then sets a flag so it never pushes again for that form on that page. Where developers cannot add it, a reviewed custom HTML tag in the container can attach the same listener, at the cost of script the governance process must read. Build a custom event trigger and a GA4 event tag as in the previous step, reusing the form_name variable. If the data stream's enhanced measurement form option is on, switch it off when this event goes live, so form_start arrives from one source under one rule. Starts divided by page views tell you whether the page gets people to the form at all.

  5. Record validation errors by field

    Push form_error each time the form shows an error, with the form name, the field's name from a controlled list, and the kind of rule that failed, such as required or format. Server-side rejections count too: a submission refused for a duplicate or an unsupported postcode is an error the visitor saw, so the server's response should trigger the same push. Never send the message text if it can echo what was typed, and never send the value. Register field_name and error_type as event-scoped dimensions. Errors by field and by device are the reading the form abandonment guide relies on to separate a confusing rule from a hostile phone keyboard. Failures outside forms, such as missing pages, refused payments and empty listings, are recorded the same way in the tutorial on tracking errors and failed actions, which reads form_error alongside them.

  6. Handle multi-step forms

    For each step, push form_step when the step is completed and accepted, with a step number and a short step name, rather than when the step is displayed. The final step's success is still generate_lead, so the lead count stays comparable across single and multi-step forms. If the steps change the address without reloading the page, rely on these pushes rather than history change triggers, which the data layer guide shows firing on changes that are not steps. A funnel exploration with form_start, each form_step and generate_lead, narrowed by form_name, then shows where a long form loses people.

  7. Test the negative cases

    In preview, with DebugView open, prove what must not happen as carefully as what must. Submit the empty form: errors per required field, no lead. Submit an invalid format: one error, no lead. Trigger a server rejection: an error, no lead. Submit successfully and reload the confirmation: one lead only. Double-click the submit button: one lead. Start the form and leave: one start and nothing else. Use two forms on one page: two starts, each with its own name. Then read every parameter in DebugView and confirm none holds anything a visitor typed. Repeat with analytics consent refused, where nothing should reach the property.

  8. Publish and check the reports

    Publish with a version note listing the forms covered and the tests passed. The next day, read the events report for the four events, split leads by form_name, and reconcile one closed day of generate_lead against the lead system's own count. Expect GA4 to be a little lower, for consent and blockers; investigate a large gap or one form that is far out, using the diagnosis for GA4 not tracking form submissions to find the cause form by form. Build the form funnel and an errors-by-field table in explorations, and use the conversion rate calculator for completions over starts. From here, reading the numbers and changing the form belongs to the CRO guides, and a change such as fewer fields can be tested as the lead form length experiment describes.

One quote form, tracked (illustrative)

Illustrative example — not a real result

Ploverstitch Home Insurance replaces a click trigger

Ploverstitch Home Insurance, an invented home insurer, measured its quote form with a form submission trigger on the submit button, sent to GA4 as quote_submit. In October the property recorded 4,860 quote submissions; the quote system recorded 2,910 quotes issued. The gap was every attempt that failed: an empty required field, a postcode the rating engine did not cover, a date of birth in the wrong format.

The rebuild followed the steps above. The developers added a generate_lead push in the quote system's success response with form_name: "quote_home" and lead_type: "quote", a form_start push on first input, and a form_error push for each client and server error with the field name. The click trigger was removed in the same release. November's figures:

MeasureNovember
Form starts (form_start)9,400
Errors on postcode1,620
Errors on date of birth880
Errors on rebuild value640
Confirmed quotes in GA4 (generate_lead)2,850
Quotes issued in the quote system2,930

GA4 now sits about 3% below the quote system, which the team accepts as visitors who declined analytics. The postcode errors split almost entirely into one cause: people typing the postcode without a space, which the form rejected. Accepting both formats is the first change the CRO team tests.

Forms you cannot change

Some forms belong to a platform, a plugin or a third party, and no developer can add a push. The options, in order of how close they come to a confirmed submission:

Source of the success signalHowWeakness
A confirmation page that renders only after successCustom event or page view condition on that page; the events guide also describes a create event rule that derives a lead from itA reload or bookmark counts again unless guarded
A success message that appears on the pageElement visibility trigger on the messageBreaks when the message's markup changes
The form trigger with validation enabledThe building blocks guide describes the option that fires only when the browser would submitStill counts submissions the server rejects
A click on the submit buttonClick triggerCounts every attempt; do not use for leads

Treat any of these as a stopgap, written into the tracking plan with its weakness, while the request for a proper push is pursued. A form embedded from another service inside a frame is a different problem, because your container cannot see inside it at all; the guide to embedded widgets and hosted pages sets out the options there.

Common mistakes

  • Counting the click. Attempts, failed validation and server rejections reported as leads.
  • Old and new triggers running together. The replacement ships and the click trigger stays, so every lead counts twice.
  • One event per form. contact_submit, quote_submit and callback_submit where one event with a form_name parameter would do.
  • Field values in parameters. An error event that sends what the visitor typed sends personal data.
  • Form starts on every keystroke. Without a once-per-form flag, starts are counted per field and the start-to-lead rate means nothing.
  • A thank-you address as the only signal. Reloads, bookmarks and the back button add leads that never happened.
  • Step events on display. A step counted when shown, not when completed, hides where people actually stop.
  • Skipping the reconciliation. Without a closed day compared with the lead system, nobody knows whether the new count is right.

The Tag Manager hub lists the other guides in this section, and the data layer guide covers the contract and timing rules every push here follows.

Frequently asked questions

Why not use GA4's enhanced measurement form events instead?

They are a reasonable first look and a poor basis for counting leads. The setup tutorial notes that the enhanced measurement form option fires on any form it can detect, and it cannot know whether your server accepted the submission. Once you build your own events, switch that option off in the data stream so the same kind of event does not arrive from two sources with different rules, and keep one definition of a lead, written in the tracking plan.

Can I see which field people abandon the form on?

Partly, from the events in this tutorial: form starts against confirmed submissions give the abandonment, and validation errors by field show where attempts fail. To see the last field touched before leaving, add a field interaction event when each field is completed, carrying the form and field names, never the value. It adds event volume, so add it to the forms whose abandonment is worth investigating rather than to every form, and read it with the form abandonment guide.

Why does GA4 record fewer leads than the CRM?

Some gap is normal: visitors who declined analytics, browsers that block the tag, and leads that arrive by phone or email never reach the property. A large or growing gap usually means the tag does not get the chance to send, for example because the page navigates to the thank-you page the instant the push is made, or that some forms send no push at all. The data layer guide describes the callback that lets the page wait for tags; the inventory in this tutorial shows which forms are missing.

Terms used on this page

Tools to try

Frameworks

Where this page is used

Sources

  1. The data layer — Google Tag Platform
  2. Preview and debug containers — Google Tag Manager Help
  3. [GA4] About events — Google Analytics Help

Related