I'm interested in customing the URL to a follow up page based on the information submitted as part of a form on a landing page.
If I use the embed code for the form and insert it into a landing page using an HTML element, the followling works:
<script src="//app-sj04.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_2"></form>
<script>MktoForms2.loadForm("//app-sj04.marketo.com", "999-XXX-999", 2, function(form){
form.onSuccess(function(values, followUpUrl) {
// Do needed work here
window.location = followUpUrl + '?computed_query_parameters';
return false;
});
});</script>
This approach has a couple disadvantages. First, because I'm using the embed code, the form fields
do not prepopulate with data for known leads. Second, because an AJAX request is needed to load the details for the form, the form visually pops in a few hundred milliseconds after the page loads.
Since I am using this form on a Marketo landing page, what I would like to be able to do is insert the form into the landing page using the Form element so that pre-population of known lead information will happen, and the field details of the form will be populated on the server side so the form renders seemlessly with the webpage.
Is there a way to register Forms 2.0 API handlers like the above when using a form element? I haven't been able to find one. The closest I've seen is to try to hack things using jQuery to listen for submit events which doesn't really accomplish what I want.