SOLVED

Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

Go to solution
Alex_Lowe
Level 1

Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

We just made the switch to Wix and the functionality of our embedded Marketo forms work fine. Leads are being scored and going through the designated smart campaigns accordingly. The only hiccup is, once someone hits submit the external url set up in the form settings is displayed in the iFrame from the Wix embed code, instead of bringing the site visitor to the external page.

Here's one of the pages with the issue: https://www.luminoso.com/schedule-a-demo

This is where they are supposed to be directed after hitting submit: https://www.luminoso.com/thank-you

Any insights or tips would be greatly appreciated if anyone has run across this issue. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

You need to redirect the parent window, not the iframe window.

 

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSuccess(function(vals,thankYouURL){
    window.parent.location.href = thankYouURL;
    return false;
  });
});

 

 

View solution in original post

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

You need to redirect the parent window, not the iframe window.

 

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSuccess(function(vals,thankYouURL){
    window.parent.location.href = thankYouURL;
    return false;
  });
});

 

 

Alex_Lowe
Level 1

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

Thank you for providing this. Quick follow-up question. Do I include this code within the embed code or do I insert this in the actual page code? Many thanks.

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

You can add this right after the call to MktoForms2.loadForm, within the embed code, yes.

Alex_Lowe
Level 1

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

The code I provide before adding the new redirect code seems to work fine, but when I attempt to add the code you provided below, the form breaks and doesn't display on the page. Do you see something I need to fix with this code? Thank you again, if you couldn't tell this kind of web coding isn't my strong suit.

 

 

 <script src="//app-ab10.marketo.com/js/forms2/js/forms2.min.js"></script>
    <form id="mktoForm_1323"></form>
    <script>MktoForms2.loadForm("//app-ab10.marketo.com", "828-BNV-600", 1323);
(function (){
  var invalidDomains = ["@gmail.","@yahoo.","@hotmail.","@live.","@aol.","@outlook."];

  MktoForms2.whenReady(function (form){
    form.onValidate(function(){
      var email = form.vals().Email;
      if(email){
        if(!isEmailGood(email)) {
          form.submitable(false);
          var emailElem = form.getFormElem().find("#Email");
          form.showErrorMessage("Must be business email.", emailElem);
        }else{
          form.submitable(true);
        }
      }
    });
form.onSuccess(function(vals, “https://luminoso.com/thank-you”){
    window.parent.location.href = “https://luminoso.com/thank-you”;
    return false;
  });
  });


  function isEmailGood(email) {
    for(var i=0; i < invalidDomains.length; i++) {
      var domain = invalidDomains[i];
      if (email.indexOf(domain) != -1) {
        return false;
      }
    }
    return true;
  }

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

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

Ugh, that domain validation code is totally broken...

 

Anyway, acting for the moment as if it actually works (among other reasons, it's case-sensitive and doesn't look properly at the domain portion, so it doesn't) looks like you've added curly quotes, not straight quotes. Plus there's another fatal syntax error — the second argument to the onSuccess listener (like w/any JS function) can't be a quoted string.

 

You just need the code I provided earlier, nothing needed to be changed. It picks up the Thank You URL automatically.

Alex_Lowe
Level 1

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

that worked perfectly thank you.

Last question for you if you don't mind. If I wanted to use a marketo form to redirect someone to an external URL, such as an analyst report, is it possible to insert that external page into the code you shared in place of the thankYouURL? 

Most of forms will just point to the thankYouURL, but in the past we have hosted some industry reports gated by a marketo form. Thanks again!

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

If it's a fully external URL then just change

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSuccess(function(vals,thankYouURL){
    window.parent.location.href = thankYouURL;
    return false;
  });
});

 

to

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSuccess(function(vals,thankYouURL){
    var overrideThankYouURL = "https://www.example.com/some/other/url.html";
    window.parent.location.href = overrideThankYouURL;
    return false;
  });
});

 

Alex_Lowe
Level 1

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

Thank you so much for all your help. I really appreciate it and you solved a lot of head scratching on my end. Thank you once again!

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form Embedded on Wix Displaying Thank You External URL within iFrame

Great!