Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

AlyssaMaker
Level 2

Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

We are embedding Marketo Forms on website pages in WordPress. 

I would like for the forms to go to specific landing pages and know that I can't define that in Marketo. 

Is there a piece of code you can add to the form to redirect it to a specific thank you page on completion. This is the code I am working with now:

 

<script src="//app-ab39.marketo.com/js/forms2/js/forms2.min.js"></script><form id="mktoForm_1015"></form>

<script>MktoForms2.loadForm("//app-ab39.marketo.com", "194-ATY-897", 1015);</script>

<script>MktoForms2</script>

<script>MktoForms2.whenReady(function(form) { form.onSuccess(function(values,www.juvare.com/thank-you-test-page/)

}); 
</script>
9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

I would like for the forms to go to specific landing pages and know that I can't define that in Marketo. 


Why can't you use Add Choice for Thank You URLs, specifically?

 

(Also, pls highlight any code you post using the Syntax Highlighter so it's readable.)

AlyssaMaker
Level 2

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

The Add Choice function only allows me to choose based off a form field and where the thank you pages need to go is not based off a form field, it is based off what they are downloading.

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

Add a Most Recent Asset Download field to your instance, and add it as a Hidden field in Form Editor.

 

This enables you to use Add Choice and not have to manage Thank You URLs themselves in JavaScript (which is totally possible, but unnecessarily complex if you're not a developer). 

 

To add the asset field would be a tiny bit of JS:

 

 

MktoForms2.whenReady(function(form){
  form.setValues({
    MostRecentAssetDownload : "/some/value/output/by/WordPress"
  });
});

 

 

The field value would be a WordPress user variable, or any other way WP knows the asset name.

 

(Again pls highlight your code above using the Syntax Highlighter, it's not readable otherwise.)

AlyssaMaker
Level 2

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

Just so I understand, I add a field to Marketo and put it in the form as a hidden field and then add the script to the landing page then on the form level use the Add Choice function and the hidden field to decide which thank you page it goes to?

Is that code set or do I need to change anything, replace, or add?

 

(I fixed the code in the original post)

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page


Just so I understand, I add a field to Marketo and put it in the form as a hidden field and then add the script to the landing page then on the form level use the Add Choice function and the hidden field to decide which thank you page it goes to?

Right.

 

Is that code set or do I need to change anything, replace, or add?

Well, the code uses a sample form field name (MostRecentAssetDownload). You would use the real field name once created in your instance - which is the same as the SOAP API field name.

 

(I fixed the code in the original post)


Looks like a screenshot - which isn't right for code.

 

The Syntax Highlighter is part of the post editor:

 

2020-03-02 15_57_55-Reply to Message - Marketing Nation.png

 

That's how you get code to be syntax-highlighted, readable and copyable.

AlyssaMaker
Level 2

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

Gotcha. Okay I just fixed the code again. It should be correct now.

AlyssaMaker
Level 2

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

Would you create the field as a Boolean field or a string field in Marketo? Or does it matter?

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

It has to be a String field! Because it's going to be storing the URL of the asset.

AlyssaMaker
Level 2

Re: Marketo Form embedded on Non Marketo Page and Need it to go to a specific landing page

I added the hidden field to the form and put in the code you provided and it is not populating the mostrecentdownload field with anything in Marketo. I also tried adding the Add Choice field on the form saying if most recent download contains (URL of Page) then send to external URl. It still stays on the page.

 

Is it supposed to populate that hidden field?

 

Here is the URL to the page I put it on: