Ecommerce tracking problems with double quotes in product name or category name

(Klaus) #1


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.

The ecommerce tracking script looks like this:

_paq.push(['addEcommerceItem',"1111test","Käse","old "Käse"",10,1]);

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:


But the result in Piwik looks terrible:

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?

(Matthieu Aubry) #2

Klaus, this sounds like a bug in Piwik. Could you please create ticket in the issue tracker, with code to reproduce?

There is one ecommerce test here: matomo/TwoSitesEcommerceOrderWithItems.php at master · matomo-org/matomo · GitHub

Btw are you using default piwik.php or the proxy script?

(Klaus) #3

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.

(Klaus) #4

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:

old: _paq.push(['addEcommerceItem',"1111test","Käse","old "Käse"",10,1]);
new: _paq.push(['addEcommerceItem','1111test','Käse','old "Käse"',10,1]);

Single-quotes I need to convert, but that causes no problems:

_paq.push(['addEcommerceItem','1111test','Käse 'Oh','old "Käse"',10,1]);

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.

Should I still open a ticket? Maybe someone can confirm my observations and we just need to change the documentation at Ecommerce Analytics - Analytics Platform - Matomo

(Matthieu Aubry) #5

Oh! That’s definitely a bug, that should be fixed :slight_smile: Thanks for the report. Please create a ticket on issue tracker, with code to reproduce, and we will tackle it at some point, cheers!


Hi, I am having problems with this issue as well. Has a ticket been created for this issue?

(Matthieu Aubry) #7

@erodrig, I’m not sure yet maybe @Klaus will help

Otherwise you can search for issues in Issues · matomo-org/piwik · GitHub and see if it’s already created


I did not find anything in the issue tracking system. Should I submit a new issue?

(Klaus) #9


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.

(Matthieu Aubry) #10

@erodrig9 please create new issue with steps to reproduce and expected VS what you got. Thanks!


Opened a new issue ecommerce orders with double quotes in product name or category name are not tracked · Issue #6068 · matomo-org/matomo · GitHub