SOLVED

Re: Route form fill to specific thank you page based on the URL

Go to solution
Anh_Ly
Level 2

Is there a way to route a form fill to a specific thank you page based on the URL where the form lives? We are hosting our landing pages on the CMS and would like to prevent the creation of multiple forms.

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

Sure, you can do this in 2 ways:

1. In an onSuccess listener, dynamically choose the Thank You based on the current URL (for example, appending "_ThankYou" to the current page).

2. In the form setup, by using Add Choice on the Settings page.

View solution in original post

16 REPLIES 16
SanfordWhiteman
Level 10 - Community Moderator

Sure, you can do this in 2 ways:

1. In an onSuccess listener, dynamically choose the Thank You based on the current URL (for example, appending "_ThankYou" to the current page).

2. In the form setup, by using Add Choice on the Settings page.

Anonymous
Not applicable

Hi Sandford

I can't actually see the referrer URL as an option you can select when setting the choice for the thank you page. It is only offering the fields/questions I have on the form. Can you outline how you would do this? Am I missing something?

SanfordWhiteman
Level 10 - Community Moderator

You'd have to add the field to the form, as here: https://nation.marketo.com/message/79664#comment-79664

Then you can use it in conditions.

shilohpaul
Level 2

Hi @SanfordWhiteman - I know this post is several years old, but I'm trying to implement this for a global form, embedded on WordPress landing pages, that we need to route to different thank you pages. I've added the code from the linked post to the wordpress page. Do I simply submit the form to make the hidden field become available in Marketo? Or do I have to set a field up in Marketo's form settings to listen for the LastFormURL hidden field?

 

<script src="//app-xxxx.marketo.com/js/forms2/js/forms2.min.js "></script>
<form id="mktoForm_1XXXX"></form>
<script>
MktoForms2.loadForm("//app-xxxx.marketo.com ", "***-***-***", XXXX, function(form){
  form.addHiddenFields({ LastFormURL : document.location.href })    
});
</script>

 

Thank you!

SanfordWhiteman
Level 10 - Community Moderator

You need a Marketo (String) field LastFormURL to be created first in Admin » Field Management.

 

You don't need this field to appear in Form Editor at all, it will be added by JavaScript either way.

kenmckown
Level 4

@SanfordWhiteman I found this and was attempting to use it on our instance, but it is causing issues. I am not sure if I broke the code trying to compile it. I am getting two forms showing up.

 

<script src="//go.autoshopsolutions.com/js/forms2/js/forms2.min.js"></script> <form id="mktoForm_3948"></form> <script>MktoForms2.loadForm("//go.autoshopsolutions.com", "180-DGD-014", 3948);</script>

<script>
{

  const ctaText = "Download Now";

  /* -- NO NEED TO TOUCH BELOW HERE -- */

  MktoForms2.whenReady(function(readyForm){
    const formEl = readyForm.getFormElem()[0],
          buttonEl = formEl.querySelector(".mktoButton[type='submit']");

    buttonEl.textContent = ctaText;
  });

}
</script>

<script>
MktoForms2.loadForm("//go.autoshopsolutions.com", "180-DGD-014", 3948, function(form){
  form.addHiddenFields({ LastFormURL : document.location.href })    
});
</script>

 

SanfordWhiteman
Level 10 - Community Moderator

That code contains a call to loadForm(). If you’re already calling loadForm() elsewhere, that’ll naturally create a duplicate form. It’s not an issue with the code, just a consequence of not coordinating with existing code.

 

Also not clear what you’re trying to do: that code doesn’t change the Thank You page.

kenmckown
Level 4

The goal was to embed this form on an external page, the second part is to allow for changing the submit button, and the bottom piece was designed to change the Thank You page based on the LastFormURL field. I set up the choices on the form in Marketo.

shilohpaul
Level 2

Thank you! I have that set up. However, it's still not passing the URL through. Our marketo admin does have that hidden field already in the form with a value of null, so I'm wondering if that's overwriting the value passed with the code (which lives on a WordPress page). Would you recommend deleting that field from the form? If so, the field won't be an option for setting the logic in the settings of the form, so I'm not sure how to proceed there.

 

 

SanfordWhiteman
Level 10 - Community Moderator

OK, so there are 2 levels of "necessary" here, maybe that's confusing.

 

It's not necessary to have the hidden field on the form in Form Editor in order to have it filled in using addHiddenFields() and have the value stored in the Marketo database.

 

It is necessary to have the hidden field on the form in Form Editor in order to use it in the Advanced (Add Choice) Thank You section.

 

Overall I'd like to see the Details of a Filled out Form activity from a lead's Activity Log so we can confirm the value is being posted.

shilohpaul
Level 2

Sure thing! PreviousURI is our name for LastFormURL

 

Webform ID:
1360
Form Fields:
FirstName: First
LastName: Last
Company: Test
Email: first.last@test.com
broadIndustry: Financial Services
gamedium:
gasource:
gacampaign:
previousURI:
marketingCommunicationsOptIn: yes
munchkinId: 801-JLS-289
PreviousURI: http://staginginsxxxx.wpengine.com/uncategorized/form-test/
formVid: 1360
_mktoReferrer: http://staginginsxxxx.wpengine.com/uncategorized/form-test/
checksumFields: FirstName,LastName,Company,Email,broadIndustry,gamedium,gasource,gacampaign,previousURI,marketingCommunicationsOptIn,formid,munchkinId,PreviousURI,_mkt_trk,formVid,_mktoReferrer
checksum: fd904fe78ceb0715de6a3c6a5abc1ffcc0d6d48555444326b7537bc4f9025f8a
Webpage ID:
426668
Query Parameters:
 
Referrer URL:
Client IP Address:
98.164.55.70
User Agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Person ID:
22011334
SanfordWhiteman
Level 10 - Community Moderator

I see both previousURI and PreviousURI in the form post — only one of those can be the right spelling!

shilohpaul
Level 2

Oh my goodness - thank you! What a silly mistake that I won't be making again. It's working perfectly now! 

SanfordWhiteman
Level 10 - Community Moderator

OK, great!

shilohpaul
Level 2

Hi again! I asked this in another threat but it might be better to ask it here. 

Is there any way to get this to open in a new tab? 

SanfordWhiteman
Level 10 - Community Moderator

Answered on the other thread.