Forms 2.0 Success Message on Embedded Form

Highlighted

Forms 2.0 Success Message on Embedded Form

Looking for help on how to add an OnSuccess message after a Marketo form submit on our website. We want to avoid a Marketo 'Thank You' LP so it doesn't break the session in GA.

The form submit results in a page reload and brings the user back to a new, blank form after submit in its current state... We want the submit button to trigger a Thank You message underneath so we can set up an element visibility trigger in GTM. What would the form's embedded code look like for this?

Any help is appreciated! Sanford Whiteman

2 REPLIES 2
Highlighted
Level 10 - Community Moderator

Re: Forms 2.0 Success Message on Embedded Form

You would add this code after the line that calls MktoForms2.loadForm() in the standard embed code:

MktoForms2.whenReady(function(form){
var formJq = form.getFormElem(),
formEl = formJq[0];

form.onSuccess(function(vals, tyUrl){
/*
Do whatever you want in here.
The page will not refresh/go to the configured Thank You URL in Marketo as long as you return false; from this onSuccess listener.
formJq is the jQuery (yuck) wrapper for the <form> element
formEl is the pure HTML DOM <form> element
*/

return false;
});
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Highlighted

Re: Forms 2.0 Success Message on Embedded Form

Dear Sanford,

 

We are using the code you proposed. However, it is not working since this spring. Can you please give any advise on this issue? Thanks!