Skip to main content

Typeform GTM Event Listener

Track Typeform form submissions and step changes in Google Tag Manager. Capture typeFormID, stepReference and fire GA4 events on typeform_submitted.

typeformformsgtmga4lead-generationmulti-stepsurvey

Typeform

Overview

Typeform is a conversational form and survey tool that embeds via an iframe. Like HubSpot, it uses the window.postMessage API to communicate events to the parent page. This listener intercepts those messages and pushes two events: a submission event and a step-change event for tracking progress through multi-question forms.

Events fired:

  • typeform_submitted, successful form submission
  • typeform_step_change, user advances to next question/step

Credit: Adapted from Codeandtonic

Why Use This Listener

Typeform's iframe architecture makes it invisible to GTM's built-in triggers. Without this listener, you cannot track:

  • Who completed a Typeform survey
  • Which step users drop off at
  • Which form (if multiple) was submitted

This listener provides form-level and step-level granularity.

Common Use Cases

  • Track completed lead qualification surveys
  • Measure drop-off rates at specific survey questions
  • Fire Google Ads conversions only on Typeform completion
  • Build audiences of users who completed specific Typeforms
  • A/B test different Typeform question orders

How It Works

Typeform dispatches postMessage events from its iframe as users interact with the form. The listener filters for form-submit and form-screen-changed message types and pushes them to the dataLayer.

GTM Setup Guide

Step 1: Create Custom HTML Tag

Tag type: Custom HTML, paste the code below. Fire on: All Pages.

Step 2: Create Event Triggers

Trigger NameEvent Name
CE – Typeform Submittedtypeform_submitted
CE – Typeform Step Changetypeform_step_change

Step 3: Create DataLayer Variables

Variable NameDL KeyPurpose
DLV – Typeform IDtypeFormIDForm identifier
DLV – Typeform StepstepReferenceCurrent step reference

Installation

html
<!-- GTM Custom HTML Tag: Typeform Event Listener -->
<script>
window.addEventListener('message', function(event) {
  if (event.data && event.data.type === 'form-submit') {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'typeform_submitted',
      'typeFormID': event.data.formId
    });
  }
  
  if (event.data && event.data.type === 'form-screen-changed') {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'typeform_step_change',
      'typeFormID': event.data.formId,
      'stepReference': event.data.ref
    });
  }
});
</script>

Data Layer Output

Submission Event

json
{
  "event": "typeform_submitted",
  "typeFormID": "AbC123De"
}

Step Change Event

json
{
  "event": "typeform_step_change",
  "typeFormID": "AbC123De",
  "stepReference": "email_question"
}

Trigger Configuration

Trigger: typeform_submitted Use for: GA4 generate_lead, Google Ads conversion, Meta Lead event Trigger: typeform_step_change Use for: GA4 form_progress event with step_name parameter

Variables to Capture

VariableDL KeyExample
DLV – Typeform IDtypeFormID"AbC123De"
DLV – Typeform StepstepReference"email_question"

GA4 Mapping Recommendations

GA4 EventParameterValue
generate_leadform_idDLV – Typeform ID
generate_leadmethod"typeform"
form_progressform_idDLV – Typeform ID
form_progressstep_nameDLV – Typeform Step

Debugging

ProblemCauseFix
No events firingTypeform on different subdomainCheck iframe src origin
typeFormID undefinedOld embed codeUse Typeform's standard <iframe> embed
Step changes not trackedUsing popup embedPopup embeds may use different message format

Best Practices

  1. Use typeform_submitted for all conversion tracking, never step changes
  2. Track step changes for funnel analysis in GA4 Explorations
  3. If you have multiple Typeforms, always include typeFormID as a GA4 parameter
  4. Use Typeform's hidden fields to pass UTM parameters into the response

Related Listeners