How can I pass a Webflow form input into a Pardot form input for a modal?
To pass a Webflow form input into a Pardot form input for a modal, you can follow these steps:
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.
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.
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.
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.
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.
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"".
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>
- 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:
- How do I create a form in Pardot?
- Can I pass form data from Webflow to other marketing automation platforms?
- What is the purpose of custom attributes in Webflow form inputs?