URL appended after form submission | Community
Skip to main content
New Participant
July 15, 2020
Question

URL appended after form submission

  • July 15, 2020
  • 1 reply
  • 2119 views

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

 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
New Participant
July 15, 2020

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; }); });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

nflowersAuthor
New Participant
July 28, 2020

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
New Participant
July 28, 2020

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.