Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Iframe checkout tracking not reaching the parent page: fix

TRK-401Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Some checkouts, booking tools and payment pages are shown inside an <iframe> on your own site. The iframe loads a page from another origin (a different domain or subdomain), such as a hosted checkout or a funnel tool.

Browsers keep that frame separate from the parent page. The parent's GA4, Google Ads or Meta tags cannot read the frame's content or its data layer. The frame's own tags, if any, may run with a different client ID and no knowledge of the ad click that brought the visitor.

The result is that the purchase or generate_lead event is missing, is sent with the wrong session, or shows up as direct traffic.

Why it costs you leads or sales

The sale still happens, but your ad platforms do not hear about it. Smart bidding in Google Ads and Meta's delivery learn from conversions. If they see fewer than really occurred, they optimise on weak data and your cost per result looks worse than it is.

Reports also mislead you. Paid campaigns look like they sell nothing, while revenue piles up under direct or referral traffic. You may cut budget from the channels that actually work.

Where the signal is lost
  1. Ad clickVisitor lands with gclid and UTMs
  2. Parent pageTags fire, page_view recorded
  3. Iframe checkoutSeparate origin, no link to the parent session
  4. Purchase eventNot sent, or sent without the ad source
  5. Ad platformConversion never credited

The parent page tracks the visit, but the purchase inside the iframe never reaches it.

Purchases reported vs real purchasesExample numbers
Purchases reported vs real purchases (example)Real purchases: 100 purchases; Reported in GA4: 55 purchases; Credited to paid ads: 20 purchases038771005520Real purchasesReported in GA4Credited to paid adspurchases

Example: 100 real purchases a week. With the iframe unlinked, only some are reported, and fewer still carry the ad source.

How to check if your site has it

Quick checks
  • Open the checkout page and look in the browser's developer tools (Elements tab) for an <iframe> whose src is another domain.
  • Complete a test order and watch the Network tab for GA4 (collect) and ad platform requests. Note which come from the parent and which from the iframe.
  • In GA4 Realtime or DebugView, check whether the purchase appears and which source and medium it shows.
  • Compare orders in your store or payment tool with purchases in GA4 and Google Ads for the same days.
  • Check whether the client ID (_ga cookie) on the parent matches the one used in the iframe requests.
  • Look at your referral list in GA4 for the checkout domain. If it appears, sessions are being split.

How to fix it

There are two routes. Best is to have the iframe send a message to the parent, which then fires the tags with the parent's full session. The second is to track inside the iframe and link its session to the parent. You need control of the iframe's code or settings for either one. If the provider is a hosted tool, check its documentation for a supported event or parameter option.

Fix with postMessage
  1. Decide who owns the tags

    Prefer firing conversion tags on the parent, where the ad click data and consent state already live.

  2. Send a message from the iframe

    On the order confirmation view inside the iframe, call window.parent.postMessage with the event name, order ID, value and currency. Always set the parent's exact origin, never '*'.

  3. Listen on the parent

    Add a message listener on the parent page. Check event.origin against the checkout domain, then push the data to the data layer.

  4. Fire tags from the data layer event

    Create a trigger for your custom event and attach the GA4 purchase, Google Ads conversion and Meta tags to it.

  5. Prevent double counting

    Turn off duplicate purchase tags inside the iframe, or pass the same transaction ID so platforms can deduplicate.

Inside the iframe (confirmation view)javascript
window.parent.postMessage({
  type: 'checkout_complete',
  transaction_id: 'ORDER-12345',
  value: 59.00,
  currency: 'USD'
}, 'https://www.yourstore.com');
On the parent pagejavascript
window.dataLayer = window.dataLayer || [];
window.addEventListener('message', function (event) {
  if (event.origin !== 'https://checkout.example.com') return;
  var d = event.data;
  if (!d || d.type !== 'checkout_complete') return;
  window.dataLayer.push({
    event: 'purchase_from_iframe',
    ecommerce: {
      transaction_id: d.transaction_id,
      value: d.value,
      currency: d.currency
    }
  });
});
Set it up on your platform
  1. Add the listener

    Create a Custom HTML tag with the parent listener code, triggered on All Pages (or the checkout page only).

  2. Create a Custom Event trigger

    Set the event name to purchase_from_iframe.

  3. Read the values

    Create Data Layer Variables for ecommerce.transaction_id, ecommerce.value and ecommerce.currency, then use them in your GA4 event, Ads conversion and Meta tags.

  4. Test in Preview

    Run a test order in Tag Assistant and confirm the tags fire once on the parent.

