When using Pardot Forms that are embedded as an iFrame, we use DOM event messages to pass the form submission data along and present a Calendar once Pardot verifies that the submission went through.
Note this does not work with the native Pardot landing page implementation code, and the implementations are not interchangeable. If you update the code below, make sure you update it in all areas.
This article will cover how to successfully implement Chili Piper with Pardot forms embedded in an iframe:
- Add custom code to your Pardot form settings
- Optional
Look & Feel → Below Form Code Editor
Before we begin, have your domain and router name at the ready. Your domain and router names are found in your inbound router under the Embed code section -
In Pardot, navigate to your form, under "Look and Feel" open the "Below Form" Source code, and add the script from the GitHub linked below, being sure to follow directions to replace [[domain]] with your domain and [[router_name]] with the correct router name.
In Pardot, navigate to your form, under "Look and Feel" open the "Below Form" Source code, and add the script below, replacing "calendar" after "var tenantDomain = " with your domain and "test" with the correct router name.
Please get the latest version of this implementation from GitHub.
Paste the code in as shown here:
Hit Confirm & Save
Completed Actions → Thank You Code
Add the Following Code to the Completed Actions → Thank You Code
<script>
window.parent.postMessage(
{
message: "PARDOT_FORM_SUCCESS",
},
"*"
);
</script>
Parent Webpage Code
Add the Following Code to the Parent Webpage in which the Pardot Embed HTML code resides.
<script src="https://js.chilipiper.com/marketing.js" type="text/javascript" async></script>
<script>
var leadObj = {};
//Below is the event listener that will listen for the Pardot Events
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
// Form data ready, update leadObj
if (event.data && event.data.message === "PARDOT_DATA_READY" && event.data.data) {
leadObj = event.data.data; // Update leadObj
}
// Form was submitted and validated, call ChiliPiper
if (event.data && event.data.message === "PARDOT_FORM_SUCCESS") {
// Account domain and router name are from Step #1 - no need to change it here
ChiliPiper.submit(leadObj["CPTenantDomain"], leadObj["CPTenantRouter"], {
map: true,
lead: leadObj,
});
}
}
</script>
Custom field names using CSS class names
When looking for field names to use, we check the CSS class names first, then placeholders and labels. Sometimes your form labels need to be complex and include some simple instructions, making the label hard to read and use for mapping in Chili Piper. With this implementation, you can specify field names using CSS Class names in Pardot. This will make mapping easier and more predictable.
Here is how to specify a CSS class name on a Pardot field:
- Open your form in Pardot and click the Edit Button - Fields - Small Edit icon next to the field.
- From here, click on Advanced and enter a CSS Class name starting with "CP_".
For example, "CP_FirstName". - That's it! Now save and repeat for any other fields you want to specify a name for.