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.
- Ad clickURL has utm_source and gclid
- Parent pageParameters visible in the address bar
- Iframe formLoads its own URL with no parameters
- Lead in CRMSource fields empty
- 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
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
Open a tagged URL
Visit your page with
?utm_source=test&utm_medium=manual&utm_campaign=iframe_check&gclid=TEST123added to the URL.Inspect the iframe
Right-click the form, choose Inspect, and find the
<iframe>tag. Check whether itssrccontains your parameters.Submit a test lead
Use a clearly fake name and an email you control.
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
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();
});
});<iframe data-pass-params src="https://forms.example.com/widget/form/abc123" width="100%" height="700" style="border:0"></iframe>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.
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.
Add the script
Add it in the footer with a header and footer plugin or your theme's custom code area.
Mark the iframe
Use a Custom HTML block for the embed so you can add data-pass-params.
Use an Embed element
Paste the iframe into an Embed element with data-pass-params.
Add the script
Put the script in Page settings, Custom code, before the body tag.
Create a Custom HTML tag
Paste the script inside script tags and fire it on All Pages or the landing pages.
Check timing
If the iframe loads before the tag runs, the change reloads it. Prefer adding the params in the page code where possible.
Build the src on the server or in JS
Append the incoming query string to the iframe src when you render it, or use the script above.
How to confirm it's fixed
Reload the tagged URL
Open the page with test UTMs and a fake gclid value.
Inspect the iframe src
It should now include the same parameters.
Submit a test lead
Check that source, campaign and click ID fields are filled in the CRM.
Test without parameters
Visit the plain URL and confirm the form still loads and submits.
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
- 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.
Related issues
- TRK-312UTMs lost when moving from landing page to form pageFix guide
- TRK-311UTMs lost on redirect (http->https, www, trailing slash)Fix guide
- TRK-313UTMs lost crossing to checkout / booking domainFix guide
- TRK-334Server redirects drop query string (301 to /)Fix guide
- TRK-317UTMs overwritten by internal links with utm tagsFix guide
- TRK-329Direct traffic inflated by missing UTMs on emails/SMSFix guide