How to integrate WordPress with Pardot using Gravity Forms

Pardot logo

I was recently working with a large corporate client that uses Pardot to track the activity of their users. As we started talking about how to integrate their new site with Pardot, they indicated that they wanted to be able to show premium content to subscribers of their newsletter.

The methodology

We looked at several ways of doing this, including querying the Pardot API to check whether the user was a prospect in their system. However, we determined that doing so would result in an unnecessary delay to the user.

Since the Pardot cookie does not provide identifying information that would allow me to determine whether a user was a prospect or not, I came at the problem from a whole different angle.

Instead of retrieving information from Pardot, I would instead rely on my own information and only send information to Pardot.

What this meant was that I would create a form for signing up to the newsletters using Gravity Forms (consisting merely of an email field, though it could have included name, company and any other information) and then send that information to Pardot. If the user already existed, it wouldn’t duplicate the user (important), and if they didn’t exist, it would create them as a new prospect. In each case, it would make sure that the user got subscribed to the lists specified by me.

Once the form was submitted, I set my own cookie in the browser and that way, I knew definitively that the user had subscribed to the newsletter. I set the expiration way off into the future so that they wouldn’t be bugged again for their email address unless they deleted their cookies.

I could then systematically check for the cookie and modify the site for the end user depending on whether or not they had subscribed to the client’s newsletter, such as hiding premium content, limiting commenting ability etc.

How I did it

Now for how I actually did it.

Like I said, the first step was to create a Gravity Form that would collect just an email address.

The next step was to create a Form Handler in Pardot. Log in to your Pardot Control Panel and go to Marketing > Forms > Form Handlers.

From there, you need to add a descriptive name for the Form Handler, select the Campaign that the form is associated with, set the success and error locations, add your completion actions, and set up fields for all of the information that you will be sending to Pardot.

In my case, I set the success and error locations to the Referring URL, because I wanted the user returned to the same page that they were on when they filled out the form (for example, they could then immediately read the article that they were previously restricted from). For the completion actions, I set the lists that I wanted to add the user to. Lastly, since I was only sending an email address to Pardot, the default field (’email’ = Email) was sufficient for me, though you may need to add more if you’re capturing names etc.

Pardot Form Handler

Once you save the Form Handler, you’ll need to retrieve the endpoint URL for the Form Handler. This is where our Gravity Form will send the data.

Now, back to your Gravity Form. Go to Settings > Confirmations and edit the default one. The type of confirmation should be Redirect and the Redirect URL should be the Endpoint URL from your Pardot Form Handler. Then, check the box for “Pass Field Data via Query String” and add all of the fields that you’ll be sending to Pardot along with the parameter names you set up earlier.

Gravity Form confirmation for Pardot

Your site is now talking to Pardot and if you test your form, you should see your information appear as a new prospect in Pardot, with the appropriate completion actions taken.

One final piece of the puzzle for me was to set a cookie in the browser once the form was submitted, and to then check for it when I needed to protect content, or a feature.

To set the cookie, I used the following snippet:

And to check for the cookie and restrict content accordingly, I used this code:

So that’s how I used Gravity Forms to create a link between WordPress and Pardot, which helped my client to increase readership and subscriptions to their publications.

If you’d like to discuss something similar for your own project, please get in touch with me.

Get a Gravity Forms license

6 thoughts on “How to integrate WordPress with Pardot using Gravity Forms”

  1. Lars Faye says:

    Fantastic. It’s people like you who make working on the web such a unique and fulfilling experience. I JUST found out today I have a project coming down the pipeline that will need to connect GF to Pardot/Salesforce and now I can come to the table with a solution before we ever even need it! Thank you a million times over!

  2. Ty Murphy says:

    Thank you for your post, this worked great for us! One question we had is our google analytics code is not getting transferred through the form handler and back to the success page, so all our submissions are showing up as from referral sources instead of search/paid media, etc.

    Where did you place this php script to carry the cookie? I believe this might be our solution as we were unsure where this snippet goes in regards to our website/landing page. Thanks!

    1. Hmmm I’m not sure how your tracking code is getting applied to the form, or how the cookie is relevant, but at any rate, I added the snippet for setting the cookie in a custom plugin that contains all of my Pardot functionality.

  3. Gary says:

    Hi, Great post. This is just what I was looking for. When working with the ‘redirect query string’ how did you format fields such as ‘First Name’? Did you leave the space or use a hyphen or underscore between first and name? I can get this to work with the single word fields but it seems to go off the rails when I run into the two word fields.

    1. I think I just kept them as single words, such as fn or firstname

  4. Ross Hopkins says:

    Hi, this doesn’t work for me and SalesForce have advised it is due to Gravity Forms having an enctype of multipart. This can be updated to ‘x-www-form-urlencoded’ but then this means any form with a file upload field will not submit, regardless if you’re posting/mapping that particular form to Pardot or not.

Leave a Reply