I want to track products and categories in ecommerce tracking with double quotes in their names. I have Piwik 2.3.0.
Let’s say article is called ‘Käse’ and the category is called ‘old “Käse”’. The problem is that no ecommerce items are tracked when a double quote is in the product name or product category.
It is not tracked in Piwik as an ecommerce item. If I remove the double quote from the category name it tracks it as an ecommerce item.
I also tried to use single quotes around the values, but the same result.
If I urlencode() Product name and Product category it gets tracked with this code:
Abandoned Cart
Revenue left in cart: 15.95 € , Quantity: 1
1111test: K%C3%A4se (old+%26quot%3BK%C3%A4se%26quot%3B) , Quantity: 1, Price: 10 €
rawurlencode() the same.
There is a HTTP GET request with the ec_items value "GET /piwik/piwik.php?idgoal=0&revenue=15.95&ec_items=%5B%5B%221111test%22%2C%22K%25C3%25A4se%22%2C%22old%2520%2526quot%253BK%25C3%25A4se%2526quot%253B%22%2C10%2C1%5D%5D&idsite=1
this ec_items is completely missing when I don’t rawurlencode() product name and product category that contain double quotes.
Can you point me to the tests where I can add such a case to verify it? I am a bit lost with the tests right now where to add it. Or can someone else confirm this problem?
The Integration tests seem to be fine with double quotes in product name or category name as far as I can see. The problem seems to be on the client side JavaScript that genereates the JSON encoded array for ec_items.
No proxy scripts and using default asynchronous JavaScript tracking.
The problem why no ecommerce items got tracked if one item had double-quotes in product name or product category was a
Error while json_decode the Ecommerce items = NULL
on the server side.
ec_items had an invalid JSON format because of the " which was needed to insert it into the double-quoted addEcommerceItem values.
I got it working now by changing my tracking scripts:
I am not sure if there is a way how this could be improved in Piwik, but it will work as it is now when I leave double-quotes alone and convert single-quotes to ’ in product names and category names.
Oh! That’s definitely a bug, that should be fixed Thanks for the report. Please create a ticket on issue tracker, with code to reproduce, and we will tackle it at some point, cheers!
I think I did not open an issue because it was somehow in the transition of the isse tracker and then forgot it.
I solved it in my implementation with adding htmlspecialchars_decode() in the tracking-code.