Has anyone passed successfully url variables in non-marketo landing pages with forms?
I am trying to figure out how to pass these in a non-marketo landing pages that has a form. Trying to pass these variables as hidden fields in the forms.
First the url
http://www.yourdomain/?utm_medium=blog&utm_campaign=camptest&SFDCCampaignID=701a000ldlc&CampaignMemberStatus=sent
Here is the javascript
// to set cookies. Uses noConflict just in case
var $jQ = jQuery.noConflict();
<!-- A method from getting the url params using pure javascript. Taken from http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html-->
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.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;
}
<!-- Then use the fuction to get the param you want. -->
var params = getUrlVars();
var utm_medium = params["utm_medium"];
var utm_source = params["utm_source"];
var utm_campaign = params["utm_campaign"];
var SFDCcampaignID = params["SFDCCampaignID"];
var CampaignMemberStatus" = params["CampaignMemberStatus"];
<!-- This should identify the and set the inputs -->
document.querySelector("input[name='utm_medium']").value = utm_medium;
document.querySelector("input[name='utm_source']").value = utm_source;
document.querySelector("input[name='utm_campaign']").value = utm_campaign;
document.querySelector("input[name='SFDCCampaignID']").value = SFDCCampaignID;
document.querySelector("input[name='CampaignMemberStatus']").value = CampaignMemberStatus;
and here is the form input fields
<input type="hidden" name="utm_medium" id="utm_medium" />
<input type="hidden" name="utm_source" id="utm_source" />
<input type="hidden" name="utm_campaign" />
<input type="hidden" name="SFDCCampaignID" />
<input type="hidden" name="CampaignMemberStatus" />