AnsweredAssumed Answered

Passing a utm to a form in an iframe

Question asked by b046db3e1a842f19394234e3d0f0af8cfdbdee8b on Jan 27, 2014
Latest reply on Mar 12, 2014 by b046db3e1a842f19394234e3d0f0af8cfdbdee8b
Hi All,

I have read through this article from Marketo on passing utms parameters to a form in an iframe and to be honest it doesn't give enough information.

https://community.marketo.com/MarketoResource?id=kA650000000GuKCCA0

I want to know where in the js does it say the field in the database this feeds to? I don't want it to go to leadsource as we populate this a different way. I want to have it populate utm_campaign, utm_source field etc I have set up in the database. 

The script says to duplicate the yellow section but it doesn't tell you what to amend.

Has anyone done this?

Here is the script below I have amended but I don't know where to change the fields it goes into:

<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)["source"];
    $("#LeadSource").val(sourceParam);
    var sourceParam = getUrlVars(url)["medium"];
    $("#LeadSource").val(mediumParam);
    var sourceParam = getUrlVars(url)["campaign"];
    $("#LeadSource").val(campaignParam);
    var sourceParam = getUrlVars(url)["term"];
    $("#LeadSource").val(termParam);
 
 
  })
   
  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>
 

Outcomes