Fill Marketo Form using Tokens/URL Parameters
Hello,
We are trying to ensure a form is filled with the Marketo tokens rather than Pre-fill data when someone clicks on the landing page link in an email. I've read a few posts about this but can't seem to get the hidden fields and JS code to work.
The first field in my form is mapped to Email Address and I want it to populate the email in Marketo database (some visitors are seeing pre-fill info that doesn't match their Marketo email address).
I've created a hidden email field named renewEmailAddress and set the autofill to URL paramater: email. Would my JS code then look like the below? And would the link in the email would then look like https://example.com?email={{Lead.Email Address}}? I don't think I'm putting the JS code in the right location and/or I'm using the wrong "source" and taget names in the code itself.
// Set your proxy (hidden) field to visible field mappings
var proxySources = [
{
source : "renewEmailAddress",
target : "Email Address",
readOnly : false
}
];
// --- No need to touch below this line! ---
var formEl = form.getFormElem()[0],
readyValues = form.getValues(),
mktoFieldsObj = {},
arrayFrom = Array.from || Function.prototype.call.bind(Array.prototype.slice);
proxySources
.filter(function(proxy){
return !!readyValues[proxy.source];
})
.forEach(function(proxy){
var fieldEls;
mktoFieldsObj[proxy.target] = readyValues[proxy.source];
if (proxy.readOnly) {
fieldEls = formEl.querySelectorAll('[name="' + proxy.target + '"]');
arrayFrom(fieldEls)
.forEach(function(el){
el.readOnly = el.disabled = true;
});
}
});
form.setValues(mktoFieldsObj);
@@@});
Message was edited by: Audreon Babb