Forms 2.0 Success Message on Embedded Form | Community
Skip to main content
Natalie_Delinsk
New Participant
August 6, 2019
Question

Forms 2.0 Success Message on Embedded Form

  • August 6, 2019
  • 1 reply
  • 2870 views

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‌

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
New Participant
August 6, 2019

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;
});
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Iason_Kubrakov
New Participant
April 29, 2020

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!