Here's a Q for you:
We have a series of LPs that are unique templates only used for these stand-alone campaigns, so we created them in the LP editor as opposed to creating templates. They're for digital ads, so there's a many-to-one relationship with the places pointing to the ads, the products the ads reference and the ads (many products to one ad).
We need to populate the product interest at the time of record creation because we have to. Don't ask. Can't do it in a workflow later, it causes problems.
The only way we can see as being able to do this is to pass the product name in a URL parameter. Problem is that the product names were developed with spaces and slashes and other non-HTML friendly characters and there's no way to decode those prior to plopping in the form.
Is there a way to utilize the Forms 2.0 embedded features, such as form.vals on a LP created page? If I can use JS I could decode the param prior to setting the hidden field to that value. But I'm not sure if that'll work or not since I'm not doing a full-on embed for the form.
Any suggestions?
Solved! Go to Solution.
Hi Robb,
Not necessarily,
You can append some JS to a "normal" form in a Marketo LP. This is done adding a <script> at the end of the LP:
<script>
MktoForms2.whenReady(function (form) {
// Put your code that uses the form object here
});
</script>
-Greg
Hi Robb,
Yes of course, you can use the form API to set field values in the form. See this example from the forms 2.0 API doc:
MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) {
// Set the value of the Phone and Country fields
form.vals({ "Phone":"555-555-1234", "Country":"USA"});
});
You could even imagine to pass a code in the URL and convert that code in a full length product name.
Best regards,
Grégoire
Yeah, I figured this is the case, I was just wondering if it's possible without rebuilding the page with an embedded form.
Hi Robb,
I do not understand. You can add the additional script on the LP, without an embedded form, if you are on a Marketo LP.
-Greg
I'm under the impression that to do this I'm deleting the form that's already there and replacing it with a code snippet. Are you saying this isn't the case?
Hi Robb,
Not necessarily,
You can append some JS to a "normal" form in a Marketo LP. This is done adding a <script> at the end of the LP:
<script>
MktoForms2.whenReady(function (form) {
// Put your code that uses the form object here
});
</script>
-Greg
Yep -- Robb, all my forms demos use whenReady, which works for both embedded forms and named Form elements.