I want to get your views on what ‘category’ should be set to when using the Ecommerce PHP API calls. There’s several categories that could be chosen in each scenario so I’m not certain which is best. Consider a product “Duck”, with the following category structure;
Types of meat ( A )
Tasty meat ( B )
Duck
Things that flap ( C )
Duck
ie. It can be navigated to in two ways (through C, or through A and then B ). In total it is in 3 categories (A, B and C), but with B being a child of A.
For the ‘dosetEcommerceView’ I have thought it best to track the category based on the ‘path’ GET variable (I am using opencart) - ie. the category you are currently in, or when viewing a product, the category you used to navigate to the product. I have also decided to merge categories into one string when they are parent & child, instead of passing as an array. For example if you are viewing ‘Duck’ after navigating A to B to Duck, then I have set the category string to “A > B” (instead of passing an array of [“A”, “B”]. Duck is still in category C - but I have ignored that in this case, because category C is unrelated to how the user has navigated. What would you choose?
This is the simple case however (!) - now I am looking at the ‘dotrackEcommerceCartUpdate’ call. This happens every time the cart is updated, added to, or deleted from - It can occur from any page on the site. So if the user is say on the homepage and deletes a product from their cart, what do you set as the category? My current thinking is to go with every category the product is in, but merged into one string where they are parent & child as before. For example in our ‘Duck’ case above, this would be an array of [“A > B”, “C”], - two strings, one for each way of navigating down the category tree.
Would this bring about problems, because in one scenario I am using category C and the other scenario I am not? Is this in line with the intention of what Piwik is trying to track?
You are free to track whichever way you want. You can also set multiple categories in an array as explained in the documentation. Each category will be credited with the transaction, so if you set multiple categories the “total revenue” of all categories will be greater than the actual revenue.
EDIT: just realised the below was me thinking about tracking an order, not a cart update as in my previous post. Just what I had on my mind atm, but the issues are related.
I understand that I’m free to track any yes, I was trying to work out which was best so that the resulting calculations are meaningful.
For example, many categories go something like (categories and sub-categories);
A > B > C
It is very common (as this is the way most ecommerce carts work) to put a product which is in category C, also in category A and B so they show up when in A or B. Thus, from the point of view of the databases the product is in A, B and C (even if this process is transparent to the user).
If I simply set the Piwik ‘category’ to the categories that the product is “in”, the category conversion rate would be meaningless - categories higher in the tree would have artificially i-n-f-l-a-t-e-d (PS why is this word banned for posts!?) conversion rates (and could even exceed 100% theoretically).
In addition, the % doesnt mean what you might expect it to mean. A 5% category conversion rate should mean that 5% of the people who viewed that category bought a product from that category. In this example it would mean something different and arbitrary.
My current plan is to pull category info from the ‘custom_var_v5’ fields from the ‘piwiktest_log_link_visit_action’ table for this user from the past 30 minutes say (this field is the category recorded when an ecommerce category view was recorded) - then for each purchased SKU which I am doing an ‘addEcommerceItem’ call, I take the category field used when viewing this product. If the same purchased product has been viewed via multiple routes then I’ll need to decide which to use (or use both). Not sure which yet, I’ll have to give more thought to this part!
Do you get what I mean or was that gibberish?! Any thoughts?
No one?? I really want to get this right to make sure the category conversion rate is actually useful! I’m sure others must have come across this when doing e-commerce implementations. Let me know what you did…