Hello,
I’m tracking custom variables with Piwik but in the generated request to Piwik server, here what I get :
/piwik.php?action_name=my_action&idsite=2&rec=1&r=632817&h=18&m=26&s=12&url=http://www.xxxx.com/?cid=XXX&urlref=http:xxx.html&_id=565da35e40f66022&_idts=1446568377&_idvc=2&_idn=0&_refts=0&_viewts=1446571155&send_image=0&pdf=1&qt=0&realp=0&wma=0&dir=0&fla=1&java=1&gears=0&ag=0&cookie=1&res=1920x1080&cvar={“1”:"[“Var1”, “VAR0003719412”]",“2”:"[“Var2”, “0”]"} >_ms=277
The parameter which is matching to the custom variable is very weird because it has misplaced quotation mark : {“1”:"[“Var1”, “VAR0003719412”]",“2”:"[“Var2”, “0”]"} and antislashes coming from nowhere.
Result : these custom variables are not saved by Piwik.
When I try to send a request manually with this value : cvar={“1”: [“Var1”,“VAR0003719412”] ,“2”:[“Var2”,“0”]}, it works well.
I track my custom variables in a standard way :
_paq.push([‘setCustomVariable’, 1, ‘Var1’, ‘N°Identifiant’, ‘page’]);
_paq.push([‘setCustomVariable’, 2, ‘Var2’, ‘Montant’, ‘page’]);
Any clue of where did come from these quotations marks and antislashes ?
Thanks for any help,
Tia
matthieu
(Matthieu Aubry)
November 3, 2015, 10:21pm
2
you are likely using Prototype 1.6.0.3 which is known to be buggy re JSON. Please update Prototype to a more recent version.
opened 08:41AM - 16 Oct 15 UTC
closed 01:49AM - 27 Oct 15 UTC
answered
I explained my problem on the forum: http://forum.piwik.org/read.php?2,129751
in… short:
Segment datas are wrong or empty.
Custom variables are declared to the tracker like this:
```
_paq.push(['setCustomVariable', 1,"Site","SET",'page']);
_paq.push(['setCustomVariable', 2,"Redacteur","xxxxx",'page']);
_paq.push(['setCustomVariable', 3,"RubriqueNiveau1","SET_FR1",'page']);
_paq.push(['setCustomVariable', 4,"RubriqueCourante","SET_FR1",'page']);
```
in core/Tracker/Request.php the customVariable values are read out of Common::getRequestVar, but for some reason those are still json encoded instead of being an array as expected:
```
["Site", "SET"]
["Redacteur","xxxxx"]
["RubriqueNiveau1","SET_FR1"]
[""RubriqueCourante","SET_FR1"]
```
looks like there's a missing json_decode() in the foreach ($customVar as $id => $keyValue) loop.
I could commit a patch but I'm not sure of the implications since I haven't found any other bug reports on the subjet it must still be working for some people...
I updated it and it works well
thank you !