"I need to automatically add predetermined text to a hidden field in my Pardot form. Is there a script for this?"
Sometimes you need to capture consistent information in your Pardot forms without requiring user input. Our simple script template makes it easy to populate a hidden field with static text of your choice.
What This Script Does
This JavaScript snippet automatically inserts your predefined text into a specific hidden field on your Pardot form. This is useful for tracking form sources, categorizing submissions, or adding context to your lead data without modifying your form's appearance.
The Script Template
For your convenience, we offer two ways to get the script:
- Do It Yourself: Copy and paste this template and customize it manually following the instructions below.
- Use Our Free Tool: For a simpler approach, visit our free Static Text Pardot tool, enter your field information and desired text, and get a customized version of the code ready to implement.
Copy and paste this script into your Pardot form's "Below Form" section or directly into your Layout Template:
<!-- Start Text Capture -->
<script type="text/javascript">
//Replace YOURFIELD (not input) with your field (f.e. Page_Title) and use the field and not name. For this go to Account Engagement Settings - Prospect Fields - column Field (not column Name)
//Replace YOUR TEXT with your static text but do not remove the two ""
$('.YOURFIELD').find('input:hidden').val("REPLACE TEXT");
</script>
<!-- End Text Capture -->
How To Customize the Script
The script is straightforward but requires proper customization:
- Set Your Field Name:
- Replace YOURFIELD with your actual Pardot field
- This must match exactly with the field in Pardot, including capitalization
- To find the correct field name, go to Account Engagement Settings - Prospect Fields and look at the "Field" column (not the "Name" column)
- Define Your Static Text:
- Replace REPLACE TEXT with whatever text you want to appear in the hidden field
- Keep the quotation marks around your text
- Example: $('.Form_Source').find('input:hidden').val("Homepage Contact Form");
Common Use Cases
Here are some popular ways marketing teams use static text in hidden fields:
Use Case | Example Value | Benefit |
Form Source | "Product Page Form" | Track which forms generate leads |
Campaign Identifier | "Spring 2025 Webinar" | Group submissions by initiative |
Lead Category | "Product Interest" | Pre-categorize leads |
Default Values | "Not Specified" | Ensure fields have baseline values |
Implementation Steps
- Create Hidden Field in Pardot:
- Navigate to Pardot Admin settings - Prospect Fields
- Create a field with your desired name (e.g. "Form_Source")
- Set field type as "Text"
- Add Hidden Field to Your Form:
- Edit your Pardot form
- Add the field you created
- Mark it as a "Hidden" field
- Implement the Script:
- Add the script to your form in the "Below Form" section or
- Add it to your Layout Template for use across multiple forms
Test your form thoroughly after implementation to ensure the hidden field is capturing the static text correctly.
Next Steps
With this script implemented, your Pardot form will now automatically include your predefined text in the hidden field every time the form is loaded. This provides consistent data for segmentation, routing, and reporting purposes.
Need help implementing this script or with other Pardot topics? Get in touch with our team for personalized assistance.