Page Title in Hidden Pardot Field Script Template

Get a ready-to-use script template for automatically capturing webpage titles in hidden Pardot form fields for improved lead context.
Written by Axel
Updated 5 days ago

"I want to capture the page title automatically when someone submits a Pardot form. Is there a script for this?"

Capturing the page title provides valuable context about where your leads are coming from. Our simple script template makes it easy to automatically store the current page title in a hidden Pardot field.

What This Script Does

This JavaScript snippet automatically captures the title of the webpage and stores it in a hidden field on your Pardot form. This provides additional context about which pages are generating leads without requiring any input from your visitors.

The Script Template

For your convenience, we offer two ways to get the script:

  1. Do It Yourself: Copy and paste this template and customize it manually following the instructions below.
  2. Use Our Free Tool: For a simpler approach, visit our free Page Title Pardot tool, enter your field information, 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 Page Title Capture -->
<script type="text/javascript">
                        
                        //Replace YOURFIELD (not input) with your field (f.e. Page_Title). Make sure to use the field and not name: For this go to Account Engagement Settings - Prospect Fields - column Field (not column Name)
            $('.YOURFIELD input').val(document.title);
        </script>
<!-- End Page Title Capture -->

How To Customize the Script

The script is straightforward but requires proper customization. To do this, set your field name:

  • Replace YOURFIELD with your actual Pardot field class name
  • 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)
  • Example: $('.Page_Title input').val(document.title);

Implementation Steps

  1. Create Hidden Field in Pardot:
    • Navigate to Pardot Admin settings - Prospect Fields
    • Create a field with a descriptive name (e.g. "Page_Title")
    • Set field type as "Text"
  2. Add Hidden Field to Your Form:
    • Edit your Pardot form
    • Add the field you created
    • Mark it as a "Hidden" field
  3. 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

Advanced Tips

  • Combining with Other Data: Pair page title data with UTM parameters for even more comprehensive tracking
  • Custom Title Formatting: Modify the script to extract specific parts of long titles or add prefixes
  • Conditional Logic: Use this data in Pardot completion actions to route leads differently based on the page they came from

If you have very long page titles, consider adding length validation to ensure they fit within your Pardot field's character limits.

Next Steps

With this script implemented, your Pardot forms will now automatically capture the page title every time a form is submitted. This data will help you better understand which content drives conversions and optimize your lead generation strategy.

Need help implementing this script or with other Pardot topics? Get in touch with our team for personalized assistance.

Did this answer your question?