This article will solve common revenue tracking erors in Optimizely for Shopify stores. Want to skip the explanation and get ready to use code? Click here.
Errors with high order amounts
After following the standard Optimizely revenue tracking guide for Shopify, our team noticed some supicious behavior in an experiment’s revenue tracking.
The issue appeared to be with high order amounts in particular – the example code given in the Optimizely guide will have unexpected behavior for orders of $1,000 dollars (or your currency) and over.
Here’s the guide’s code for reference (to be inserted into the Additional Scripts portion of your Shopify Checkout Settings):
This works fine in most cases, but if the order subtotal is $1,000 the liquid will output 1,000.00
, giving you the following:
In this scenario, revenueInCents is now equal to 0! Scary stuff. Instead of reporting 1k revenue for this user, 0 will be reported instead.
To solve this problem, use {{ subtotal_price }}
without the money_without_currency
filter. This will output its value in cents already, so no need to multiply by 100 again.
The updated code looks like this:
This will eliminate errors for high order amounts, and hopefully save you from headaches with results later down the line. I’ll be in touch with the Optimizely team to highlight the issue, and will update here if their guide is fixed.
Revenue being tracked multiple times for orders
This can occur if your code is not wrapped with the following:
Without the above, when your users check on the status of their order they will re-trigger any conversion scripts on the Thank You page (order status), including Optimizely’s.