Forms are usually chosen for reasons that have little to do with measurement. The CRM already in place, the design options, the price of the licence or how quickly the marketing team can publish a new landing page tend to drive the decision.
Tracking enters the conversation only later, often when the campaigns are already live and someone asks why leads in the CRM do not match the conversions reported in Google Ads or GA4. At that point, the form is in production, the integrations are built and changing course is expensive.
In our work as a digital agency, a large share of the tracking problems we are asked to fix come from one specific decision: embedding the form inside an iframe.
The form you choose defines what you will be able to measure, and how cleanly. It is worth treating it as a tracking decision from day one.
Why iframes get in the way
To see why, it helps to know how an iframe works. In short, iframes load one web page inside another. It is a convenient way for form providers to deliver their product: paste an embed code and the form appears on your site, hosted and maintained by them. The catch is that the iframe is, by design, an isolated document.
That isolation is a security feature. Browsers apply the same-origin policy, which stops the parent page from reading or interacting with content served from a different domain. This is what prevents a website from reading what you type into an embedded bank or login form. It protects users, but it also keeps your tag manager out of the form.
For tracking, this has three practical consequences:
The parent page cannot see what happens inside
The tag manager on your website cannot listen to clicks, field interactions or submissions inside the iframe. Built-in triggers such as form submission or element visibility simply do not reach it. From the parent page, the form is a closed box.
The dataLayer is not shared
The iframe has its own window and, if anything, its own dataLayer. Events pushed there are invisible to the Google Tag Manager container on the parent page, and variables available on your site, such as page context or campaign parameters, are not available inside the form.
Tracking inside the iframe creates new problems
The intuitive fix is to place Google Tag Manager or a measurement script inside the iframe itself, where the provider allows it. This usually trades one problem for another. Hits sent from the iframe carry the iframe’s URL as the page location, so reports start filling with form provider domains. Cookies may be partitioned or blocked as third-party, which means the iframe often starts its own session, separate from the one on the parent page.
The result is duplicated sessions, broken attribution and conversions credited to referral or direct traffic rather than to the campaign that brought the user in. Measuring the form becomes possible, but the data around it stops being reliable.
The preferred option: forms rendered on the page
Our recommendation is to avoid iframe forms wherever possible.
Instead of an iframe, use a form rendered directly in the page’s HTML. Whether it is native to the CMS or injected by the provider’s JavaScript, it lives in the same document as your tag manager. Triggers can see it, variables can read it and the session continues uninterrupted.
Being on the page is only half of it. The form also needs to tell your tag manager when someone starts or submits it. In order of preference, look for forms that:
- Emit their own events to the dataLayer, such as form start, form submission or a successful submission, with useful parameters like form ID or name
- Allow custom scripts or callbacks to run on form start and on successful submission, so you can push your own events
- Redirect to a trackable, dedicated thank-you page, which is a reliable fallback when nothing else is available
If a form offers none of these and only shows an inline success message, the tracking has to rely on DOM changes or button clicks. Both approaches are fragile: a click is not a submission, and a redesign can break the setup without anyone noticing.
When the iframe cannot be avoided
Sometimes the iframe is not negotiable. The form is tied to a CRM or marketing automation platform that the business depends on, or the provider only offers an embedded version. In that case, the key question is whether the form lets you run your own code when the submission is completed.
HubSpot and Salesforce Marketing Cloud Account Engagement (formerly Pardot) are two common examples where it does, each with a different approach: HubSpot lets you push events to the dataLayer, while Pardot relies on postMessage to talk to the parent page.
Pushing events to the dataLayer
HubSpot forms expose submission callbacks and events that a script can listen to.
This makes it possible to push a custom event to the parent page’s dataLayer when a form is submitted, including parameters such as the form ID. Google Tag Manager can then use that event as a trigger for GA4, Google Ads, Meta or any other platform, without placing any tags inside the form itself.
Sending messages to the parent page with postMessage
Pardot forms are typically embedded in an iframe hosted on the Pardot domain. They allow custom code in the thank-you content (Completion Actions), which runs inside the iframe after a successful submission. From there, a script can use the browser’s postMessage method to send a message to the parent window. A listener on the parent page receives it, validates the origin and pushes the corresponding event to the dataLayer.
postMessage is effective because it is the browser’s allowed way for documents on different origins to talk to each other. It works around the isolation of the iframe without disabling any security control, and it keeps all tracking on the parent page, so sessions, attribution and page URLs stay clean.
The compliance grey zone
postMessage solves the technical problem, but the legal risk depends on what the message carries. If it only signals that a form was submitted, there is little to worry about. If it also includes what the user typed, such as an email address or phone number, personal data is leaving the form, and that needs a closer look.
Enhanced conversions in Google Ads and similar features in other platforms rely on user-provided data, such as email address or phone number, to improve matching. Using it with an iframe form means personal data travels from the form provider’s domain to yours, and then on to advertising platforms.
This is not automatically unlawful, but it is not automatically compliant either. Whether it is acceptable depends on the consent collected, the purposes declared in your privacy policy, the agreements in place with the form provider and the advertising platforms, and how the data is handled along the way.
In practice, that means putting a few safeguards in place before implementing it:
- Review the setup with a legal or privacy specialist, especially under GDPR
- Send only the minimum data required, and only after the relevant consent has been granted
- Hash user data (for example, SHA-256 of a normalised email) inside the iframe before it leaves, so raw values never reach the parent page
- Restrict the target origin in postMessage and validate the sender’s origin in the listener, so messages cannot be read or spoofed by other scripts
Questions to ask before choosing a form
The point is not that one tool is right and another is wrong. It is that each option comes with tracking and compliance consequences, and those should be known before the contract is signed.
Here is a short set of questions to put to any form provider:
- Is the form rendered on the page or inside an iframe?
- Does it push events to the dataLayer natively, and which ones?
- Can custom scripts run on form start and on successful submission?
- Can it redirect to a thank-you page on our own domain?
- If it uses an iframe, can it send messages to the parent page, and what data would those messages contain?
- How does it handle consent, and can it read the consent state from our consent management platform?
If the answers are mostly no, it is reasonable to expect gaps in conversion data, more manual workarounds and a harder conversation with your legal team later.
How we can help
At All Around, we have worked through this situation multiple times: iframe forms that broke attribution, duplicated sessions inflating traffic, conversions that never reached Google Ads and postMessage setups that needed a privacy review before going live.
That experience lets us help at both ends of the process:
- Before the decision, we can assess the form options you are considering against your tracking and compliance requirements, so you choose a tool that fits your measurement needs as well as your CRM.
- After the decision, we can design and implement the tracking, whether that means native dataLayer events, custom callbacks or a postMessage bridge with the right safeguards in place.
Are you about to choose a form provider, or struggling to measure the one you already have? Get in touch and we will find the best setup for your case together.









