onSuccess handler to follow-up page has stopped working | Community
Skip to main content
pmann-elementum
New Participant
June 8, 2022
Solved

onSuccess handler to follow-up page has stopped working

  • June 8, 2022
  • 1 reply
  • 4354 views

Does anyone know why my handler has stopped working? I made a change to the number of fields on the form and it seems to have broken it. 

 

The form settings have a fallback page of a home page redirect, but this usually interrupts it, but has stopped doing so and filling in the form takes you to the home page now. 

 

 

 

<script src="//MYSITEHERE.com/js/forms2/js/forms2.min.js"></script> <form id="mktoForm_1058"></form> <script>MktoForms2.loadForm("//MYSITEHERE.com", "465-NDL-037", 1058, function(form) { //Add an onSuccess handler form.onSuccess(function(values, followUpUrl) { // Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl location.href = "MYSITEHERE.com/PAGE"; // Return false to prevent the submission handler continuing with its own processing return false; }); }); </script>

 

 

 

Best answer by SanfordWhiteman

The cause is you have a script you’re injecting via GTM that uses the default Thank You URL:

a.onSuccess(function(b, c) { window.dataLayer.push({ event: "mkto.form.success", "mkto.form.values": b, "mkto.form.followUpUrl": c, eventCallback: function() { document.location.href = c }, eventTimeout: 3E3 }); return !1 })

 

This code waits for the Data Layer event to be complete and then redirects to c — the original Thank You.

1 reply

SanfordWhiteman
New Participant
June 8, 2022

Link to your actual page, please.

pmann-elementum
New Participant
June 9, 2022

Thanks!

 

Page:

www.elementum.com/lp/how-your-business-can-benefit-from-esm-software/ 

 

unredacted code:

 

<script src="//go.elementum.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1058"></form>
<script>MktoForms2.loadForm("//go.elementum.com", "465-NDL-037", 1058, function(form) {
    //Add an onSuccess handler
    form.onSuccess(function(values, followUpUrl) {
        // Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
        location.href = "https://www.elementum.com/lp/typ/thank-you-guide-to-esm/";
        // Return false to prevent the submission handler continuing with its own processing
        return false;
    });
});
</script>

 

 

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
June 10, 2022

The cause is you have a script you’re injecting via GTM that uses the default Thank You URL:

a.onSuccess(function(b, c) { window.dataLayer.push({ event: "mkto.form.success", "mkto.form.values": b, "mkto.form.followUpUrl": c, eventCallback: function() { document.location.href = c }, eventTimeout: 3E3 }); return !1 })

 

This code waits for the Data Layer event to be complete and then redirects to c — the original Thank You.