How Do I Track Conversions With WooCommerce?

Knowledge Base > Premium > Compatibility > How Do I Track Conversions With WooCommerce?

in CompatibilityPremium

Simple Page Tester with the Premium add-on will let you run split tests for any Custom Post Type available on your WordPress installation.

People often use this to test product pages, especially on WooCommerce.

But the catch them becomes how do you track a conversion? WooCommerce by default doesn’t have a thank you page so what you have to do is create a snippet of code to place in your functions.php file in your theme:

function trackConversionForSplitTest($order_id) {
    sptRecordConversion(array('id' => '123'));

add_action('woocommerce_thankyou', 'trackConversionForSplitTest');

This snippet of code gets called when the Thank You for your order message is displayed to customers after purchase and is a great place to tell Simple Page Tester of your conversion.

The line inside the function is available for copy and pasting from your test edit screen under the “Advanced Users” section of the Conversion Code box on the right.

Click on the +Show Template Code button and it will display the template code for tracking a conversion which looks something like “sptRecordConversion(array(‘id’ => ‘123’));” where 123 is your test’s unique ID.

I hope this helps you track your conversions on WooCommerce, if you would like to see what else the Premium version can do check it out here.