1 Reply Latest reply on Sep 11, 2014 10:33 AM by Grant Booth

    URL Parameter with Forms 2.0 in iFrame

    Tonya Austin
      Hello All,
      I am hoping someone can help.  I implemented a solution using the script found here: (https://community.marketo.com/MarketoResource?id=kA650000000GuKCCA0) with my older forms buf found that it does not work with Forms 2.0.  Can anyone out there help me modify my script to make it work with Forms 2.0?

      Here is what I have right now:

           <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
           <!-- Keep your jQuery up to date -->
            
           <script>
            
             $(function(){
               var url = (window.location != window.parent.location) ? document.referrer: document.location;
               var sourceParam = getUrlVars(url)["leadsource"];
               $("#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;
             }
            
           </script>

           Any suggestions are greatly apprecaited!  Thanks!