FreeGoogle Tag Manager recipes

Track Typeform Submissions in Google Tag Manager with this Free GTM Recipe

A free, tested Google Tag Manager recipe that captures Typeform submissions and turns them into a trigger you can use to fire conversions to Google Ads, Google Analytics and more.

Aaron Beashel
Aaron BeashelUpdated July 20267 min read
The Typeform recipe tag inside Google Tag Manager

Google Tag Manager is a common way to send conversions to Google Ads, Google Analytics, etc when someone completes a Typeform on your website.

The problem is, it's quite difficult to set up. Typeforms load inside an embedded frame (an iframe), which means Google Tag Manager's built-in form submission trigger can't see them at all, so you're left having to write custom code that listens for Typeform's messages, sends an event to the dataLayer, and build triggers on top of that.

And unless you're a developer or very experienced with Google Tag Manager, you're going to struggle.

Fortunately though, there is a simple solution.

You can simply install this Typeform Conversion Tracking Recipe in your Google Tag Manager account, and you'll have everything you need to get basic conversion tracking set up.

What Is a Google Tag Manager Recipe and What's in It?

A recipe is a pre-built bundle of Google Tag Manager assets (a tag, a trigger and two variables) that you import in one go instead of building each piece yourself. You can see all our recipes and how they work in the GTM recipe library.

This recipe detects successful Typeform submissions, sends a 'Form Submitted' event to Google Tag Manager, and gives you a Trigger you can use to send conversions to Google Analytics, Google Ads, etc. There are four parts to it, and nothing inside is hidden. Here's exactly what each piece contains, so you can see what you're importing before you import it.

Custom HTML Tag

Listens for successful Typeform submissions and pushes a 'typeform_form_submitted' event to the dataLayer. It fires on All Pages, once per event, and this is the code inside it.

The Tag's CodeJavaScript · 72 lines
(function () {
  if (window.__converlyRecipeTypeform) return;
  window.__converlyRecipeTypeform = true;
  window.dataLayer = window.dataLayer || [];

  // HTTPS-only, host-anchored. Matches typeform.com and any subdomain
  // (form.typeform.com is the real iframe host).
  var ORIGIN_PATTERN = /(^|\.)typeform\.com$/;

  function fireConversion(formId, responseId) {
    window.dataLayer.push({
      event: 'typeform_form_submitted',
      form_id: formId || '',
      response_id: responseId || ''
    });
  }

  // Typeform's Embed SDK has normalized the "visitor submitted" postMessage
  // type differently across versions/embed modes (inline, popup, slider).
  // Accepting the known aliases costs nothing while protecting against an
  // SDK update.
  function looksLikeTypeformSubmit(data) {
    if (!data || typeof data !== 'object') return false;
    var t = data.type;
    if (typeof t !== 'string') return false;
    return (
      t === 'form-submit' ||
      t === 'typeform.formSubmit' ||
      t === 'typeform-form-submit' ||
      t === 'embed-auto-close-popup'
    );
  }

  function pickFormId(data) {
    return data.formId || data.form_id || data.formID ||
      (data.payload && (data.payload.formId || data.payload.form_id)) || '';
  }

  function pickResponseId(data) {
    return data.responseId || data.response_id || data.responseID ||
      (data.payload && (data.payload.responseId || data.payload.response_id)) || '';
  }

  function onMessage(event) {
    if (!event || !event.source) return;
    if (event.source === window) return;
    if (!event.origin || typeof event.origin !== 'string') return;

    // Origin check — HTTPS-only, host-anchored. Extract the host from a
    // strictly-https origin and test ORIGIN_PATTERN against it. Rejects
    // http:// origins and substring-match spoofs (e.g. typeform.com.evil.com).
    var hostMatch = /^https:\/\/([^/]+)$/.exec(event.origin);
    if (!hostMatch) return;
    if (!ORIGIN_PATTERN.test(hostMatch[1])) return;

    var data = event.data;
    // Some older embeds post a JSON-encoded string instead of an object.
    if (typeof data === 'string') {
      try { data = JSON.parse(data); } catch (e) { return; }
    }
    if (!data || typeof data !== 'object') return;
    if (!looksLikeTypeformSubmit(data)) return;

    var formId = pickFormId(data);
    var responseId = pickResponseId(data);
    if (!formId || !responseId) return;

    fireConversion(formId, responseId);
  }

  window.addEventListener('message', onMessage, false);
})();

Variables

Capture the form ID and response ID of the submission, ready to reference in any tag. These are their exact settings.

Name

DLV - Typeform Form ID

Variable Type

Data Layer Variable

Data Layer Variable Name

form_id

Name

DLV - Typeform Response ID

Variable Type

Data Layer Variable

Data Layer Variable Name

response_id

Trigger

Fires when the 'typeform_form_submitted' event is received. Use it as the trigger for any conversion tag. These are its exact settings.

Name

CE - Typeform Submitted

Trigger Type

Custom Event

Event Name

typeform_form_submitted

Download This Recipe

Get the ready-to-import file and upload it into Google Tag Manager. Everything shown above (the tag, the trigger and both variables) comes pre-built inside.

Built from Converly's own Typeform detection code

