Pardot is an email marketing and lead generation tool that runs along side and in tandem with Sales Force.  It does an excellent job of tracking initial source campaigns for individual email addresses/users in its system.  This is a great tool to match lead generation to sales or donations.

One item, however, that Pardot does not do well, is eCommerce (I know, right?)  There is no true mechanism for managing eCommerce purchases and recording it in Pardot.

Mind you, SalesForce can of course handle a purchase, but if you use Pardot as the mechanism to track lead generation effectiveness (email, social spends or AdWords etc…) versus eCommerce Sales, how can you track a purchase as an event in order to match lead generation costs to actual sales?

Website already connected to Pardot via Gravity Forms

I have a non-profit client with an active WordPress website.

Previous connections were easier- namely Gravity Forms:

Gravity Forms manages donations and lead generation- and submits both types of activities to Pardot via Form Handlers.  These events are handled with Pardot Form Handlers setup to fire through Gravity Forms Confirmation Events upon form submission.  I use confirmation events and not the Webhooks Gravity Forms Addon because it is the web user’s web browser that needs to be directed to Pardot for cookie tracking management.

(You can find tools that connect Gravity Forms to Pardot without cookie and tracking management (like Zapier) , but that’s really against the purpose of Pardot.

Additionally, separate Gravity Forms Web-to-Lead tools submit donation details as opportunities to SalesForce in tandem.

Connecting WooCommerce to Pardot

To connect WooCommerce to Pardot, I used the already working Pardot Form Handler tool that I am comfortable with.  This gives me a way to bring data in to Pardot.

Like the Gravity Forms implementation mentioned above, Pardot needs to be visited by the user’s web browser in order to handle cookie management and campaign tracking.

The question becomes- where in the Order Placement process can we send users away from WooCommerce to Pardot, and then have them come back to WooCommerce as if nothing happened?

The answer is simply at the end of the process- just before the Thank You Page.

Commandeering the WooCommerce Thank You Page for Pardot

Just like our Gravity Forms Submission through Pardot, we can insert Pardot as a pass through entity on the Way to a Thank You Page.  The below code, implemented in your theme’s functions.php or similar, will use a Pardot Form Handler instead of the basic WooCommerce Thank You Page.

One thing that helped me to orient myself to how Pardot works was to imagine Pardot as a hoop that has to be jumped through, and not a 3rd party application that needs to be contacted.  The result was my crazy drawing, and then the code:

This code was written successfully against WooCommerce 3.3.5.

//Override the main Thank You Page to push to a Form Handler Instead/
add_action( 'woocommerce_thankyou', 'remarkable_redirectpardot',1,1);

//Run This function in place of The Regular Thank You function
function remarkable_redirectpardot( $order_id ){

//Understand what the order is
$order = wc_get_order($order_id );

//setup pardot form handler url
$pardoturl = 'https://go.pardot.com/x/xxxxxxxx/xxxxxxxx/xxxxxxxx';

//gather personal information from order $fname=$order->get_billing_first_name(); $lname=$order->get_billing_last_name(); $addy1=$order->get_billing_address_1(); $addy2=$order->get_billing_address_2(); $city=$order->get_billing_city(); $state=$order->get_billing_state(); $zip=$order->get_billing_postcode(); $country=$order->get_billing_country(); $phone=$order->get_billing_phone(); $email=$order->get_billing_email(); //build the submission string we will send to the Pardot Form Handler $urlsubmissionstring=$pardoturl . "?fname=".$fname ."&lname=".$lname ."&addy1=".$addy1 ."&addy2=".$addy2 ."&city=".$city ."&state=".$state ."&zip=".$zip ."&country=".$country ."&phone=".$phone ."&email=".$email; //Ship It and Stop Processing wp_redirect($urlsubmissionstring); exit;
}

From this point, we have to trust Pardot to send our user back to a real thank you page.  I have created a custom static page called /order-complete/ to stand in as the Thank You Page.

Opportunities to Upgrade

You may notice that the above code does not actually submit order information (products ordered, order total, etc..) For this, our organization continues to use SalesForce to record that direct information (we use a WooCommerce to Sales Force Zap from Zapier).  While we could certainly send totals to Pardot, it was not necessary- we are only using this Pardot even to capture the user’s campaign process and be accurate in our user trail recording.

One trade off that this code affects is that of the functionality of the Thank You Page.  The standard WooCommerce Thank you page lists an order #, order details, etc.  This code, currently does not (because we exit WooCommerce and go to Pardot)

If desired, this code could be customized to send an order # to Pardot, record that  order #, and then send it back to WooCommerce.  A new, custom Thank you page could ingest that order #, and reflect the order details of the default WooCommerce Thank you Page.

If your organization needs some help with adding some connector coding for Pardot, please reach out.  I work on a project and retainer basis as needed.

Leave a Reply

Your email address will not be published.