Patrick's Programming Blog

Scalable and Reliable Conversion Event Tracking in WooCommerce

Scalable and Reliable Conversion Event Tracking in WooCommerce

To run a successful eCommerce business you need to track checkouts also called conversions. You'll want to use data to connect those conversions to specific marketing channels and allocate your marketing resources appropriately.

WooCommerce of course offers built-in conversion tracking and offers several reports via WooCommerce Analytics.

Some of the top-line numbers in WooCommerce Analytics

And for a nascent eCommerce business these stats can work but as you grow you'll want to send conversion events to other tracking services.

Some of these have great integrations with WooCommerce (shoutout to Metorik!) and if you use services which have great integrations you can install those integrations and call it done. But there are thousands of applications and many don't integrate with WordPress or WooCommerce.

When that happens you'll have to write your own integration and then you'll need to think about when you send a conversion event, and how to do so in a way that doesn't slow down your website.

When to Send a Conversion Event

If you haven't worked with WooCommerce before you might be surprised to know there's no definitive time when you should send a conversion event. There are order statuses such as:

But, there's no enforced consistency. Order statuses are effectively controlled by your payment gateway.

At Xero Shoes we have several payment gateways all of which use different order statuses.

So if you write any custom functionality for your store to track conversions which order status do you use? Well if you only use one payment gateway and it consistently uses one order status you can use that. Many credit card processors use the Processing order status.

But if you don't want to write fragile code that may require updates in the future you should use a different hook.

At Xero Shoes we use the ThankYou page to send conversion events. And we use this page for two main reasons:

  1. It loads immediately after a customer places an order on the front-end of the site. It by-passes needing to know anything about order statuses.
  2. This hook let's you easily add client-side tracking events. This means that your Google Analytics, your Facebook tracking pixel, and your Klaviyo conversion event will all load invisibly to the user and send data from their browser to the tracking service.

But there is of course a problem with using the Thank You page for all conversion events. If you're sending backend API requests to tracking services that can slow down the Thank You page being sent to the customer. If the API is slow or entirely down yours customers might think they didn't checkout and generate customer service requests and duplicate orders. Not good.

To solve these problems we need to look into the Action Scheduler.

How to Send a Conversion Event – Action Scheduler

Action Scheduler is built into WooCommerce. It's also a stand alone plugin that can be included in your WordPress site even if you aren't using WooCommerce

Action Scheduler let's you … schedule actions. How apt-ly named. 😃

Think of it as a programmatic post-it that says “remember to buy milk on Thursday”. On Thursday your website will go out and buy milk.

What's so useful about Action Scheduler on the Thank You page is that you can schedule an action to fire a conversion event a minute after the order is placed.

That means that the customer will load the Thank You page quickly and your store still sends conversion events in near real-time.

Here's how this looks in practice:

We recently updated one of our API-requests from sending the event on the Thank You page to sending that same event through the Action Scheduler and the Thank You page loads a whopping 8 seconds earlier! 🤯

That's good for our customers and it also makes our website more reliable and stable since we aren't relying on an API being online at all times.

If you are still manually sending back-end API requests on the Thank You page or using one of the hooks above you should send your events asynchronously and improve your website reliability & stability.

Exit mobile version