Can I Populate Hidden Form Field With Page URL or Name? | Community
Skip to main content
Mahurrinah_Sims
New Participant
December 8, 2017
Solved

Can I Populate Hidden Form Field With Page URL or Name?

  • December 8, 2017
  • 3 replies
  • 4985 views

Hi,

We have a form that we want to use on multiple pages, but we want their thank you page to be dependent on the page their filling out the form on.

Can we populate a hidden field with the page url or name?

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

This has been asked before (make sure to search!) and is very easy:

MktoForms2.whenReady(function(form){

  form.addHiddenFields({

    'lastFormSubmitPageName' : document.title,

    'lastFormSubmitPageURL' : document.location.href

  });

});

Replace lastFormSubmitPageName and lastFormSubmitPageURL with the names of fields in your instance that you want to store this data.

3 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
December 8, 2017

This has been asked before (make sure to search!) and is very easy:

MktoForms2.whenReady(function(form){

  form.addHiddenFields({

    'lastFormSubmitPageName' : document.title,

    'lastFormSubmitPageURL' : document.location.href

  });

});

Replace lastFormSubmitPageName and lastFormSubmitPageURL with the names of fields in your instance that you want to store this data.

Amanda_Thomas6
New Participant
December 8, 2017

Also, you can actually do this with Javascript as well, might be easier. So on the form embed code, you can modify it to show a different landing page, then do this per page the form is on. I'm not sure what the exact script is, but google may have it? lol

Amanda_Thomas6
New Participant
December 8, 2017

Hi @Mahurrinah Sims​, You should be able to do this. Do you use a web personalization tool? Like Evergage or Optimizely?

Mahurrinah_Sims
New Participant
December 8, 2017

Hi Amanda,

We use Optimizely.

Amanda_Thomas6
New Participant
December 8, 2017

There should be a workflow you can set up through optimizely> If fills our form 5678 on page x then show page x. That's how we handle this workflow through Evergage.