Can pass query string value to Marketo form that's in an iframe? | Community
Skip to main content
Level 3
August 18, 2015
Solved

Can pass query string value to Marketo form that's in an iframe?

  • August 18, 2015
  • 1 reply
  • 1911 views

We have a form that captures the referrer value from the query string. The form has a hidden field for the referrer. It works HERE in a non-iframe situation.

We now want to use the iframe delivery method for a different form on a different page, so the form is loaded into a page on our web site via an iframe. I need it to capture the referrer (ref) value from the parent URL: i.e. xxx.com/static/400/?ref=DM

What script is required in the iframe page that has the form? Anything else?

Many thanks!

Best answer by SanfordWhiteman

Certainly it's possible operating fully within the IFRAME, and the building blocks were detailed by Dan Stevens on the discussion you just cross-posted to.

However, even easier -- if you control the outer page's code itself -- is to append the query param to the IFRAME src, so your form will see it like any other param.

In other words (pseudocode):

     NewIframe.src = 'pages.example.com/lp-with-form.html' + document.location.search;

Then you can use standard hidden fields, because the outer page's query string is also the IFRAME's query string.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
August 18, 2015

Certainly it's possible operating fully within the IFRAME, and the building blocks were detailed by Dan Stevens on the discussion you just cross-posted to.

However, even easier -- if you control the outer page's code itself -- is to append the query param to the IFRAME src, so your form will see it like any other param.

In other words (pseudocode):

     NewIframe.src = 'pages.example.com/lp-with-form.html' + document.location.search;

Then you can use standard hidden fields, because the outer page's query string is also the IFRAME's query string.