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.

  • Website event tracking (Google Analytics, Heap, etc.)
  • Email marketing software (Klaviyo, MailChimp, etc.)
  • Help desk software
  • Affiliate software
  • Ad tech (Facebook Ads, Google Ads, etc.)

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:

  • On-hold
  • Pending
  • Processing
  • Completed

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.

  • PayPal & Klarna put orders in Pending
  • Braintree puts orders into Processing
  • If someone places an order via check orders are placed into On-hold
  • And we don't mark orders as Complete until they've left the warehouse which takes between 1-3 days. Enough of a delay to totally mess up conversion tracking.

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:

<?php
/
* Example Sending Conversion Event via Action Scheduler
*/
if ( ! function_exists( 'update_event_tracking_software' ) ) {
/
* Handle order status changes and send events to event tracking software PAP updates.
*/
function update_event_tracking_software( $order_id, $old_status, $new_status ) {
// Schedule an API request to Event Trackig Software in the background
as_schedule_single_action( time(), 'event_tracking_change_order_status', array( $order_id, $status ) );
return;
}
}
add_action( 'woocommerce_order_status_changed', 'update_event_tracking_software', 10, 3 );
// Add actions for the Action Scheduler to run our asynchronous callback function (below)
add_action( 'event_tracking_change_order_status', 'event_tracking_change_order_status_callback', 10, 2 );
if ( ! function_exists( 'event_tracking_change_order_status_callback' ) ) {
/**
* Send conversion event to Event Tracking software
*/
function event_tracking_change_order_status_callback( $order_id, $status ) {
// Continue writing your code here.
// Action Scheduler will run this code in the background
// Send an API request.
// @see https://developer.wordpress.org/reference/functions/wp_remote_post/
}
}
?>
view raw functions.php hosted with ❤ by GitHub

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.

How to Make the WooCommerce Sale Price Accessible

How to Make WooCommerce Sale Price Accessible

I recently joined Xero Shoes. They're one of the largest WooCommerce stores in the world. And as luck would have it we received the results of an accessibility (a11y) audit right after I started. That meant my first project is to dive deep into accessibility with WordPress & WooCommerce.

And the first item I looked into was making sure our sale prices were accessible. 👇

Continue Reading…

Liquid Web – Managed WooCommerce Hosting Review

Quite often in the WooCommerce world you'll hear “make sure you use a good host” which sounds helpful but when you don't define what a good host is it becomes meaningless. And for many first time store owners how are you supposed to know what you need and if a host has those features?

I've heard a lot about Liquid Web but I hadn't actually seen the backend until recently, when they gave me an account to play around with. So I'm going to show you how to create a brand new WooCommerce site using Liquid Web's Managed WooCommerce Hosting plan.

A friend of mine runs a WooCommerce store selling sunglasses so let's recreate that site using Liquid Web's infrastructure.

Note: Liquid Web paid me for a few hours of my time to review their hosting.

Continue Reading…

Combining WooCommerce & Gutenberg

Printing Press from Gutenberg

With Gutenberg getting closer and closer to being merged into WordPress core lots of plugins are thinking about ways they can take advantage of the new interface.

WooCommerce has been preparing for Gutenberg since last year. They're replacing the old [products] shortcode with a Gutenberg block and overall it looks great. If you want to display a specific set of products on a page the interface is phenomenal.

This is a great place to start and store owners can play with that functionality the day Gutenberg comes out. While this is a great place to start it's no where near where it's going to end. Gutenberg gives site builders so much control over their blog posts & pages. And eventually I'd like to see that same control applied to product pages.

Continue Reading…

WooCommerce Security

Airport Security

I talk about the features about eCommerce platforms all the time. But I don't often talk about related but important concepts. Every store owner has thought about security and how to keep their store safe both for their customers and so they don't get sued. When it comes to security there are two things you need to worry about.

  1. The security of your site
  2. The security of payment information

Continue Reading…

Metorik: The Missing Analytics for WooCommerce

Metorik Banner

I've written about WooCommerce reporting in the past. And at that time the best solutions were plugins you installed yourself. That's no longer the case. Metorik is a service designed specifically to understand your WooCommerce data.

Metorik was created by Bryce Adams who used to work for WooCommerce. So it's well built, well designed, and it enhances the reporting experience in WooCommerce. And not just a little bit. But a lot.

Continue Reading…

How to Add a WooCommerce Announcement Bar

Announcement Banner

Imagine it's the week before Xmas and you realize you forget to get a present for someone. You start looking for the perfect gift and you manage to find it. It's exactly what this special someone would love.

You add it to your cart and as you start looking at the shipping options you realize you don't know if it will arrive in time. There's “free shipping” – who knows how long that will take. And there's “expedited shipping” which will probably get there on time but you don't know if it's worth the extra $20.

You start googling rates, prices, and shipping times and you go down a rabbit hole and might never come back to that site.

It's the holidays and we're approaching the cut off date to get presents on time. As a store owner you want to let your customers know the last day they can order and still get presents. This does two things:

  1. It removes uncertainty. If you're uncertain if the present will get there on time you might not order. Or if you have to do a bunch of work to guess if it comes on time you might just get lost down the rabbit hole and never come back and order.
  2. It creates urgency. When users come to your site and they see a banner that lists the last day to order it creates pressure. They don't want to forget the present and they don't want to miss the cut off date. They will be more likely to buy right now.

Continue Reading…

Selling Videos with WooCommerce

Computer Screen Selling Videos

There are a few different WooCommerce Facebook groups and all of them have great discussions. Earlier today there was a question about selling videos with WooCommerce:

If I have video files in a cloud storage independent from my WordPress site can I link those videos and sell them as digital, downloadable products? I don't want to store videos in my WordPress site.

The short answer is yes – WooCommerce can sell downloadable videos (or any sort of downloadable product).

Continue Reading…

Easy Membership Sites With WooCommerce Memberships

Lock

Two years ago I wrote a post about how hard it was to setup a membership website with WooCommerce. It took twenty two steps and it required two plugins.

Not ideal.

At the time we thought it best to integrate with an existing solution that already had some users. Sounds smart but it forces users to go through the extra steps to make the integration work. And as someone who has to setup his own site & his own accounts I hate when someone drags me through extra steps.

End users don't care what powers their technology. They just want to solve their problem. Which is why we set out to build an entirely new system.

Continue Reading…