How to confirm it's fixed

Verify with a test order
  1. Run a test purchase

    Use the provider's test mode or a low-value order you can refund. Enter the site from a tagged link such as ?utm_source=test&utm_medium=check.

  2. Watch the data layer

    In GTM Preview or the console, confirm the purchase_from_iframe event arrives on the parent once.

  3. Check GA4 DebugView

    The purchase should show the transaction ID, value and the test source and medium, not direct.

  4. Check ad platforms

    Look in Google Ads conversion diagnostics and Meta Events Manager for the event within the expected delay.

Before and after

Broken

  • Purchase happens in the iframe only
  • Parent tags never hear about it
  • Orders show as direct or are missing

Fixed

  • Iframe posts a message on confirmation
  • Parent fires tags with the full session
  • Orders carry the right source and value

How to prevent it happening again

Keep it working
  • Document who owns the iframe code and the parent listener.
  • Re-test a full order after any change to the checkout provider, theme, tag manager container or consent banner.
  • Keep the message format (event name and field names) fixed and versioned.
  • Compare store orders with GA4 purchases weekly and investigate gaps.
  • Add the checkout domain to GA4 unwanted referrals or cross-domain settings if it appears as a referrer.
  • Schedule an automated test of the whole journey so a break is noticed within a day.

How FunnelGuard handles this

FunnelGuard detects this issue only partly. A robot visitor runs your checkout journey on a schedule, from the EU or the US, and checks the steps and the tracking hits sent to GA4, Google Ads, Meta and other platforms. If the expected hit does not arrive, the failure is re-checked from a second region and you get one alert with a screenshot and a likely cause.

Questions people ask

Why is my iframe checkout not tracking purchases in GA4?

The iframe is a separate page context from a different origin, so tags on your parent page cannot see inside it. If the iframe has no GA4 tag, or one with a different client ID, the purchase is missing or split from the original session. Send the event to the parent with postMessage, or link the sessions with cross-domain settings.

Can Google Tag Manager on the parent page track events inside an iframe?

No. GTM on the parent cannot read the iframe's clicks, DOM or data layer when it is on another origin. The iframe has to send the data out, usually with postMessage, or run its own tags.

How do I send a purchase event from an iframe to the parent page?

Call window.parent.postMessage with the order details and the parent's exact origin from the iframe confirmation view. On the parent, add a message listener, verify event.origin, and push the data to the data layer to trigger your tags.

Why do iframe checkout sales show as direct traffic?

The iframe session starts without the parent's cookies or the ad click parameters, so GA4 sees a fresh visit. Fire the purchase on the parent, or add the checkout domain to GA4 cross-domain settings so the client ID carries across.

Is it safe to use postMessage with a wildcard origin?

No. A '*' target lets any page that embeds the frame read the message, which may include order values or identifiers. Use the exact parent origin when sending, and check event.origin when receiving.

Will I count purchases twice if both the iframe and the parent have tags?

Yes, it can happen. Keep purchase tags in one place, or send the same transaction ID from both so GA4 and the ad platforms can deduplicate. Test with one order and check that it appears once.

Can FunnelGuard check my iframe checkout tracking?

Partly. It runs your checkout journey on a schedule and checks tracking hits to ad and analytics platforms, alerting you when expected hits are missing. It does not verify your postMessage design or whether real purchases are credited to the right campaign, so keep doing manual test orders.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.