Refreshed and republished on September 3, 2021

This post was originally published on May 29, 2018 and has been revamped and updated for accuracy and comprehensiveness.

Want to do something with your Pardot form that is not available in the editor? Try using JavaScript! Enhance your forms by using these 6 advanced Pardot form techniques. Learn how to add text between form fields, how to capture URL parameters in hidden fields and more.

Adding JavaScript to your Pardot forms

Custom JavaScript can be placed within your Pardot forms under Look and Feel > Below Form. Click on the HTML button within the WYSIWYG editor and add in the JavaScript.

1. Add text between form fields

Edit the form field you want to add the text before in the form editor. Click on the advanced tab and add a CSS class with the name “add-text-before”.

Once the class has been added to the form field, you can add the following JS to your form and update the message.




2. Redirect to a thank you page based on field values

This tip is from the Pardot Help Docs, but with a couple updates. The article recommends using JavaScript-encoding for variable tags using {js}. I’ve never had success while using this method. Instead using this JavaScript does the trick.




3. Use a hidden field to capture page url

Edit the hidden form field, click on the advanced tab and add a CSS class with the name “get-page-url”.

Insert this JS into your form to capture the page url in the hidden field.

Note: This will not work if you have a iFramed form on a web page.




4. Use a Hidden field to capture page name

Edit the hidden form field, click on the advanced tab and add a CSS class with the name “get-page-name”.

Note: This will not work if you have a iFramed form on a web page.

Insert this JS into your form to capture the page url in the hidden field.




5. Pass URL parameters to a Pardot form

You can use this script to parse out URL parameters and put them into fields within your Pardot form. In this example, I’m passing utm_source, utm_medium and utm_campaign into hidden form fields.

Learn more about UTM parameters in Pardot in this post




6. Turn your form labels into placeholder text

There’s currently no feature for Pardot forms that allow you to use placeholder text instead of the label text. So, in this tutorial, I will show you how to add a bit of JavaScript to your Pardot forms to use the field labels as placeholders.

Questions?

Send me a tweet @jennamolby, leave a comment below, or book a Peer Chat.

Author

I'm a Freelance Marketing Operations Consultant With 15 years of experience in Marketing Operations, I’ve worked with a wide range of tools including Salesforce, Marketing Cloud Account Engagement (Pardot), Marketo, and many other sales and marketing platforms. I help teams optimize their tech stacks, improve processes, and get accurate, actionable reporting. Whether it’s setting up your Marketing Automation Platform, building Salesforce reports, managing lead lifecycles, tracking attribution, or integrating your tech stack, I ensure everything is aligned to drive real results.

81 Comments

  1. Jackson Collantes Reply

    Hi Jenna. Excellent post! Can you please help me with something? I did your “add text before solution” but now I want to format that text. I am a bit lost how to do it/where to do it

    • Jenna Molby

      Hi Jackson, Thank you!! You can style the text using CSS like this:

      .add-text-before {
      color:red;
      font-weight:bold;
      }

  2. Daniel Peaper Reply

    Hi Jenna,
    Thanks for all of the great content, it’s been really useful. I’m assuming that the form above to subscribe is a Pardot form? I was wondering how you achieved the popup message that says “Please fill in this field” Instead of the default Pardot required field error message?
    Thanks,
    Dan

    • Jenna Molby

      Hi Daniel, You’re welcome :). No, the form above is not a Pardot form.

  3. Hi Jenna,
    This article was really helpful, additionally, I would like to know can we use/evaluate two different fields to show thank you message?
    Example If Field 1 = Yes and Field 2 = Yes then I need to redirect to thank you page
    If Field 1 = No and Field 2 = Yes then I need to redirect to unsuccessful page
    If Field 1 = Yes and Field 2 = No then I need to redirect to unsuccessful page

    Thanks

  4. Hi Jenna, is there a way to customize the text in the add-before-text java trick? Ie. I have 3 paragraphs that I want to put above the field. Is that possible? Thanks

    • Jenna Molby

      Hi Michelle, You can add paragraph tags like this newEl.innerHTML = '

      Paragraph 1

      Paragraph 2

      Paragraph 3

      '; and you can add CSS like this: .add-text-before {color:#000;}

    • Michelle

      Thanks so much Jenna!!! I am having difficulty with the second section. Pressing enter removes my content (it goes to black instead of green.) Can you help? Is it supposed to look like this?

      function insertBefore(el, referenceNode) {
      referenceNode.parentNode.insertBefore(el, referenceNode);
      }

      var newEl = document.createElement(‘div’);
      // replace this line with your message
      newEl.innerHTML = ‘

      I want a paragraph here. As well with spacing above.

      And here.

      ‘;

      var ref = document.querySelector(‘.add-text-before’);

      insertBefore(newEl, ref);

    • Jenna Molby

      Hi Michelle, You’re welcome! DM me the link to your page and I can take a look.

  5. Really helpful Jenna! Is there a way to add padding to each line in the form?

    • Jenna Molby

      Hi Jonny, You would this CSS should add padding to each line in the form #pardot-form .form-field {padding-top:5px;padding-bottom:5px;}

Write A Comment