Skip to main content
Will_Raleigh
Level 2
Mar 27, 2016 2:02 AM UTC
Solved

Using Query String Parement to pass follow up with page URL into a form?

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Mar 28, 2016 7:54 PM UTC

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:

  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;

  });

});

4 replies

Jason_Hamilton1
Level 6
Mar 28, 2016 1:09 PM UTC

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

Translate
Kenny_Elkington
Adobe Employee
Adobe Employee
Mar 28, 2016 3:52 PM UTC

Take a look at example 2 here: Forms 2.0 » Marketo Developers

Translate
SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Mar 28, 2016 7:54 PM UTC

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:

  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;

  });

});

Translate
Will_Raleigh
Level 2
Mar 30, 2016 12:14 AM UTC

Thanks. That worked. You are all awesome.

Translate