Re: URL Parameter with Forms 2.0 in iFrame

Tonya_Austin
Level 2

URL Parameter with Forms 2.0 in iFrame

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!
Tags (1)
1 REPLY 1
Grant_Booth
Level 10

Re: URL Parameter with Forms 2.0 in iFrame

This other discussion has some insight (see Kenny's third comment):
https://community.marketo.com/MarketoDiscussionDetail?id=90650000000PrHrAAK

In that discussion, the "referrer" they are referring to is actually a URL parameter in that particular use case.