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
Ecommerce Product average price may be incorrect, review implementation without using Custom Variables #12035
Comments
Just had a look and the queries itself in the standard ecommerce plugin looks good. Just to be sure: Are you using the standard ecommerce reporting plugin in Piwik or did you write your own custom reporting plugin? If so, it is open source and we can have a look at it? |
I'm using the standard ecommerce build in reporting functions of piwik yes... |
Just to avoid any confusion. Do you mind letting me know which report you are looking at and experience this issue? |
I'm looking at ecommerce -> product then both "product code" and "product name" reports show incorrect average price data |
When you see an Average Price... does it show next to it a number for "Unique purchases"? Do you mind commenting this line https://github.com/piwik/piwik/blob/3.1.0/plugins/Goals/API.php#L324 meaning putting By looking at the code I can think of two problems which makes me think there really is a bug. The referenced link which renames "privce_viewed" to "avg_price" and then it does not calculate a proper value anymore... and there are also filters like Average Price https://github.com/piwik/piwik/blob/3.1.0/plugins/Goals/Columns/Metrics/AveragePrice.php#L42-L46 where we fall back and divide by abandoned cards instead of orders (but I don't think this is the problem) |
As an example, here after the report gives me from september 8 to september 12: And here after the report gives me from september 12 to september 12: In the database, I extract with this query: And I obtain (CSV): |
In the example I provided, the unique purchase is empty. But I've found other example were the unique purchase is 4 (for also 4 unit purchased) and the problem still occurs I've commented the line as indicated. |
any update on the issue? |
The price "should" be correct when there are unique purchases. When there are no purchases, the price should be zero as well I'd presume but maybe not @mattab ? I'd find it very confusing to not see any purchases but then still see a price. Are you sure your custom woocommerce tracker plugin is tracking the orders etc correctly? You should probably compare the shown pricing information with data from Commenting the other line I mentioned should still leave the price when there are purchases but set all others to zero. |
FYI: the reason you can still see a price when there is no purchase, is when the following feature is used: "Tracking Product Page Views & Category Page Views (optional)" see the guide: https://piwik.org/docs/ecommerce-analytics/#tracking-product-page-views-category-page-views-optional |
Indeed, as matab pointed out, this is what I have implemented in my code. |
@mattab be good to make this more clear in the UI. I did not expect this behaviour... Eg beside "Ecommerce orders and Ecommerce abandoned carts" I would have expected another item "Ecommerce views" or "Product views" etc. @rosnoun do you have this problem only for week / month / year periods or also when only viewing a day? Looks like the average is calculated directly in MySQL which looks to me like this might not be showing correct values when viewing for week/month/year/range in https://github.com/piwik/piwik/blob/3.1.1-b1/plugins/CustomVariables/Archiver.php#L125 Next problem is that it looks like it generates an average of all custom variable values here even if the custom variable slot is used for something else: https://github.com/piwik/piwik/blob/3.1.1-b1/plugins/CustomVariables/Archiver.php#L112-L114 After seeing this and quickly debugging it I stopped any further investigation as it is clear this feature was not properly implemented and needs to be re-built in a less "hacky" way. The data it generates may be quite buggy as you pointed out @rosnoun . As the feature might require schema changes we cannot work on it before Piwik 4.0 |
@tsteur as per your suggestion, moving this issue to Piwik 4 where we'll try to improve the implementation of Ecommerce view tracking. |
@sgiehl not quite sure. Could maybe move it out of Matomo 4. Maybe look at the initial comment again and this
I'm not quite into the topic anymore so not quite sure what is happening there. Maybe we can fix some archiving queries. In general it seems like ecommerce misuses the custom variables feature which we remove in Matomo 4? In that case would need to migrate this logic. |
@sgiehl Maybe we could hijack this issue and change scope to "Remove custom variables in ecommerce implementation" (or create a separate issue, and move this one out of Matomo 4) |
@tsteur @mattab just had a look at the way custom variables are used for ecommerce. It actually only affect ecommerce product views, where category, price, name and sku are tracked in custom variables. Thought about just moving those in separate columns, like we did for search category and count, but I'm unsure if that would be the best solution. We actually already have dimensions for product name, price, category and sku, but those are in the Actually I wonder if it would make sense to change the Any thoughts / suggestions? |
Might work to use the existing table 👍 |
Just had a look into tracking, archiving, and storage etc how it all works. If I see this correctly, so far as part of a page view we track basically these additional 4 values in the log_link_visit_action table
Random first thought I had would it make sense to keep 5 On the other side conversion_item may allow us to potentially store more values, but then also wondering are we removing the hack that was used with custom variables just to now add a hack around "conversion items". In this case it's not a conversion item, there is no value for the orderId primary key etc. Another random thought was what if "product view" was a specific action just like outlink etc. Then we could reuse With conversion item would indeed need to make sure existing segments still work the same way and they apply a filter on the |
I think the solution depends on the goals we want to achieve. Having additional "product view" actions has various advantages. Same applies for modifying and reusing the
|
Not sure on the multiple product per page view, multiple categories, and more reports. It be nice probably, at the same time it be great to maybe ignore this for now and focus on the problem itself as these feature wouldn't have a big impact for now. In a few years we might want the feature though (could then still migrate the DB who knows what the DB will look like then as we then might also add other things like refunds, etc).
The old product segments should stay and they should behave the same. Eg if we used the items table, then the segment should automatically only consider the items from orders. A new segment for product view items is not needed for now (be a different issue). If it comes easily out of the box with whatever implementation we go with, we take it I guess. It maybe shouldn't influence the decision though (hoping that helps). I thought it be great to keep the data in I have not really a big preference. Is there a way you can estimate how much work it be to use the items table? |
Actually I didn't even know how product views are displayed in Matomo, so I've now adjusted the VisitorGenerator to add some random views (matomo-org/plugin-VisitorGenerator#54). So we currently have no reports that displays the product views. They are filtered out of the custom variables reports and even in the visitor log they are displayed with their tracking parameter: But as they are stored as custom variables it's kind of possible to segment by it if you know which parameter is what. Back to the new implementation. Simply adding new columns in log_link_visit_action table, as we did for search category / count is quite easy to do and to migrate. Adjusting the log_conversion_item table would be a bigger load of work I guess as we would also need to adjust the whole implementation of ecommerce sales. Unfortunately I'm not very deep into that whole ecommerce implementation, so it's hard for me to estimate that properly without spending some hours to look that through. |
@mattab can you confirm it's only used there? Is the feature even all that valuable then? Maybe could deprecate it until we eventually decide to implement a better implementation of it with more features? Just looking at the UI (not code)... is it maybe used in the product conversion rate? |
No doesn't seem so: matomo/plugins/Goals/Columns/Metrics/ProductConversionRate.php Lines 41 to 48 in 1155273
|
Thanks. Honestly, if that's all it does, I'd remove this feature and add it back later. @mattab |
The feature is used to calculate:
both are visible in the Ecommerce > Product reports. They are valuable, but if it's too hard to keep this feature we could possibly remove it...
What would be estimate for this? or is there a downside with it? (btw If we decide to remove the feature, users could still get the same "Product views" metric by Tracking a custom dimension of action scope in each product view. But I don't think they could get "Product conversion rate" in a custom report (because custom dimension of action scope don't yet have "per-goal" conversion metrics. if we had that, we could easily delete the "Product view" feature without any loss of feature)) |
Ok. So how shall we proceed? moving that into new columns should be quite easy and fast to implement. |
@sgiehl no big preference. I'm tempted to simply remove it but if it's quick and easy to do feel free to put it into new columns. Wonder if then we just have these as custom link action columns that could be also used by other types eventually? Similar to |
Tried to start implementing that by moving the custom variables into new fields. But it imho doesn't make much sense to continue here. That seems much more comprehensive than I thought in the first place. I've now realized how the product views are integrated into the product reports. matomo/plugins/CustomVariables/Archiver.php Lines 106 to 112 in 1155273
matomo/plugins/CustomVariables/Archiver.php Lines 213 to 225 in 1155273
It also seems possible to set multiple categories for a page view, which is then splitted while archiving: matomo/plugins/CustomVariables/Archiver.php Lines 185 to 211 in 1155273
All those special reports are than used to enrich the product reports when the API is called: Lines 749 to 797 in 1155273
Actually I guess we could move that all to the Goals archiver and do some additional queries there, to get those data directly while archiving (and no longer combine that in API). But I doubt it make sense to store that in those new fields at all. Storing multiple categories in one field isn't that good. Also the conversion_item table only stores ids for name, sku and category[1-5] (linked to log_action table), so imho it would make sense to do the same for product views. But adding id fields to the log_link_visit_action table makes it impossible to convert existing data while updating. So we would need to break BC and need to provide a migration script for those who need the data... Long story short: Shall I go on with that, or shall we discuss other solutions? |
@sgiehl sure happy to discuss other solutions. Do you have any preference? Maybe give that preference a quick try for few hours to see if would work? |
When looking to the ecommerce products report, the average product price display incorrect value. The value seems to be multiplied by number of days for which there has been visit on the product page.
I've check that all my visits log product information report correct values directly into the database...
Piwik 3.1.0
Custom e-commerce report plugin (woocommerce)
The text was updated successfully, but these errors were encountered: