hello@datascale.de+49 89 921 35 623DEEN

Search services, integrations and blog posts.

DatascaleResourcesGTM Form Tracking Template

Free · a template you keep

GTM Form Tracking Template for FormAssembly

A GTM template for the full FormAssembly form lifecycle: view, start, step, submit and error in the dataLayer, with the FormAssembly form ID and version. Works with redirecting and AJAX forms. Open source under Apache-2.0.

Clean form tracking for FormAssembly, with no data collection of its own. The template loads a small runtime and writes the form lifecycle into the dataLayer. Current version: 2.0.0.

View on GitHub →

What it tracks

  • view: the form becomes visible
  • start: first interaction with a field
  • step_N: step change on multi-step forms
  • submit: successful submission
  • error: validation or submission errors
  • form ID and version (formId, formVersion)
  • optional non-sensitive select choices as a label you define (for example yes/no for a callback preference), never the selected value

Features

  • Works with forms that redirect and with forms the page submits via AJAX and replaces with a confirmation module
  • Consent gating via OneTrust, or none when you use Google Consent Mode (recommended)
  • Multi-step and modal forms
  • SPA navigation without re-tagging
  • Deduplication of repeat events
  • No network calls of its own beyond loading the runtime, just dataLayer.push

Install

  1. Import the template from the GTM Community Template Gallery, or load template.tpl manually.
  2. With Google Consent Mode, clear the consent groups and put the consent requirement on your GA4 tags. With OneTrust gating, set your groups; analytics usually sits on C0002.
  3. Trigger the tag on "Initialization - All Pages".
  4. Map your form IDs to names, and add the new ID whenever a form is copied or re-published.

Licence & code

Apache-2.0. Code on GitHub. The Gallery permalink follows after Google review.

Last updated:

All resources →

Asked often

Does the template collect any data of its own?

No. Apart from loading its runtime script, it only runs dataLayer.push, with no network calls of its own and no external endpoint. What happens to the events is up to your own GTM tags.

Does it work with multi-step and modal forms?

Yes. The template reports step changes as step_N and treats forms inside modals like regular forms, including after SPA navigation without a page reload.

Which consent platform is supported?

Consent gating reads OneTrust's OptanonConsent cookie by default, with configurable groups; analytics usually sits on C0002. With Google Consent Mode, clear the groups and put the consent requirement on your GA4 tags. Interactions before the visitor answers the banner then reach the dataLayer, and Consent Mode decides what GA4 does with them.

The form name changed after we re-published the form. Why?

Copying or re-publishing a form in FormAssembly creates a new form ID. Without an ID or path mapping, the name falls back to the nearest visible heading. Add the new ID to the template's form name table before the new form goes live, and formName stays the same.

Our page submits the form via AJAX and shows a thank-you module. Does submit tracking work?

Yes. When the page intercepts the submission, the runtime watches the form for up to 15 seconds by default. An error message counts as error, a form that is replaced or hidden counts as submit. If the form stays as it was, nothing is pushed.

Afterwards: does it actually work?

The Tracking Check tests tracking, consent and security headers live against your site.

Start the Tracking Check →

From template to setup

Documented is not measured.

Where the template exposes gaps, the measurement service wires them up, each with an acceptance criterion.