How to pass URL parameters to a form in an iframe

Document created by 9588451ecc601f1a2620c0a3338f73ddec06dbf4 Employee on Dec 8, 2014Last modified by 9588451ecc601f1a2620c0a3338f73ddec06dbf4 Employee on Sep 27, 2017
Version 4Show Document
  • View in full screen mode
This solution will ONLY work with Forms 1.0.


Some customers put Landing Pages in an iFrame on their public website. In this case, URL parameters on the parent page are not passed down to the form.



Using JavaScript, you can pull the URL from the parent page.


Please ensure that you have access to an experienced JavaScript developer. Marketo Technical Support is not set up to assist with troubleshooting JavaScript.

Place Javascript on your Form Page


You can use Custom HTML or just put the following script in the template of the page that has the form on it.

<script src="//"></script> <!-- Keep your jQuery up to date --> 




$(function(){ var url = (window.location != window.parent.location) ? document.referrer: document.location;     var sourceParam = getUrlVars(url)["source"]; $("#LeadSource").val(sourceParam);


function getUrlVars(url) { var vars = [], hash; var hashes = url.slice(url.indexOf('?') + 1).split('&'); for (var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1];




   return vars;



You can repeat the lines in yellow if you have multiple parameters and form fields.

That's it! Give it a try and make sure to test!