Hi Sanford!
If we went with the {{my.token}} route, in the code you provided earlier, we could have "Product Interest" in place of "SomeField" can it be in any format or does it need to the the API name of field? then, "some value" could be the {{my.token}} and we can populate the values at the local program level? Where does the code below get added into the LP template?
MktoForms2.whenReady(function(readyForm){
readyForm.setValues({
SomeField: "some value"
});
});
In the other option of the query param or segment of the URL path, how do we set it up so that it is pulling some value from these into for example the Product Interest so the value is already showing on page load? Could you show some screenshots or explain in further detail? we could train our teams to name their landing page URL in a specific format, but how would we be able to accurately pull that value into the Product Interest checkbox?
The most flexible way as you mentioned is <meta> tags. We haven't utilized this very much and not sure how to get started with this. Is it something we update on the LP templates, or can we use it on the Edit Page Meta in the LP editor?
Thanks for the ideas! First time trying to achieve this form default value setup.
If we went with the {{my.token}} route, in the code you provided earlier, we could have "Product Interest" in place of "SomeField" can it be in any format or does it need to the the API name of field?
It needs to be the SOAP API name of the field, which is the same as the form field <input> name.
"some value" could be the {{my.token}} and we can populate the values at the local program level?
Yes, but you can’t just output the {{my.token}} directly into the JS. You need to output it into a <datalist><option> and then read it from there. Like so:
<datalist id="marketo-tokens">
<option name="my.Product Interest">{{my.Product Interest}}</option>
</datalist>
<script>
MktoForms2.whenReady(function(readyForm){
const marketoTokens = document.querySelector("datalist#marketo-tokens").options;
readyForm.setValues({
ProductInterest: marketoTokens["my.Product Interest"].value
});
});
</script>
Where does the code below get added into the LP template?
Just before the closing </body> tag.
In the other option of the query param or segment of the URL path, how do we set it up so that it is pulling some value from these into for example the Product Interest so the value is already showing on page load? Could you show some screenshots or explain in further detail
If the query parameter is productInterest then you’d pull it like so:
MktoForms2.whenReady(function(readyForm){
const currentURL = new URL(document.location.href)
readyForm.setValues({
ProductInterest: currentURL.searchParams.get("ProductInterest")
});
});
The most flexible way as you mentioned is <meta> tags. We haven't utilized this very much and not sure how to get started with this. Is it something we update on the LP templates, or can we use it on the Edit Page Meta in the LP editor?
You would put them on the LP template, then fill them from variables at the LP level.