SOLVED

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

Go to solution
Mahurrinah_Sims
Level 2

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?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

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.

View solution in original post

5 REPLIES 5
Amanda_Thomas6
Level 9 - Champion

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

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

Mahurrinah_Sims
Level 2

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

Hi Amanda,

We use Optimizely.

Amanda_Thomas6
Level 9 - Champion

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

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.

Amanda_Thomas6
Level 9 - Champion

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

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

SanfordWhiteman
Level 10 - Community Moderator

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

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.

View solution in original post