Passing URL Parameters to iframe

Follow

If a landing page contains an iframe in an HTML/JavaScript block, you can pass the landing page's own URL query parameters through to the iframe's source. This is useful when the embedded page needs to read values, such as tracking parameters, from the parent URL.

This uses custom JavaScript and is not an official Unbounce feature. Test it on a published page before relying on it.

Pass the parameters to the iframe

Give your iframe an id, leave its src empty, and set the source on page load. Replace the base URL with the address you want to load inside the iframe:

<iframe id="iframe" src="" width="100%" height="800" frameborder="0"></iframe>

<script>
  var baseUrl = 'https://your-embedded-page.com/';
  var params = window.location.search; // the parent page's query string, including the leading "?"
  document.getElementById('iframe').src = baseUrl + params;
</script>

When the page loads, the iframe's src becomes your base URL followed by whatever query string was on the landing page URL.