URL appended after form submission

nflowers
Level 1

URL appended after form submission

Is it possible to append a URL parameter after successful marketo form submissions? Example.  'www.example.com/thank-you-for-a-demo/?status=mFormSuccess '

 
Tags (1)
3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: URL appended after form submission

Of course!

 

MktoForms2.whenReady(function(mktoForm) {
  form.onSuccess(function(submittedValues,thankYouURL) {
    var rewrittenTYLoc = document.createElement("a");

    rewrittenTYLoc.href = thankYouURL;
    rewrittenTYLoc.search += "&" + 
       encodeURIComponent("additionalParamName") + "=" + 
       encodeURIComponent("additionalParamValue");      
    document.location = rewrittenTyLoc;

    return false;   
  });
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

nflowers
Level 1

Re: URL appended after form submission

Thanks Sanford! 

 

Quick question: 

Where in the code of the form would I insert this? I tried adding at the beginning and I was not able to append the url after form submission. 

 

Also - is there anywhere in the code where I will need to add "=success" so that after every form submission, the url will be appended with this? 

 

Thank you so so much!

SanfordWhiteman
Level 10 - Community Moderator

Re: URL appended after form submission

You'd add it in its own <script> tag. With the form embed, put it anywhere after the embed code. On a Marketo LP, just before the closing </body> tag.

 

additionalParamName and additionalParamValue can be replaced with whatever name/value you want.