Pardot Knowledge Base

Using Form Field-Based Completion Actions

Last Updated: Jun 28, 2016 | Print this Article
 
Whoa there, partner! This is an advanced topic that involves custom script. Troubleshooting custom script is outside of Pardot Support’s scope, so proceed with caution.

You can use a simple script and form handlers with Pardot forms to perform completion actions based on field values that prospects choose. For example, you could assign the prospect to a user when they choose "Yes" in a field, or you could send them an autoresponder email if they choose "No". Although this seems similar to running an automation rule, using this method lets the completion actions trigger every time the same prospect fills out the form -- automation rules only run once for the same prospect.

Note: If you just want to set a profile or add prospects to a list based on form field selections, this article outlines an easier way to do so.

Before you begin

Before you begin, you'll need to create a Pardot form, and you'll need to set up form handlers with completion actions for each field value you want to add completion actions for. For example, if you want to perform different completion actions for the values "Yes" and "No", you need two form handlers, each with the appropriate completion action.

Example Form Handler: Here's a form handler set up to assign prospects to a user, change the Contract custom field value, and adjust the prospect's score (over the default). Later, when we edit the script, we'll associate the value "Yes" with this form handler, and when a prospect chooses it on our form, they'll trigger this form handler's completion actions.

Form Handler Completion Actions  

Important Notes:
  • Make sure that Always display form after submission is marked on the Pardot form that you use — otherwise this method will not work, and your Thank You Page and script will run in a loop!
  • This will not work with multi-select or checkbox fields with multiple values.
  • Make sure that the fields you add in the form handler are NOT marked required unless you add additional parameters to the end of your form handler URL, otherwise your completion actions will not be triggered. See Step 6 below for instructions to include multiple required fields.
Once you've set up your form handlers and completion actions, you're ready to move on.

Setting up the script

Paste the following script to your Pardot form's Thank You Code:  
  1. Replace your_field_id with the Pardot field id that you want to perform completion actions based on. It must be wrapped in %%, and a {js} modifier must be added. For example, if your field id is custom_field_1, it should look like %%custom_field_1{js}%%
  2. Replace VALUE_1 with the value you'd like to trigger a completion action. For example, you want the value Yes to trigger the form handler, enter Yes.
  3. Replace FORM_HANDLER_1_URL with the URL for the form handler for VALUE_1. Leave the ? and everything after it.
  4. Replace VALUE_2 with another value to to trigger a completion action.
  5. Replace FORM_HANDLER_2_URL with the URL for the form handler for VALUE_2. Leave the ? and everything after it.
  6. If your form handlers contain required fields (other than email) you'll need to add additional parameters to the end of your form handler URLs, otherwise your completion actions will NOT be triggered. This example adds  required_field_1 and required_field_2 fields. Note that parameters are separated with an ampersand (&). 

Adding more than two values

If you'd like to trigger completion actions for more than two values, you can just add more cases to the script. Just copy this snippet, and add it between the last break; and } in the script above. 

Need more? Start a conversation with other Pardot users in our Success Community