Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#2897 closed Bug (fixed)

Ecommerce: Tracking multiple Product categories on an ecommerce page view does not work

Reported by: jeremy Owned by:
Priority: normal Milestone: 1.7 Piwik 1.7
Component: Core Keywords:
Cc: Sensitive: no


Piwik Version : 1.6

I've tried to use the e-commerce tracking as described in the documentation (

The documentation and that ticket ( tell us that we can assign multiple categories to products, but it seems that it actually doesn't work via the piwikTracker.setEcommerceView function (JS tracker).
For example :


It results in an empty Product Category "Custom Variable value not defined".

I've activated the debug mode and i've found a first error :

Warning: substr() expects parameter 1 to be string, array given in /www/piwik/core/Tracker/Visit.php on line 1082

The error appears in the getCustomVariables and truncateCustomVariable functions.

It seems that the code is not handling arrays and assume that all custom variables are only strings.

Change History (7)

comment:1 Changed 2 years ago by matt (mattab)

  • Milestone set to 1.7 Piwik 1.7

comment:2 Changed 2 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

(In [5777]) Fixes #2897

  • Forgot to stringify the array of categories. This wasn't covered in the tests since they use the php tracking api client.
  • Added JS tests

jeremy, it is very appreciated if you can test the new piwik.js and report if it's working for you too! thanks

comment:3 Changed 2 years ago by matt (mattab)

  • Priority changed from major to normal
  • Summary changed from E-commerce and multi-categories to Ecommerce: Tracking multiple Product categories on an ecommerce page view does not work

comment:4 Changed 2 years ago by jeremy

I've tried the lastest version (1.7), but now the Ecommerce tracker seems not to work at all:

  • I can see the ecommerce custom variables values in the visitor log (in the bubble when we put the mouse on the url) : _pkp, _pks, _pkn, _pkc
  • I can also see them in the piwik_log_link_visit_action table, which means that they are saved
  • BUT NOW the "custom variables" page or even the "ecommerce and goals" page are empty

comment:5 Changed 2 years ago by matt (mattab)

It's expected that they don't appear in the "Custom Variable" see #2755

However it's not expected that nothing works. On the demo we track ecommece and it is working (product name is tracked). What exactly is not working for you? can you put a screenshot? thx

comment:6 Changed 2 years ago by jeremy

OK I didn't see the #2755 ticket and so i thought that they will appear in the "custom variables" widget again.
Now I can see them in the ecommerce widgets so all is good!
I'm sorry for the unuseful last comment and for the waste of time ;)
However I can now confirm that tracking multiple categories is working like a charm.

comment:7 Changed 2 years ago by matt (mattab)

So the conclusion is that "All" is working fine? :) that's good!!

Note: See TracTickets for help on using tickets.