How do I fix a truncated or rounded revenue or price value?
If you installed Matomo Analytics before Matomo 4.0, a revenue or price value might be truncated or rounded when the value is high. For example if you track a value of 12225201
, the value might be stored as 12225200
.
If you track high revenue or price values, you can fix this issue by running a database migration script like this:
ALTER TABLE `matomo_goal` CHANGE `revenue` `revenue` DOUBLE NOT NULL;
ALTER TABLE `matomo_log_conversion_item` CHANGE `price` `price` DOUBLE NOT NULL;
ALTER TABLE `matomo_log_conversion` CHANGE `revenue` `revenue` DOUBLE NULL DEFAULT NULL;
ALTER TABLE `matomo_log_conversion` CHANGE `revenue_discount` `revenue_discount` DOUBLE NULL DEFAULT NULL;
ALTER TABLE `matomo_log_conversion` CHANGE `revenue_shipping` `revenue_shipping` DOUBLE NULL DEFAULT NULL;
ALTER TABLE `matomo_log_conversion` CHANGE `revenue_subtotal` `revenue_subtotal` DOUBLE NULL DEFAULT NULL;
ALTER TABLE `matomo_log_conversion` CHANGE `revenue_tax` `revenue_tax` DOUBLE NULL DEFAULT NULL;
Please note running this update script may alter your existing values. For example, if previously a value of 4.1
is stored, it might convert it to 4.099999
. As a result, for example a changed value might not match a specific segment anymore.
If you’re wanting to test this first, you may compare the output of this SQL query (this query may run a long time):
SELECT price, CAST(price as DOUBLE) FROM matomo_log_conversion_item WHERE price is not null ORDER BY price ASC LIMIT 10000;
SELECT revenue, CAST(revenue as DOUBLE) FROM matomo_log_conversion WHERE revenue is not null ORDER BY revenue ASC LIMIT 10000;
SELECT revenue, CAST(revenue as DOUBLE) FROM matomo_goal WHERE revenue is not null ORDER BY revenue ASC LIMIT 10000;
To see if any value would be changed as it depends on your MySQL version. Integers (numbers without a fraction part) should remain generally unchanged.