SOLVED

Re: onSuccess handler to follow-up page has stopped working

Go to solution
pmann-elementum
Level 1

onSuccess handler to follow-up page has stopped working

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>

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: onSuccess handler to follow-up page has stopped working

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.

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: onSuccess handler to follow-up page has stopped working


EDIT: Unfortunately that was not the solution. That code was in place before the issue occurred for about five weeks, and removing it hasn't solved the issue either.

GTM tag absolutely is the cause. Tested by blocking gtm.js from loading entirely.

View solution in original post

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: onSuccess handler to follow-up page has stopped working

Link to your actual page, please.

pmann-elementum
Level 1

Re: onSuccess handler to follow-up page has stopped working

Thanks!

 

Page:

https://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
Level 10 - Community Moderator

Re: onSuccess handler to follow-up page has stopped working

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.

pmann-elementum
Level 1

Re: onSuccess handler to follow-up page has stopped working

Ah, thank you - may I ask how you stepped through the code to find it? Chrome debug tools wouldn't step through the loop accurately enough for me.

 

Or if you know where these functions are documented more clearly to prevent this happening in the future? 

 

Thank you, again. 

 

EDIT: Unfortunately that was not the solution. That code was in place before the issue occurred for about five weeks, and removing it hasn't solved the issue either. 

 

 

SanfordWhiteman
Level 10 - Community Moderator

Re: onSuccess handler to follow-up page has stopped working


EDIT: Unfortunately that was not the solution. That code was in place before the issue occurred for about five weeks, and removing it hasn't solved the issue either.

GTM tag absolutely is the cause. Tested by blocking gtm.js from loading entirely.

pmann-elementum
Level 1

Re: onSuccess handler to follow-up page has stopped working

Thank you for this, I dug a little deeper and found there was still an recalcitrant tag active I had overlooked - but why it hadn't affected anything until I edited the forms in Marketo Design Studio is a mystery to me. Appreciated.