How can I pass a Webflow form input into a Pardot form input for a modal?

Published on
September 22, 2023

To pass a Webflow form input into a Pardot form input for a modal, you can follow these steps:

  1. Set up your Pardot form: Create a form in Pardot with the desired form fields, including the ones that you want to populate with the data from your Webflow form.

  2. Get the Pardot form embed code: In Pardot, go to Marketing > Forms and locate your form. Click on the form name and then select "Embed Code" from the dropdown. Copy the entire embed code.

  3. Add custom code to your Webflow site: In Webflow, open the project where your form is located. In the Designer, select the page where the form is and click on the "Pages" tab in the right sidebar. Open the page settings by clicking on the gear icon next to the page name.

  4. Add the Pardot form code to the page settings: In the page settings, scroll down to the "Custom Code" section and paste the Pardot form embed code into the "Head Code" field. Save the changes.

  5. Add custom code to the Webflow form: Go back to the Designer and select your form element. Open the element settings by clicking on the form element, and then go to the "Custom Attributes" tab in the right sidebar.

  6. Add a custom attribute to each form input: For each form input that you want to pass to Pardot, add a custom attribute with the name "data-pardot" and set its value to the corresponding Pardot form field name. For example, if you want to pass the value of the "Name" field, set the custom attribute to "data-pardot="first_name"".

  7. Add custom code to capture form submission: Go to the "Project Settings" in Webflow and navigate to the "Custom Code" tab. In the "Footer Code" section, add a script that captures the form submission event and populates the Pardot form. Here's an example script:

<script>document.addEventListener("DOMContentLoaded", function() {  var form = document.querySelector("form");  form.addEventListener("submit", function() {    var inputs = form.querySelectorAll("input[data-pardot]");        inputs.forEach(function(input) {      var fieldName = input.getAttribute("data-pardot");      var fieldValue = input.value;            if (fieldName && fieldValue) {        var pardotField = document.querySelector('input[name="' + fieldName + '"]');                if (pardotField) {          pardotField.value = fieldValue;        }      }    });  });});</script>
  1. Publish your Webflow site: Once you've added the custom code, you can publish your Webflow site to make the changes live. Test your form to ensure that the data is being passed correctly from Webflow to Pardot.

By following these steps, you should be able to pass the inputs from your Webflow form into a Pardot form for a modal.

Additional questions:

  1. How do I create a form in Pardot?
  2. Can I pass form data from Webflow to other marketing automation platforms?
  3. What is the purpose of custom attributes in Webflow form inputs?