Using a hidden form field to send url of external page Marketo form is on/filled out from | Community
Skip to main content
New Participant
January 29, 2021
Solved

Using a hidden form field to send url of external page Marketo form is on/filled out from

  • January 29, 2021
  • 1 reply
  • 7441 views

Marketo's documentation on this isn't very clear for me so I'm hoping someone can help.

 

We have one Marketo form that is embedded on multiple pages on our website.  The internal stakeholders would like form fills to include the url of the page the person filled out the form on, so they can tell which pages are getting more form fills.

The pages do not have querystrings in their url's so I'm not sure parameters will work for this.

 

Is there a way to get the url into a hidden form field?

 

Otherwise I guess my other option would be to create smartlists and use the referrer constraint to split out each page the form is on.

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

1. Add the custom String field LastFormURL to your instance.

 

2. Use this simple JavaScript to pass that hidden field for every form fill:

MktoForms2.whenReady(function (form) { form.addHiddenFields({ LastFormURL : document.location.href }); });

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
January 29, 2021

1. Add the custom String field LastFormURL to your instance.

 

2. Use this simple JavaScript to pass that hidden field for every form fill:

MktoForms2.whenReady(function (form) { form.addHiddenFields({ LastFormURL : document.location.href }); });
New Participant
January 29, 2021

Thanks, Sanford.  Where would I put that script?  On the page on our website the form is on or can I put it in a rich text area on the form?

SanfordWhiteman
New Participant
January 29, 2021

You can add it directly after the embed code or if absolutely necessary, you can add it within a Rich Text but only if you do it like this: https://nation.marketo.com/t5/Product-Blogs/HOWTO-Add-Forms-2-0-JS-behaviors-inside-a-Rich-Text-Area/ba-p/242768