4 Replies Latest reply on Feb 11, 2015 10:38 AM by 64828

    URL parameters

    Gareth Flower
      Can I pass an e-mail address or lead ID to a landing form as a URL parameter, so that it populates the form with the relevant lead data (rather than pulling the info from a cookie)?
        • Re: URL parameters
          Kenny Elkington
          Hey Gareth,

          You can do this natively with hidden fields like this(https://community.marketo.com/MarketoArticle?id=kA050000000LH7uCAG).  For visible fields you need to use some JS with forms 2 api.  This snippet will do that with a parameter called 'Email' and map it to your forms' email field:

               //function to make query parematers into an associative array
                 function getUrlVars(url) {
                   var vars = [],
                   var hashes = url.slice(url.indexOf('?') + 1).split('&');
                   for (var i = 0; i < hashes.length; i++) {
                       hash = hashes[i].split('=');
                       vars[hash[0]] = hash[1];
                   return vars;
               MktoForms2.whenReady( function(form) {
               var urlEmail = getUrlVars(location.href)['Email'];//get Email from URL
               form.vals( {"Email":urlEmail} );//set value in Email field
          • Re: URL parameters
            Josh Hill
            Some folks think that using the email address or LeadID like this is a security risk, so just be aware of that.
            • Re: URL parameters
              I had an issue with this script, but was able to get it to work with the following change. I'm not a javascript guy, so don't expect a good explanation of what exactly it did. :)

              var hashes = url.slice(url.indexOf('?') + 1).split('&');

               var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
              • Re: URL parameters
                How do you get the lead data based on the email address provided?  I am trying to build an email subscription landing page that will prepoulate the form based on the email parameter in the url, not from the cookie.