Pardot Google Click ID (GCLID) Parameter Capture Script Template

Get a ready-to-use GCLID parameter capture script template for Pardot to track Google Ads conversions.
Written by Axel
Updated 5 days ago

"I need a script to capture GCLID parameters in my Pardot forms for Google Ads tracking. Is there a template I can use?"

Yes! Tracking Google Click IDs (GCLID) is essential for attributing conversions to your Google Ads campaigns. Our ready-to-use script template makes it easy to capture this valuable parameter directly in Pardot.

What This Script Does

This JavaScript snippet automatically captures the GCLID parameter from your URL and stores it in a hidden field on your Pardot forms. This ensures your Google Ads conversion data is properly tracked, allowing you to measure ROI and optimize your ad spend effectively.

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 GCLID Parameter Pardot tool, enter your field information, and get a customized version of the code ready to implement.

Copy and paste this script into your desired Pardot form inside "Below Form" and adjust the parameters to your needs - see two comments inside code:

<!-- Start Parameter Capture --><script type="text/javascript">
function getParameterByName(name) {
                name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
                var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                    results = regex.exec(location.search);
                return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
            }
// Give the URL parameter (f.e. gclid) variable names (f.e. gclid)
// Example: var PARAMETER = getParameterByName('PARAMETER-AS-SHOWN-IN-URL');
            var gclid = getParameterByName('gclid');  
//Put the variable name (f.e. gclid) into place, replace YOURFIELD with your field (f.e. GCLID). Make sure to use the field and not name: For this go to Account Engagement Settings - Prospect Fields - column Field (not column Name)
// Example: document.querySelector('.PARDOT-COLUMN-NAME input[type="hidden"]').value = PARAMETER;
            document.querySelector('.GCLID input[type="hidden"]').value = gclid;
        </script>
<!-- End Parameter Capture -->

How To Customize the Script

The script includes helpful comments that guide you through the customization process:

  1. Define Your Parameter:
    • The first comment section explains how to map the URL parameter to a variable
    • The GCLID parameter is already set up with var gclid = getParameterByName('gclid')
    • If needed, you can add additional parameters following the same pattern
  2. Configure Your Field Name:
    • The second comment section is crucial - it shows how to map the variable to your specific Pardot field
    • Replace the GCLID with your actual Pardot field class if yours is named differently
    • To find the correct field name, go to Account Engagement Settings - Prospect Fields and look at the "Field" column (not the "Name" column)

Implementation Steps

  1. Create Hidden Field in Pardot:
    • Navigate to Pardot Admin settings - Prospect Fields
    • Create a field named "GCLID" (or your preferred name)
    • Set field type as "Text"
  2. Add Hidden Field to Your Form(s):
    • Edit your Pardot form
    • Add the GCLID field you created
    • Mark it as a "Hidden" field
  3. Implement the Script:
    • Add the script to your form layout template or
    • Add it to a specific Pardot form in the "Below Form" section

Understanding GCLID

GCLID (Google Click ID) is a unique identifier that Google Ads adds to your landing page URLs when a user clicks on your ad. It looks something like this:

https://www.example.com/landing-page?gclid=CjwKCAiA15eqBhBZEiwAdDR16hTgM8uW5F7skBY3C9JzL7NuA5X8QcFg

When captured properly, this ID allows Google to connect conversions back to the specific ad, keyword, and campaign that generated the click, even if the conversion happens days later.

Make sure your Google Ads account is properly configured to use auto-tagging, which is required for GCLID parameters to be added to your URLs.

Next Steps

With this script implemented, your Pardot forms will now capture GCLID parameters, allowing you to track Google Ads conversions accurately. This data will help you measure campaign effectiveness and optimize your Google Ads spend.

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

Did this answer your question?