Open Tracked/Guides/Iframe tracking

Iframe tracking

Content inside an iframe belongs to another page. To track it, ask the embed to tell you what happens, or put your own tracking inside it.

4 min read · Updated October 26, 2026

In this guide
Key takeaways
  • A page cannot see inside a cross-origin iframe. Events inside it are invisible to your tags unless the embed sends a message.
  • Use postMessage from the embed, or your own container inside the iframe if you control it.
  • Safari and others partition storage in iframes, so cookies and IDs behave differently.
PPage with iframePpostMessage from the embedEEvent in your analytics

Booking widgets, forms, video players and payment pages are often embedded in iframes. A form from another vendor may collect the leads that matter most, and your analytics sees nothing. This page explains why, and the ways to track what happens inside. It builds on multi-domain tracking and data validation.

Why it is hard

  • Same-origin policy. A page cannot read or listen to events inside an iframe from another origin.
  • Storage partitioning. Browsers limit cookies and storage inside third-party iframes. An ID set inside may not match the ID outside.
  • Referrers. The iframe's traffic often looks like a visit from your own page.
Check your setup

Check your tracking in one pass

This is an example. Run the check on your own site to see where yours stands.

The options

OptionHowWhen
The embed sends messagesThe vendor's script calls window.parent.postMessage with events; your page listens and pushes to the data layerThe vendor supports it (many form and booking tools do)
Your own tracking inside the iframeYou install Tag Manager inside the embedded pageYou control the embedded page
A redirect to a thank-you pageAfter the action, send the visitor to a page on your domainA simple, robust option for forms
Server-side webhookThe vendor calls your server when a lead or booking is madeYou need reliability and the vendor offers webhooks

Listen for postMessage

window.addEventListener("message", function (event) {
  // check the sender before trusting the message
  if (event.origin !== "https://forms.vendor.example") return;
  if (event.data && event.data.type === "form_submitted") {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({ event: "generate_lead", form_name: event.data.form });
  }
});

Always check event.origin. Never trust a message from an unknown sender, and never put personal data from a message into analytics.

Data in, clean out

Raw events in. Clean events out.

Open Tracked collects each event on your own domain, removes the noise and sends what is left to Meta, Google Ads, TikTok.

Cross-domain with iframes

If the iframe is on a domain you own, configure cross-domain measurement so the client ID is shared. If it is a vendor's domain, you cannot share the ID directly. In that case, rely on the thank-you redirect or a webhook to send the conversion from your server, with the identifiers saved on your page before the embed loads. See CRM data to Meta with webhooks.

Server-side route

A webhook from the form vendor to your tagging subdomain turns an invisible event into a server-side conversion. The container can then send it to Meta, Google Ads and GA4 with hashed customer data, with consent. Open Tracked hosts the tagging server, and its Data Store and Enricher can remember the hashed e-mail for later events.

Common problems

SymptomLeads are invisible
Likely causeThe form is in a cross-origin iframe.
FixUse postMessage, a redirect or a webhook.
SymptomSessions break after the embed
Likely causeThe payment or booking domain is different.
FixUse cross-domain settings or server-side purchase.
SymptomTwo page views are counted
Likely causeThe iframe has its own tag.
FixRemove it or filter by hostname.
SymptomConsent is not carried into the iframe
Likely causeThe embed does not know the choice.
FixPass consent to the embed if it supports it.
0 of 5 done
Try it

Works with your stack

Grab a logo and throw it. These are the tools Open Tracked already talks to.

Grab one. Throw it.

Frequently asked questions

Can I track events inside an iframe?

Not directly if it is cross-origin. Use postMessage, your own tracking inside it, a redirect or a webhook.

What is postMessage?

A browser feature that lets an iframe and its parent page send messages to each other.

Why do cookies behave differently in iframes?

Browsers partition storage in third-party iframes.

How do I track a form in an iframe?

Ask the vendor for a postMessage event, a redirect to your thank-you page or a webhook.

Is it safe to listen to messages?

Yes, if you check the origin and avoid putting personal data in analytics.

Do I need spreadsheets to read my results?

No. Once tracking is live, the Open Tracked analytics shows spend, revenue, ROAS and profit, and you can ask Ari, the built-in AI assistant, questions about your own numbers in plain words. Ari's allowance depends on your analytics plan.

Is Open Tracked different from Open Track or Open Space Track?

No. Open Tracked is the official name of our server-side tracking platform, and the website is opentracked.io. Many people search for it as Open Track, OpenTrack or Open Space Track. All of them lead to the same product: server-side Google Tag Manager hosting, first-party analytics and a CRM pipeline.

Fix your tracking at the source

Open Tracked hosts your server-side Tag Manager, keeps first-party cookies alive and shows what each ad is really worth.

Open Tracked
Written by

The Open Tracked team

We build Open Tracked: server-side tracking hosting, analytics and the tools around them, for stores that spend on ads. Questions about this guide, or an idea for the next one?

Write to us Read the docs

Was this article helpful?

Comments

Loading comments...

Turn better tracking into better marketing performance

Start free