Why It's the Best Recipe Out There

It is built from the same detection code we use in our own conversion tracking product, Converly, just adapted to run inside Google Tag Manager.

Listens for Typeform's built-in postMessage, which only fires on a successful submission.
Verifies the message really came from Typeform. Typeforms live in an embedded frame that announces submissions to your page, and most public scripts skip the security check, which means any script on the page can fake a conversion. This recipe validates the sender before trusting anything.
Works with the various Typeform embed options, including Standard, Full Page, Popup, Slider and Sidetab.
Has been rigorously tested through our own QA process and has been used to detect thousands of Typeform submissions by Converly customers

How to Use the Typeform GTM Recipe

1

Install the Recipe

Download the recipe using the form above, then import it into your Google Tag Manager container. In GTM, head to Admin, choose Import Container, select the downloaded file, and pick the Merge option (so it doesn't overwrite anything already in your container). The listener, variables and trigger are added for you automatically.

Importing the recipe container in Google Tag Manager
2

Configure Your Tags

Now that the recipe is installed, you can use it as a Trigger for your conversion tags. Here are two common examples.

Example 1: Google Analytics

Create a GA4 event tag and set the recipe's trigger (called CE - Typeform Submitted) as its firing trigger. Every Typeform submission now sends an event to Google Analytics.

A GA4 event tag using the recipe's trigger

Example 2: Google Ads

Add your Google Ads conversion tag and fire it on the recipe's trigger (called CE - Typeform Submitted) to send form submissions as conversions to Google Ads.

A Google Ads conversion tag using the recipe's trigger

What This Enables You to Do (and What It Doesn't)

This recipe fires an event in Google Tag Manager whenever a successful Typeform submission is detected. You can use that as a trigger to send conversions to Google Ads, Google Analytics and other tags.

What it does

Sends an Event to GTM

Detects successful Typeform submissions and pushes an event called 'typeform_form_submitted' into your dataLayer automatically.

Tells You Which Form Fired

Captures the form ID and response ID of the submission, so a site with several typeforms can fire different tags for different forms.

Creates a Trigger in GTM

Gives you a 'Trigger' in Google Tag Manager which you can use as the trigger for any of your conversion tags.

What it doesn't do

Doesn't send the conversion server-side

Everything fires client-side, so ad blockers can prevent the tag from loading, and browser privacy restrictions can limit tracking to as little as a day.

No Click IDs or Identifiers

It does not capture the Google click ID, Facebook click ID, Meta pixel cookies, IP address or user agent, which ad platforms need for Enhanced Conversions (Google) or a high Event Match Quality score (Meta).

No Personal Details

The script only fires an event. It does not capture the lead's name, email or phone number, all of which Google and Meta require for enhanced conversions and a high match score.

No Logging or Notifications

You can test it with Tag Assistant on install, but unless you check every week you have no way of knowing if it quietly breaks.

The Proper Way to Send Conversions to Google Ads, Meta Ads & More

This recipe is fine if you only send events to Google Analytics, which does not accept personal information or IP addresses. But to get a good Event Match Quality (EMQ) score in Meta, or use Enhanced Conversions in Google, you need to send the data server-side, along with the lead's name, email, Google Click ID, Facebook Click ID, IP address, etc. That is what Converly does.

A Converly workflow sending Typeform conversions to ad platforms

Here's why Converly is the best way to send conversions to Google Ads, Meta Ads, Microsoft Ads, LinkedIn Ads, etc.

Easy to set up

Converly gives you a simple drag-and-drop builder you can use to build a Conversion Flow. Simply select a trigger (like a Typeform being submitted) and then select your actions (like sending a conversion to Google Ads). No custom code, no complex configuration.

Sends Data Server-Side

Unlike when you use Google Tag Manager, Converly sends conversions directly from its servers to Google, Meta, LinkedIn, etc., so ad blockers and privacy restrictions can't get in the way.

Sends More Data

It captures the lead's name, email and phone plus the Google and Facebook click IDs, IP address and user agent, and sends them with every conversion. That enables Enhanced Conversions in Google Ads, or gives you an Event Match Quality (EMQ) score of 9 or 10 in Meta.

Full Conversion Log & Email Notifications

See every lead that submitted your Typeform, what data was captured, what was sent to each platform, and whether it was received. Get email alerts if anything goes wrong so your conversion tracking can't break without you knowing.

Supports Multiple Tools & Destinations

Detects submissions across 80+ forms, scheduling, and chat tools and sends to 20+ destinations, including Google Ads, Meta, LinkedIn, Microsoft, and TikTok. So if you ever add a new tool or start advertising on a new platform, setting up proper conversion tracking is just a few clicks.

Provides Free Support

Our team has 20 years of experience in conversion tracking and analytics and is here to help whenever you need it. With Google Tag Manager, you're on your own.

Start Your Free Trial

Start a 14-day free trial and track your conversions the proper way. No code, no complicated configuration.

About the author

Aaron Beashel
Aaron Beashel

Aaron is the founder of Converly. With over 15 years of experience in digital marketing and SaaS, he's passionate about helping businesses track and optimise their ad conversions.

Start your free trial

Easily send conversions to your ad platforms and analytics tools.
No code required.