Embeded Marketo form with Follow up with external link not working

Mark_Goonetille
Level 2

Embeded Marketo form with Follow up with external link not working

Hi,

 

I have a marketo form embeded on a non marketo landing page with the thank you page as External URL. However once the submit form is clicked nothing seems to happen. I tried a code I found on a separate ticket and now an black page opens. Any help with this?

 

 


var formEl = form.getFormElem()[0],
thankYouWindow;

form.onSubmit(function(form) {
thankYouWindow = window.open('');
});

form.onSuccess(function(vals, thankYouURL) {
thankYouWindow.document.location =
thankYouURL;
formEl.innerHTML = 'Thank you! Your NATSPEC branded worksection has opened in a new window.';
return false;
});
});

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Embeded Marketo form with Follow up with external link not working

Please highlight your code using the Syntax Highlighter so it's readable.

 

And provide your URL - need to see what else is going on on your page.

Mark_Goonetille
Level 2

Re: Embeded Marketo form with Follow up with external link not working

This is external page with the form - https://www.rondo.com.au/resources/design/natspec-branded-worksections/

 

<script src="//app-sn02.marketo.com/js/forms2/js/forms2.min.js"></script><link itemprop="stylesheet" rel="stylesheet" type="text/css" href="https://go.rondo.com.au/rs/653-INQ-695/images/rondo-mktoForm-styles.css"/><form class="whiteform"  id="mktoForm_1764"></form><script>MktoForms2.loadForm("//app-sn02.marketo.com", "653-INQ-695", 1764); MktoForms2.whenReady(function(form) {

	var formEl = form.getFormElem()[0],
		thankYouWindow;

	form.onSubmit(function(form) {
		thankYouWindow = window.open('');
	});

	form.onSuccess(function(vals, thankYouURL) {
		thankYouWindow.document.location = 
  thankYouURL;
		formEl.innerHTML = 'Thank you! Your NATSPEC branded worksection has opened in a new window.';
		return false;
	});
});  </script>
SanfordWhiteman
Level 10 - Community Moderator

Re: Embeded Marketo form with Follow up with external link not working

You have 2 different whenReady listeners in the stack. It's not just the one you're showing here. Remove the other one that starts on L#128:

 

2020-02-26 00_04_10-view-source_https___www.rondo.com.au_resources_design_natspec-branded-worksectio.png

Mark_Goonetille
Level 2

Re: Embeded Marketo form with Follow up with external link not working

thank you!

Got it working however - how do I get the success massage to show on the form which is located on the LHS side bar? That was the extra Whenready code

 

Mark_Goonetille_0-1582694647176.png

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Embeded Marketo form with Follow up with external link not working

Your whenReady listener needs to take different action depending on the form ID for which it's executed.

 

For example:

 

MktoForms2.whenReady(function(form){
  var formId = form.getId();

  switch(formId){
  case 1234:
     // whatever you want to do for form 1234
     break;
  case 4567:     
     // whatever you want to do for form 4567
     break;
  case 9999:
  case 10000:
     // whatever you want to do for forms 9999 and 10000
     break;
  }
});