Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overall Product Revenue calculated wrong #15981

Closed
beamylake opened this issue May 25, 2020 · 6 comments
Closed

Overall Product Revenue calculated wrong #15981

beamylake opened this issue May 25, 2020 · 6 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@beamylake
Copy link

Hello,

we've encountered a suspected bug in the ecommerce reporting section:

When looking at the monthly totals, it seems that the total revenue of a product is wrongly calculated if the average product quantity is bigger than 1. And the bigger the average product quantity is the bigger the error margin gets for this particular product.

ecommerce

When you take a look at the red marked example in the screenshot:

The product has a price of € 4,99.

This price multiplied with 344 (the quantity) gives a total revenue of € 1.716,56, which is the correct number. When you take the average price (€ 22,89) and multiply it with the number of unique purchases (75) the result is 1.716,75 which we also consider correct (disregarding the rounding margin).

But Matomo calculates the product revenue as € 11.107.70 - a number which we don't know, where it derives from.

We've checked the tracking input to Matomo and the prices were tracked correctly. That's why we suspect that Matomo somehow miscalculates the totals.
We are running Matomo 3.13.5 - if you need any further information please let me know!

Thanks a lot in advance!

@tsteur
Copy link
Member

tsteur commented May 26, 2020

Look like all other values except the product revenue look good. Interestingly the revenue for most other products looks good too?

Looking at the code the revenue should come from SUM(log_conversion_item.quantity * log_conversion_item.price)

Is there maybe anything different about this product?

Are you looking here at a daily view or weekly or monthly? In case you are looking at weekly or monthly, are some of the daily reports correct? Or all of them? Can you see the wrong data also for other periods?

@beamylake
Copy link
Author

beamylake commented May 26, 2020

The values besides the overall revenue are ok, but it's not only that particular product that is effected.

Basically all products are affected of this behaviour where the average quantity is bigger than 1, while products where the average order quantity equals one show the correct overall revenue.

You can easily check that by multiplying average price and unique purchases - the result of this multiplication matches the correct revenue for the product.

The screenshot above is from the monthly report, but this bug also occurs in the other report periods.

@sgiehl
Copy link
Member

sgiehl commented May 26, 2020

That is actually caused by the way the values are currently calculated and will only occur if you have the same product tracked with different prices.

Product Revenue = sum of quantity * price of each order
Quantity = sum of quantities of all order
Unique Purchases = Number of total orders
Average Price = Sum of all prices divided by unique purchases
Average Quantity = Sum of all quantities divided by unique purchases

So assuming we have this product orders

Quantity Price
4 3,50 €
1 2,00 €

That will result in this values

Product Revenue Quantity Unique Purchases Average Price Average Quantity
17,5 € 5 2 2,75 € 2,5

As you can see there is actually no way to calculate the 17,5 € with the other numbers shown.

@beamylake When you track a product with a quantity bigger than one, do you send the price for a single product, or the sum for all?

@beamylake
Copy link
Author

I'm sorry but I'm a bit confused, please help me out.

When I sell a product 344 times with a price of € 4,99 (red marked in my first post), how does Matomo come up with an overall product revenue of € 11.107,70 ? That would be a price per unit of about € 32, which is way too high for that product.

Imho the overall product revenue should be 344 x € 4.99 which is the correct number of € 1.716,56
Both numbers (price of € 4,99 and 344 sold items) have been confirmed through webshop backend reports. The price of this product has not been changed for the last 4 months (we're talking about the report for April here) and it's the same for all countries this product is sold to.

Regarding your question, I will check that and let you know.

@sgiehl
Copy link
Member

sgiehl commented May 26, 2020

That was just en example why the value can differ if you product price changes. But looking at the numbers of your report I would actually assume that you send the sum for all products instead of the price of a single one.

Your average price is reported as 22,89, but should actually be 4,99 if the price didn't change. If you divide your average price through the average quantity, you actually get something around 4,99...

@beamylake
Copy link
Author

Good morning,

I've got feedback from our devs and, as you suspected, it was the overall price that has been tracked and not the particular product price. So the error was clearly on our side.

Thanks for your patience and for pushing us in the right direction!

@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

3 participants