Legacy: Implement the Identify Call with Pardot Forms

Last Updated: January 12, 2024

🔍 Please note: This article is for customers on Standard Bundle, Enrichment, or Clearbit Platform plans. If you signed up in 2024, you are on a Sales Intelligence for HubSpot plan: Free, Growth, or Business.

For pricing information, please fill out the demo-request form on our pricing page to get in touch with a sales representative.

Pardot forms are tucked away in an <iframe> and don't provide an easy way to access submission data through their API in the same way HubSpot and Marketo does. As such, using Google Tag Manager's built-in form listener won't work. Neither will trying to tap into elements through DOM query selectors.

The following guide will walk you through setting up the identify call through a mix of Pardot's form builder and Google Tag Manager. While there are many possible variations to this solution, this one is guaranteed to work.

Skip Ahead to:

Capture the Email Submitted by Using Custom Code in the Pardot Form Builder

  1. Log in to your Pardot account and navigate to your form (Marketing > Forms > Forms).
  2. Choose your form and click Edit form in the top right corner of the screen to access the form builder.
    Screen_Shot_2022-08-17_at_9.09.17_PM.png
  3. Click on the third step of the form builder, Look and Feel.
    Screen_Shot_2022-08-17_at_9.10.22_PM.png
  4. Click on the Below Form tab and afterwards on the Source (<>) icon inside the editor.
    Screen_Shot_2022-08-17_at_9.11.20_PM.png
  5. Copy and paste the code snippet below and hit the Confirm & Save button. This option allows us to inject code within the <iframe> that will target the Pardot form on the page, save the email after a submission takes place, and send that email outside of the <iframe> along with a success message for our website to pick up on.
    <script type="text/javascript"> 
    var formID = "#pardot-form";
    var form = document.querySelector(formID);
    form.addEventListener('submit', function (event) {
    var form = event.target;
    var email = '';
    // Grab the email field's values entered in the form
    for (var i = 0, len = form.elements.length; i < len; i++) {
    var element = form.elements[i];
    if (element.value.includes("@")) {
    email = element.value;
    }
    }
    window.parent.postMessage({
    message: "PARDOT_DATA_READY",
    email: email
    }, "https://your-main-website-domain");
    });
    </script>

Verify the Form was Submitted Successfully by Using Custom Code in the Pardot Form Builder

  1. Once again, click Edit form in the top right corner of the screen to access the form builder.
  2. Now click on the fourth step of the form builder, Completion Actions.
    Screen_Shot_2022-08-17_at_9.23.49_PM.png
  3. Click on the Thank You Code tab and check the Always display form after submission box.
    Screen_Shot_2022-08-17_at_9.24.42_PM.png
  4. Copy and paste the following code snippet and hit the Confirm & Save button.
    <script> 
    window.parent.postMessage({
    message: "PARDOT_FORM_SUCCESS",
    }, "https://your-main-website-domain");

    // This bottom line is optional if you want to redirect to thank you page after
    form submission. Do not check the "Redirect to the following URL instead of
    showing the form's Thank You Content" box. The code will not fire if you do so.

    top.location.href = "https://domain-where-you-want-to-redirect"
    </script>

Create a Custom HTML Tag in Google Tag Manager that Listens for our Message Events and Pushes the Submitted Email to the Data Layer

Screen_Shot_2022-08-17_at_9.28.08_PM.png

<script> 
var email = "";

//Listen to Pardot events coming from the form builder
window.addEventListener("message", function (event)
{

// Once form data is ready, update email
if ( event.data && event.data.message === "PARDOT_DATA_READY" && event.data.email ) {
email
= event.data.email;
}

// Once form is submitted and validated, send event and email to data layer
if (event.data && event.data.message === "PARDOT_FORM_SUCCESS") {
window
.dataLayer.push({
"event": "pardot-form-submitted",
"pardot-form-email": email
});
};
});
</script>

Create a Data Layer Variable to Store the Submitted Email

The data layer variable name should be "pardot-form-email".
Screen_Shot_2022-08-17_at_9.31.27_PM.png

Create a Custom Trigger Equal to the Data Layer Event from Step 3

The event name should be "pardot-form-submitted."

Screen_Shot_2022-08-17_at_9.34.09_PM.png

Create a Custom HTML Tag that Fires on our Custom Trigger and Calls the Identify Method on Clearbit with the Submitted Email
Screen_Shot_2022-08-17_at_9.35.10_PM.png

<script> 
var email = {{
Pardot Form Email
}};
clearbit.identify(email, {
"email": email
});
</script>

Once you've completed all of these steps, you can test your Google Tag Manager through Preview mode or submit your changes and test your newly implemented identify call live. 🎉🥳