Field notes Field note 15
Typeform conversion tracking in GA4 and Google Ads
Track Typeform submissions as conversions in GA4 and Google Ads with GTM: embed events, a clean dataLayer push, consent, and testing without double counts.
· 10 min read
Typeform conversion tracking needs one extra piece: the form runs inside an iframe on Typeform's domain, so a submission does not change your page or reach Google Tag Manager (GTM) by itself. The fix is to catch the Embed SDK's submit signal, either its onSubmit callback or the message it receives from the form, and push one clean event to the dataLayer that GA4 and Google Ads can count.
Without it, the lead exists in Typeform and nowhere else. GA4 shows a visit with no conversion, Google Ads bids as if the campaign produced nothing, and you can't tell which ads fill the inbox. The pattern is the same as in our Calendly conversion tracking guide, which this one links to where the steps are identical.
Checked on 2026-11-04 against: Typeform Embed SDK README and source on GitHub, Typeform's developer page on URL parameters in embeds, GTM Custom HTML and Custom Event triggers, GA4 events and key events, Google Ads conversion import or tag, Tag Assistant, GA4 DebugView.
Why Typeform submissions go untracked
An embedded typeform is an iframe. The SDK builds its address on form.typeform.com by default, or form.typeform.eu for EU data residency, or your own custom domain if you set one (Typeform embed source: build-iframe-src.ts, constants.ts). Your page and its GTM container can't see inside it, and when the visitor presses Submit, your URL stays the same.
The Embed SDK does report what happens inside. Its README documents callbacks you can pass to any embed type:
onReady: the form has loadedonStarted: the respondent started, with aresponseIdonQuestionChanged: the respondent moved to another questiononSubmit: the respondent submitted the form, withformIdandresponseIdonEndingButtonClick,onClose,onHeightChanged,onDuplicateDetected
onSubmit is the one that matters. onStarted fires at the start, so counting it would include everyone who abandons halfway.
Under the hood, the SDK listens for message events from the iframe and calls onSubmit when it receives one whose type is form-submit and whose embedId matches the embed (get-form-event-handler.ts, create-iframe.ts). That gives you two ways in.
Typeform conversion tracking: what you will build
- A hook that pushes
typeform_submitto the dataLayer once per submission: theonSubmitcallback (Option A) or a GTM listener for theform-submitmessage (Option B). - A Custom Event trigger on
typeform_submit. - A GA4 event tag, marked as a key event.
- A Google Ads conversion, imported from GA4 or fired by its own tag.
- Optionally, URL parameters (formerly hidden fields) that store UTMs and the Google click ID with each Typeform response.
Use one option, not both. Running both counts every lead twice.
Step 1, option A: the onSubmit callback (if you can edit the embed code)
This is the documented route, and the one to prefer. If the form is embedded with the HTML snippet, add a data-tf-on-submit attribute naming a global function. The README explains that options become data-tf- attributes with dashes, and that callbacks take the name of a function on window (README: options as HTML attributes).
<script>
window.dataLayer = window.dataLayer || [];
window.tfLeadSubmitted = function (payload) {
window.dataLayer.push({
event: "typeform_submit",
form_id: payload.formId,
form_source: "typeform_embed"
});
};
</script>
<div data-tf-widget="YOUR_FORM_ID" data-tf-on-submit="tfLeadSubmitted"></div>
<script src="//embed.typeform.com/next/embed.js"></script>
Two details decide whether this works:
- Define the function before the embed loads. The SDK reads the attribute and looks the function up on
windowwhen it sets up the embed, which it does onDOMContentLoaded(load-options-from-attributes.ts, browser.ts). If the function does not exist yet, the callback is silently dropped. That is why the script sits in the page above the embed, not in a GTM tag, which can load later. - No answers, no personal data. The callback receives
formIdandresponseId, not the answers. Keep it that way: Google's PII policy for Analytics says no data Google could recognize as personally identifiable information may be sent. We also leaveresponseIdout of the push. It is only useful server-side, where Typeform's Responses API can look it up, as the README notes.
If you embed with JavaScript instead (window.tf.createWidget, createPopup and so on, or the @typeform/embed npm package), pass the same function as the onSubmit option. The README's callbacks example shows the shape.
After a test submission, Tag Assistant should list a typeform_submit event with form_id and form_source in the dataLayer.
Step 1, option B: a GTM listener (if you can't touch the embed code)
If the embed lives in a theme, a page builder block or a plugin you can't edit, GTM can listen for the same message the SDK listens for. First log what arrives: in the browser console on the page with the form, run window.addEventListener("message", function (e) { console.log(e.origin, e.data); }), then submit a test response. You should see https://form.typeform.com (or your EU or custom domain) as the origin and an object whose type is form-submit. Then create a Custom HTML tag:
<script>
(function () {
window.dataLayer = window.dataLayer || [];
var allowedOrigins = [
"https://form.typeform.com",
"https://form.typeform.eu"
// add your custom Typeform domain here if you use one
];
var seen = {};
window.addEventListener("message", function (e) {
if (allowedOrigins.indexOf(e.origin) === -1) return;
var d = e.data;
if (!d || typeof d !== "object" || d.type !== "form-submit") return;
// One push per response, even if the message arrives twice
var key = d.responseId || "no-id";
if (seen[key]) return;
seen[key] = true;
window.dataLayer.push({
event: "typeform_submit",
form_id: d.formId,
form_source: "typeform_embed"
});
});
})();
</script>
Trigger it on All Pages (or only the pages with the form), and set Advanced Settings, Tag firing options to Once per page so a second trigger can't add a second listener (Tag firing options). Name it HTML - Typeform listener.
The trade-off: the form-submit message type comes from the SDK's source code, not a documented public API, so Typeform could change it without notice. The README documents what onSubmit receives (formId and responseId), but whether those arrive under the same keys in the raw message is something to confirm in your log. If d.formId is missing there, drop it from the push or read the form ID from your embed settings instead. Remove any logging afterwards. If you can get the embed code changed, option A is the safer long-term choice.
Step 2: Create the trigger
Create a Custom Event trigger with event name typeform_submit, firing on All Custom Events (GTM custom event trigger). Name it CE - typeform_submit. The name must match the dataLayer push exactly.
If you have several typeforms and only some are leads, add a condition on a Data Layer Variable for form_id. This also matters for chained typeforms: the README notes each callback payload carries the form ID so you can tell which form in a chain sent it (README). Count only the last form in the chain.
Steps 3 and 4: GA4 and Google Ads
These are the same as for Calendly, so follow steps 3 (GA4) and 4 (Google Ads) of the Calendly conversion tracking guide, with these values:
- GA4 Event tag: event name
generate_lead, a recommended event, ortypeform_submitif you want form leads separate from other leads. Add the parameterform_idfrom a Data Layer Variable. Trigger:CE - typeform_submit. - Key event: mark the exact event name as a key event in Admin, Data display, Events (Mark events as key events).
- Google Ads: either import the GA4 key event (create conversions from Google Analytics events) or fire a Google Ads conversion tag on
CE - typeform_submit. Make one route primary, and set the other to secondary if you keep it (primary and secondary conversion actions). Count One conversion per click for leads (conversion counting options).
Step 5: Store UTMs and the click ID in Typeform (optional)
If you also want each Typeform response to say where it came from, pass the values in as URL parameters, the feature Typeform used to call hidden fields. The SDK has two relevant options (README: options, Typeform: URL parameters in embeds):
transitiveSearchParamsforwards named query parameters from your page's URL to the form, for exampledata-tf-transitive-search-params="utm_source,utm_medium,utm_campaign,gclid".hiddenpasses values you set yourself, for exampledata-tf-hidden="lead_page=contact".
The source shows both read from the current page only: transitive parameters come from window.location at the moment the embed loads, and empty hidden values are skipped (get-transitive-search-params.ts, build-iframe-src.ts). So if a visitor lands on /?gclid=... and then clicks through to /contact, the click ID is no longer in the URL and nothing is forwarded. Either embed the form on the landing page, or store the values on arrival and pass them in with hidden when you create the embed in JavaScript.
The form must have URL parameters defined with the same names. Typeform's help says to use lowercase letters and underscores, so name them utm_source, gclid and so on. You add them in the form builder; the labels in the builder change over time, so follow Typeform's current help article for URL parameters. Then confirm it works: submit a test response from a URL with test UTMs and check the values appear in the response in Typeform.
Two cautions. The click ID is an advertising identifier, so check that storing it in Typeform matches your privacy notice and consent setup. And never do the reverse: don't read answers out of Typeform into the dataLayer.
Step 6: Respect consent
As with Calendly, the hook only pushes an event to the dataLayer. The GA4 and Google Ads tags are what measure, and they follow consent through their built-in checks. Leave their Additional Consent Checks at Not set or No additional consent required, because Google says extra checks on Google tags stop consent mode working properly (unblock Google tags when using consent mode). Require consent on non-Google tags such as a Meta Pixel. The full setup is in Consent Mode v2.
De-duplication: ways Typeform leads get counted twice
- Option A and option B together. Each pushes
typeform_submit. Pick one. - A second integration. If the form, a plugin or another tag already sends submissions to the same GA4 property, you get two events per lead. Search the page source and the GTM container for
typeform, and check DebugView for two events per test submission. - Chained forms. Each form in a chain reports its own submit. Filter on the final
form_id(step 2). - Ads import plus Ads tag, both primary. Set one to secondary.
Step 7: Test it end to end
- Click Preview in GTM, enter the page with the form and connect Tag Assistant (preview and debug containers).
- Submit a real test response with throwaway answers.
- In Tag Assistant, click the
typeform_submitevent. The GA4 tag (and the Ads tag, if you used that route) should be under Tags Fired, once. - In GA4 Admin, Data display, DebugView, confirm one
generate_leadarrived withform_id. Tag Assistant preview turns on debug mode. - Delete the test response in Typeform so it doesn't pollute your lead list.
While building, the SDK's enableSandbox option (data-tf-enable-sandbox) can help. The README says it disables submissions and tracking, and that callbacks receive responseId with the value "__sandbox". Use it to check the dataLayer push without creating real responses, then remove it, and run the final test without it.
If nothing reaches the dataLayer in option A, check that the function exists on window before embed.js runs. In option B, log e.origin and compare it with your allowed list. If GA4 has the lead but Google Ads does not, see why Google Ads conversions are not tracking.
When this approach does not apply
- Links to the form. If a button opens
form.typeform.com/to/...in a new tab, the submission happens on Typeform's site, where your container is not. Embed the form instead, or, if your Typeform plan offers redirect on completion, send respondents to a thank-you page on your site and track that page. - A plain iframe pasted by hand. The callbacks belong to the Embed SDK, and its docs don't say whether a typeform loaded without the SDK sends any message. Swap to the official embed, or log
messageevents (option B with the log line) and see what arrives. - Embeds wrapped by another tool. If a page builder places the typeform inside its own iframe, the message may never reach the top window where GTM runs. Test in Tag Assistant first.
When to get help
When each Typeform lead becomes one number in GA4 and one in Google Ads, you can see which campaigns produce form leads, and bidding learns from real ones. If you'd rather not touch the embed or the container, our conversion tracking services set up form and booking embeds like this one, and the Tracking Audit checks every lead flow on your site end to end and lists what to fix first.
Quick checklist
- Official Typeform embed, not a link or a hand-made iframe
- One hook:
onSubmitcallback defined beforeembed.js, or a GTM listener with an origin check typeform_submitpushed once, withform_idonly, no answers or personal data- Custom Event trigger, filtered to lead forms and the last form in a chain
- GA4 event marked as key event, one Ads route primary
- URL parameters (formerly hidden fields) for UTMs and click ID, checked on a test response
- Test submission seen once in Tag Assistant and DebugView, then deleted