Skip to main content
Level 1
Jul 15, 2020 8:02 PM UTC
Question

URL appended after form submission

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.

3 replies

SanfordWhiteman
User Group Leader
User Group Leader
Jul 15, 2020 8:16 PM UTC

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

 

Translate
nflowersAuthor
Level 1
Jul 28, 2020 10:27 PM UTC

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!

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Jul 28, 2020 10:37 PM UTC

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.

Translate