Can I Populate Hidden Form Field With Page URL or Name? | Community
Skip to main content
Mahurrinah_Sims
Level 2
Dec 8, 2017 2:56 PM UTC
Solved

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

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.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Dec 8, 2017 8:43 PM UTC

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.

5 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Dec 8, 2017 8:43 PM UTC

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.

Translate
Amanda_Thomas6
Level 8
Dec 8, 2017 5:38 PM UTC

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

Translate
Amanda_Thomas6
Level 8
Dec 8, 2017 3:12 PM UTC

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

Translate
Mahurrinah_Sims
Level 2
Dec 8, 2017 3:28 PM UTC

Hi Amanda,

We use Optimizely.

Translate
Amanda_Thomas6
Level 8
Dec 8, 2017 3:31 PM UTC

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.

Translate