I am creating a landing page that will act as a gate to content we want to share. I would like to reuse this landing page, but I need to let the form/landing page know which content URL to direct people to after they submit the form. I would like to be able to pass that into the page as a query string parameter. Is it possible to put a query string parameter into the Form Thank You Page follow up with URL field? If it is possible, how?
I see that if I create a hidden field, I can read the query string parameter.
I thought about using a token, but the set-up page says it only accepts my text tokens. I created a my text token with PHP code to echo the parameter, but that doesn't seem to be working. I suspect Marketo isn't executing PHP code here, but it's also possible my code is missing something.
Solved! Go to Solution.
Thanks, Jason. Will, Kenny pointed you to the JS onSuccess event handler, which is a necessary ingredient. That's not quite enough, though, since you also need to parse the query string. To this day, query parsing is not a built-in JS/DOM function, to many people's surprise (and there's no plan to ever make it built-in, AFAIK).
While MktoForms2 has a built-in query parser, it's flawed, but more important, it's not exposed publicly (it's used when you add a hidden field that's set to Autofill from a query param, which you could take advantage of if you add a placeholder field to the form, but I think this'll lead to confusion later).
The closest to an "official" URI parser out there is URI.js. Does more than you need here, but that's okay, because the more you try to reinvent this wheel the more you'll miss. (Believe me, I have my own fairly well-thought-out URI parser, and it still isn't suitable for all sites because I deliberately cut some corner cases.).
Include URI.js in your HEAD:
<script src="//cdnjs.cloudflare.com/ajax/libs/URI.js/1.17.1/URI.js"></script>
Pass the Thank You URL in the query string:
http://pages.example.com/shared-landing-page.html?tyURL=followup1.html
And the companion code is simple:
MktoForms.whenReady(function(form){
form.onSuccess(function(vals,formLevelTyURL){
location.href = new URI().query(true).tyURL;
return false;
});
});
I suspect this is something that would require custom scripting or the forms API, Sanford Whiteman usually has solutions for these types of questions.
Jason
Take a look at example 2 here: Forms 2.0 » Marketo Developers
Thanks, Jason. Will, Kenny pointed you to the JS onSuccess event handler, which is a necessary ingredient. That's not quite enough, though, since you also need to parse the query string. To this day, query parsing is not a built-in JS/DOM function, to many people's surprise (and there's no plan to ever make it built-in, AFAIK).
While MktoForms2 has a built-in query parser, it's flawed, but more important, it's not exposed publicly (it's used when you add a hidden field that's set to Autofill from a query param, which you could take advantage of if you add a placeholder field to the form, but I think this'll lead to confusion later).
The closest to an "official" URI parser out there is URI.js. Does more than you need here, but that's okay, because the more you try to reinvent this wheel the more you'll miss. (Believe me, I have my own fairly well-thought-out URI parser, and it still isn't suitable for all sites because I deliberately cut some corner cases.).
Include URI.js in your HEAD:
<script src="//cdnjs.cloudflare.com/ajax/libs/URI.js/1.17.1/URI.js"></script>
Pass the Thank You URL in the query string:
http://pages.example.com/shared-landing-page.html?tyURL=followup1.html
And the companion code is simple:
MktoForms.whenReady(function(form){
form.onSuccess(function(vals,formLevelTyURL){
location.href = new URI().query(true).tyURL;
return false;
});
});
Thanks. That worked. You are all awesome.