Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segment datas are wrong/inexistant because json decoding is missing #9027

Closed
ArnY opened this issue Oct 16, 2015 · 9 comments
Closed

segment datas are wrong/inexistant because json decoding is missing #9027

ArnY opened this issue Oct 16, 2015 · 9 comments
Assignees
Labels
answered For when a question was asked and we referred to forum or answered it.
Milestone

Comments

@ArnY
Copy link
Contributor

ArnY commented Oct 16, 2015

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...

@tsteur
Copy link
Member

tsteur commented Oct 17, 2015

Hi @ArnY thanks for investigating so much already and looking so deep into it.

In general I can say that custom variables work quite well here. So it might be related to a specific browser or server.

Which browser are you using? Do you have some details about the server? On which OS is it running and what's the Piwik version?

There's a JSON decode which should convert that string that you mentioned in the forum to an array.

Can you maybe try if it still occurs if you track only one custom var? eg _paq.push(['setCustomVariable', 1,"Site","SET",'page'])

@ArnY
Copy link
Contributor Author

ArnY commented Oct 17, 2015

Since I noticed the bug on our production server on a segment which
averaged around ~30,000 monthly before the bug and ~230 after (but all
segments are impacted), if this was a browser related bug, that would
mean that 99.993% of the browsers suddendly handled the javascript wrong.

I removed my fix ($keyValue=json_decode($keyValue)) and only left one
custom variable. The problem still occurs:

DEBUG Actions[2015-10-17 09:55:04] [979f0] Invalid custom variables
detected (id=1)

I agree there's something strange with the fact that a very small
percentage of the visits are still being accounted...

On 10/17/2015 08:50 AM, Thomas Steur wrote:

Hi @ArnY https://github.com/ArnY thanks for investigating so much
already and looking so deep into it.

In general I can say that custom variables work quite well here. So it
might be related to a specific browser or server.

Which browser are you using? Do you have some details about the server?
On which OS is it running and what's the Piwik version?

There's a |JSON decode| which should convert that string that you
mentioned in the forum to an array.

Can you maybe try if it still occurs if you track only one custom var?
eg |_paq.push(['setCustomVariable', 1,"Site","SET",'page'])|


Reply to this email directly or view it on GitHub
#9027 (comment).

Arnaud Abélard
jabber: arnaud.abelard@univ-nantes.fr / twitter: ArnY
Administrateur Système

DSI Université de Nantes

@cbleek
Copy link

cbleek commented Oct 18, 2015

I can confirm the problem on ubuntu 14.4, php-5.5.9.
I can reproduce it with piwik 2.13.0 and 2.15.0rc3

@cbleek
Copy link

cbleek commented Oct 18, 2015

One more intresting thing.

If I set the value of my custom variable to "m.jobsintown.de", the value is tracked. Means, the type of $keyValue in https://github.com/piwik/piwik/blob/master/core/Tracker/Request.php#L553 is an array.

_paq.push(['setCustomVariable', 1,"Domain","m.jobsintown.de",'visit']);

if I set the value to "www.jobsintown.de" $keyValues is a json encoded string.

_paq.push(['setCustomVariable', 1,"Domain","www.jobsintown.de",'visit']);

@tsteur
Copy link
Member

tsteur commented Oct 27, 2015

That's very weird. I tried to reproduce but couldn't.

I just had a look at the website and it is actually sent differently to Piwik:

_cvar:{"1":"[\"Domain\", \"www.jobsintown.de\"]"}

vs

{"1":["Domain","m.jobsintown.de"]}

After debugging further I noticed that you are using Prototype 1.6.0.3 which is known to be buggy re JSON. Please update Prototype to a more recent version.

See eg #2165 or #7945 (comment)

@tsteur tsteur closed this as completed Oct 27, 2015
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Oct 27, 2015
@tsteur tsteur added this to the 2.15.1 milestone Oct 27, 2015
@tsteur tsteur self-assigned this Oct 27, 2015
@cbleek
Copy link

cbleek commented Oct 27, 2015

After upgrading prototype, the problem was fixed.

Thank you very much!

@ArnY
Copy link
Contributor Author

ArnY commented Oct 27, 2015

Spot on! We used prototype.js 1.6.0.3 too but I actually upgraded it a few days ago for a completely unrelated reason! I had slightly modified Request.php to send to syslog user-agents of browsers encountering the problem and upgrading prototype.js did fix most of the problem, but even after the upgrade I'm still getting non decoded json arrays for each custom variables (about 1% of the visits). Most of them are using webkit browsers: Chrome and Safari. Might not be important, I just wanted to mention those, just in case.

Thanks anyway!

@tsteur
Copy link
Member

tsteur commented Oct 27, 2015

Those browsers probably still use the cached prototype.js

@ArnY
Copy link
Contributor Author

ArnY commented Oct 27, 2015

On 10/27/2015 07:27 PM, Thomas Steur wrote:

Those browsers probably still use the cached prototype.js


Reply to this email directly or view it on GitHub
#9027 (comment).

My thought too, i'll keep an eye on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

3 participants