Re: Form Follow up with to relative external Thank you Page URL

Prakash_Mohanda
Level 2

Form Follow up with to relative external Thank you Page URL

Hello

This might be a very simple question. I am basically trying to create form that is being embedded on a web page called 'get-started' but the form should automatically redirect to a relative 'thank you' page that is one level down in the hierarchy 'get-started/thank-you' . How do I setup a redirect to a relative page on the website that this form is located on?

14 REPLIES 14
SanfordWhiteman
Level 10 - Community Moderator

Re: Form Follow up with to relative external Thank you Page URL

MktoForms2.whenReady(function(form){

  form.onSuccess(function(vals,tyURL){

    var loc = document.createElement('A');

    loc.href = tyURL;

    loc.pathname = [loc.pathname,"thank-you"].join("/");

    document.location.href = loc.pathname + loc.search + loc.hash;

    return false;

  });

});

Prakash_Mohanda
Level 2

Re: Form Follow up with to relative external Thank you Page URL

Thank you Sanford. Where does this code go? or where does this code need to be added?

Prakash_Mohanda
Level 2

Re: Form Follow up with to relative external Thank you Page URL

Currently my ember code is

<script src="//app-ab22.marketo.com/js/forms2/js/forms2.min.js"></script>

<form id="mktoForm_4"></form>

<script>MktoForms2.loadForm("//app-ab22.marketo.com", "876-MVP-978", 4);</script>

SanfordWhiteman
Level 10 - Community Moderator

Re: Form Follow up with to relative external Thank you Page URL

Right after the embed code, in a <script>.

Prakash_Mohanda
Level 2

Re: Form Follow up with to relative external Thank you Page URL

I added the code.
However  The submit button is going to https://thank-you, instead of  /get-started/thank-you.

Prakash_Mohanda
Level 2

Re: Form Follow up with to relative external Thank you Page URL

The Marketo form is located at: https://ibs.schwab.acsitefactory.com/get-started.

The thank-you page is located at: https://ibs.schwab.acsitefactory.com/get-started/thank-you,
so the link needs to be t

The Marketo form is located at: https://ibs.schwab.acsitefactory.com/get-started.

The thank-you page is located at: https://ibs.schwab.acsitefactory.com/get-started/thank-you,
so the link needs to be the relative link of /get-started/thank-you.

he relative link of /get-started/thank-you.

SanfordWhiteman
Level 10 - Community Moderator

Re: Form Follow up with to relative external Thank you Page URL

The code expects you to still have a Thank You URL entered in the Form Editor, because you may want to add query params and hash at some point.

Then it swaps out the path of the Thank You URL for the relative path (but it keeps the query and hash -- search and hash -- of the URL).

Prakash_Mohanda
Level 2

Re: Form Follow up with to relative external Thank you Page URL

The form does currently have a url 'https://www.schwab.com' listed in the follow up with  field as an external URL. are you talking about something else?

Prakash_Mohanda
Level 2

Re: Form Follow up with to relative external Thank you Page URL