It seems that custom variables tracking is not working properly.
The variables are not stored in the databases.
Also with Tracker debug enabled we can see the following error on a tracking request with custom variables
WARNING CustomVariables[2020-10-19 11:52:37 UTC] [e201d] /var/www/matomo/core/Tracker/Request.php(635): Warning - count(): Parameter must be an array or an object that implements Countable - Matomo 3.14.1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) [internal function]: Piwik\ErrorHandler::errorHandler(),<a href='/1'>#1</a>/core/Tracker/Request.php(635),<a href='/2'>#2</a>/core/Tracker/Action.php(191),<a href='/3'>#3</a>/plugins/CustomVariables/Tracker/CustomVariablesRequestProcessor.php(76),<a href='/4'>#4</a>/core/Tracker/Visit.php(174),<a href='/5'>#5</a>/core/Tracker.php(155),<a href='/6'>#6</a>/core/Tracker/Handler.php(57),<a href='/7'>#7</a>/core/Tracker.php(135),<a href='/8'>#8</a>/core/Tracker.php(112),<a href='/9'>#9</a>/piwik.php(76)
The affected code seems to be
/core/Tracker/Request.php(635) if ($id < 1 || $id > $maxCustomVars || count($keyValue) != 2
URL decoded url part for tracking request
And I think I have found a clue.
By looking at the url we can see that the cvar url parameter when url decoded is
and this leads to error in tracking
Now if we change by removing the quotes and make the lvalue of the hash a list (instead of a string), like this
And url encode and hit, no error is logged and data starts to appear in the database
custom_var_k5: PAGEVAR custom_var_v5: http://test.com/test.html
Thanks for this @basos9 . Do you know in what browser this happens and whether that site maybe overwrites
It happens on major browsers (Chrome, Firefox).
It seems to be related with something in the web page (maybe some JS library), since I was able to successfully track variables by creating a simple html web page with only the tracking code. We are investigating the issue.
Thanks for investigating. Be great to let us know what you find out.
For this webpage we tracked to the inclusion of prototype.js library which was included in our web application.
The affected file has a header
The problem is fixed when we removed this library.
More specifically this library modified (monkey patches) Builtin in Objects like String and Array, defining among others a
Another example using the Chrome's browser console on our site
"test".toJSON() ""test"" JSON.stringify(["king","kong"]); ""[\"king\", \"kong\"]""
and on youtube
"test".toJSON() VM529:1 Uncaught TypeError: "test".toJSON is not a function at <anonymous>:1:8 JSON.stringify(["king","kong"]); "["king","kong"]"
That version was released in 2008 meaning it is older than the first release of Internet Explorer 8.
So I guess there is not really much to do as one would need to specifically check for this case which would be weird considering we just dropped support for IE<8.
See eg https://github.com/matomo-org/matomo/issues/2165 prototype is kind of known actually to have caused issues with JSON and there isn't anything we can do unfortunately. Ideally the project would look at removing this dependency but I understand this is a big ask and not easily done. AFAIK the only other way would be that you overwrite again some of these changes that prototype does. Not sure if we can maybe close this issue but document somewhere this incompatibility or so?
It seems that this is a library incompatibility issue and the best would be the things mentioned
Thank you for helping sort this out.
Noticed we haven't actually documented the requirements / supported browsers anywhere for the JS tracker (at least I couldn't find it) so created https://github.com/matomo-org/developer-documentation/pull/392