Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Iframe forms losing UTMs from the parent page: how to fix it

TRK-332High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

An iframe is a window that loads another web page inside your page. Many form, booking and chat tools (GoHighLevel, HubSpot, Typeform, Calendly and others) are embedded this way. The iframe has its own URL, for example https://forms.example.com/widget/form/abc123.

Where the UTMs disappear
  1. Ad clickURL has utm_source and gclid
  2. Parent pageParameters visible in the address bar
  3. Iframe formLoads its own URL with no parameters
  4. Lead in CRMSource fields empty
  5. Ad reportingLead counted as direct or not matched

The parent page has the tags, the iframe never receives them.

Why it costs you leads or sales

Where form leads are attributedExample numbers
Where form leads are attributed (example)Before fix: 8 % of leads; After fix: 90 % of leads03469890Before fixAfter fix% of leads

Example: share of 100 form leads with a known campaign before and after passing UTMs into the iframe.

How to check if your site has it

Test it by hand in five minutes
  1. Open a tagged URL

    Visit your page with ?utm_source=test&utm_medium=manual&utm_campaign=iframe_check&gclid=TEST123 added to the URL.

  2. Inspect the iframe

    Right-click the form, choose Inspect, and find the <iframe> tag. Check whether its src contains your parameters.

  3. Submit a test lead

    Use a clearly fake name and an email you control.

  4. Read the saved lead

    Open the lead in your CRM or form tool and look at the source, campaign and click ID fields. If they are blank, the parameters were lost.

How to fix it

Copy the parent query string onto the iframe srcjavascript
document.addEventListener('DOMContentLoaded', function () {
  var params = window.location.search;
  if (!params) return;
  document.querySelectorAll('iframe[data-pass-params]').forEach(function (frame) {
    var url = new URL(frame.src);
    new URLSearchParams(params).forEach(function (value, key) {
      url.searchParams.set(key, value);
    });
    frame.src = url.toString();
  });
});
Mark the iframe so the script finds ithtml
<iframe data-pass-params src="https://forms.example.com/widget/form/abc123" width="100%" height="700" style="border:0"></iframe>
Where to make the change
  1. Add hidden fields

    In the form builder, add hidden fields named utm_source, utm_medium, utm_campaign and gclid. Hidden fields can pick up values from the iframe URL.

  2. Pass the parent query string

    Add the script above to the page's custom code and put data-pass-params on the embed code's iframe.

How to confirm it's fixed

Verify the fix
  1. Reload the tagged URL

    Open the page with test UTMs and a fake gclid value.

  2. Inspect the iframe src

    It should now include the same parameters.

  3. Submit a test lead

    Check that source, campaign and click ID fields are filled in the CRM.

  4. Test without parameters

    Visit the plain URL and confirm the form still loads and submits.

Lead record before and after

Before

  • utm_source: empty
  • utm_campaign: empty
  • gclid: empty
  • Reported as direct

After

  • utm_source: google
  • utm_campaign: spring
  • gclid: saved
  • Matched to the campaign

How to prevent it happening again

Keep it working
  • Re-test with a tagged URL whenever you change the form, the embed code or the page template.
  • Keep hidden field names identical to the parameter names.
  • Re-add data-pass-params if you replace the embed.
  • Re-test after theme, builder or form tool updates.
  • Add a source field check to your lead review routine.

How FunnelGuard handles this

Questions people ask

Why is my iframe form not capturing UTM parameters?

The iframe loads its own URL, which doesn't contain the parent page's query string. The form therefore can't read the UTMs. Pass the parameters onto the iframe src or send them with postMessage, and map them to hidden fields.

How do I pass UTM parameters to an iframe?

Read window.location.search on the parent page and append it to the iframe's src before or just after it loads. Then add hidden fields in the form that match the parameter names. Test with a tagged URL.

Can an iframe read the parent page URL?

Not directly when the iframe is on another domain, because browsers block cross-origin access. The parent has to pass the values in, through the src or postMessage. Some tools also read document.referrer, which is less reliable.

Why do my embedded form leads show as direct traffic?

The lead was saved without UTMs or a click ID, so there is nothing to attribute it to. Analytics may also start a new session inside the iframe. Passing the parameters into the form fixes the lead record.

Does the gclid also get lost in an iframe form?

Yes, the same way. If the gclid isn't passed into the iframe and saved in a hidden field, you can't use it for offline conversion matching. Treat it like any other parameter.

Is it better to use postMessage or the iframe src?

The src method is simpler and works when the form tool reads URL parameters. Use postMessage only if the tool documents that it accepts messages from the parent page. Follow your tool's documentation.

Does FunnelGuard detect iframe forms losing UTMs?

Only partly. It can run journeys through iframe forms and check submissions, tracking hits and lead delivery, but it doesn't check that the parent UTMs are passed into the iframe. Check that by hand with a tagged test URL.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: iframe forms supported; param pass not checked.

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.