You place the custom forms JS in a <script> block directly after the standard embed code.
That's what I did initially but my simple test did not work.
I find that after filling out the embedded form the formredirect field remains NULL (although it updates correctly when on a marketo landing page). Am I missing something? Here's what I've embedded
<script src="//app-sj20.marketo.com/js/forms2/js/forms2.min.js">
</script>
<form id="mktoForm_1232"></form>
<script>MktoForms2.loadForm("//app-sj20.marketo.com", "530-RLQ-870", 1232);</script>
<script>
MktoForms2.whenReady(function(form){
form.onSubmit(function(form){
form.addHiddenFields({ formredirect : a_different_value)});
});
});
</script>
For the record this is up and running now small issue on the word press side of things. Thanks Sanford.
Hi Sanford,
I am trying to use this script but find that it is not consolidating the values and inserting them into the hidden field. The hidden field (mkto_AscentTest_4) is in the form and has string as its data value. Here is the code that I am using.
MktoForms2.whenReady(function(form){
form.onSubmit(function(form){
var currentValues = form.getValues(),
fieldsToConsolidate = ["mkto_AscentTest_1","mkto_AscentTest_2","mkto_AscentTest_3"],
mkto_AscentTest_4 =
fieldsToConsolidate
.map(function(field){
return currentValues[field];
})
.join(";");
form.addHiddenFields({ mkto_AscentTest_4 : mkto_AscentTest_4 });
});
});
Any thoughts?
Please provide your URL. The code on its own is fine.
Here is the link to the page.
You're using the wrong field names. The prefix "mkto_" doesn't exist on those fields, and they don't have underscores.
Thank you Sanford, that worked. However, I am confused on about this. In my instance the field names do have mkto_ in them. Below is a screenshot of the fields in the database.
And when I go to edit the form, the field names are consistent.
Is it because I am embedding the code on my site that the names change? Maybe beyond the scope of this thread but curious. As always, thanks for the help.
The form fields will be the SOAP field names (as opposed to the friendly names). So export all your fields from Field Management, check the SOAP column, and you'll always be accurate.