Populate Hidden Field on Form with Name of Webpage

You may have a single Pardot form on multiple pages of your site (like a newsletter signup form) and want easy access to know what page that form was completed on. To populate a hidden field on a form with the name of the page where the prospect completed the form you can use the following steps:

  1. Create a new custom field with the type of ‘Hidden’ to contain the page name value in the prospect record. (Note the Field ID for future steps)
  2. Copy and paste this HTML code in your webpage where you would like the form to appear:
    <script type="text/javascript">
    var fieldId = "Custom_Field_ID";
    var formUrl = "http://cname.company.com/12345/ABCDE";
    var title = encodeURI(document.title);
    document.write('<iframe width="100%" height="300" frameborder="0" style="border: 0;" src="' + formUrl);
    document.write('?' + fieldId + '=' + title);
  3. Update the Custom_Field_ID portion of var fieldId = “Custom_Field_ID”; to be the Field ID of the new custom hidden field you just created.
  4. Update the Form URL http://cname.company.com/12345/ABCDE portion of var formUrl = “http://cname.company.com/12345/ABCDE”; to be the link to the Pardot form.
  5. Save these updates and test to confirm the page name where the form was completed is recorded in Pardot.


  • Within the document.write(‘<iframe… portion of the script you can update the height and width of the iframe to best fit within the allotted page area.
  • When applying these steps to a Form Handler instead of a Pardot Form, update the Form URL with the post URL from the form handler code instead of the link to the Pardot form. To find this URL from your Pardot Dashboard, Marketing > Forms > Form Handlers > select the form handler > View Form Handler Code > copy URL after ‘form action=’ and before ‘method=’