Skip to main content

Lifetime Value Calculation

· 4 min read
Aleksandar Vucenovic
Chief Growth Officer

featured image

There were some drawbacks in the previous implementation of the lifetime value calculation in the Pixel Manager. We have now fixed them and added some new features.

Problems with the previous implementation

  • For shops with large numbers of orders for the same customer, there was the risk that the calculation was incorrect.
  • The calculation took place while saving a new order. For shop customers with a large number of orders, this could have caused long load times, and in certain cases even a timeout error.
  • The calculation didn't take into account refunds.

New features

  • The lifetime value calculation of old orders is now done in the background, so it doesn't affect the loading time of the order page.
  • The calculation is done for all orders of a customer, not just the last 1000.
  • Auto detection of refunds and canceled orders. The lifetime value is now calculated correctly, even if the customer has refunds or canceled orders.
  • Auto detection if the calculation logic for the lifetime value has changed. If the logic has changed, the lifetime value is recalculated for all customers (during night time).
  • Button to manually recalculate the lifetime value for all customers. This is useful if you change the order value logic in the Pixel Manager settings or change the order value filter. The auto detection should pick it up with the next order that is saved. But, if you use a custom order value logic, depending on how the logic works, it might be necessary to manually recalculate the lifetime value for all customers.

Important to know

The lifetime value calculation is now done in the background using the Action Scheduler. But, there are things that you should be aware of.

Recalculation of a single customer

When a order is refunded or cancelled, only this order and all newer orders for the same customer will be recalculated. This doesn't happen instantly, but should take only a few minutes.

Recalculation of all customers

A recalculation of the lifetime value for all customers is more complex.

  • It will go through all orders of the shop.
  • The Action Scheduler that's running the calculation does its best to limit the load on the server. However, some hosting providers might still flag this. Since the recalculation of all customers should happen very rarely, this shouldn't be a problem.
  • The recalculation is scheduled to run at night when the server is under light load.
  • The recalculation of all customers should happen very rarely. It will happen the first time you update the Pixel Manager to the new version. And, it will happen if the Pixel Manager detects a change in the logic for the lifetime value calculation.

Action Scheduler

While the Action Scheduler is doing a real good job at limiting the load on the server and running the tasks in the background, it's not perfect.

We have seen cases where simple tasks run into a timeout error. Those cases are rare, but are likely to happen when a recalculation of all customers is triggered (on shops with thousands of orders). The Pixel Manager will automatically handle those cases and retry the task. You probably will see the timeout errors in the error log of your server.

From a technical point of view we are not sure yet if this is a problem with the Action Scheduler, with the server or with WordPress. Once we have more clues, we will report it to the respective developers.

Conclusion

The lifetime value calculation is now more reliable and more accurate than before.