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

bulk tracking requests with custom variables need to be double encoded #4848

Closed
anonymous-matomo-user opened this issue Mar 12, 2014 · 2 comments
Labels
answered For when a question was asked and we referred to forum or answered it. Bug For errors / faults / flaws / inconsistencies etc.

Comments

@anonymous-matomo-user
Copy link

in order to push bulk tracking requests, you have to use json, i shouldn't have to escape the cvar json in order to put it in a json object.

this is how i currently have to submit a request:

{"requests": ["{"1": "name", "value"}", "res": "1366x768", "url": "http://www.blah.com/blah/", "search_count": "54", "search": "termhere", "cdt": "2014-03-11 00:00:00", "cip": "111.222.111.222", "urlref": "http://www.ref.com/refstuff/", "idsite": "1", "rec": "1", "_id": "aaaaa563aaaaa51a", "ua": "mozilla/5.0 (compatible; msie 9.0; windows nt 6.1; trident/5.0)"}], "token_auth": "tokenhere"}

this
{"cvar": "{"1": "value"}",

should be able to be submitted as this
{"cvar": "{"1": "value"}",

none of this is mentioned in the documentation, and the documentation incorrectly states that i should be using an json array of urls with url encoded parameters, when i really have to use json throughout

http://developer.piwik.org/api-reference/tracking-api

here is the backtrace when trying to submit an un escaped request

Warning: json_decode() expects parameter 1 to be string, array given in /export/home/web/public/htdocs/projects/applog/piwik/core/Common.php on line 600

Backtrace -->
#0 Piwik\Error::errorHandler(...) called at [:]
#1 json_decode(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Common.php:600]
#2 Piwik\Common::json_decode(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Common.php:419]
#3 Piwik\Common::getRequestVar(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Tracker/Request.php:350]
#4 Piwik\Tracker\Request->getCustomVariables(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Tracker/Action.php:111]
#5 Piwik\Tracker\Action->getCustomVariables(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Tracker/ActionSiteSearch.php:84]
#6 Piwik\Tracker\ActionSiteSearch->getCustomVariables(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Tracker/Action.php:284]
#7 Piwik\Tracker\Action->record(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Tracker/Visit.php:167]
#8 Piwik\Tracker\Visit->handle(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Tracker.php:836]
#9 Piwik\Tracker->trackRequest(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/core/Tracker.php:245]
#10 Piwik\Tracker->main(...) called at [/export/home/web/public/htdocs/projects/applog/piwik/piwik.php:106]

@anonymous-matomo-user
Copy link
Author

it seems like bulk tracking still has some edge cases in it, but i would like to let you know i appreciate all your hard work, and really enjoy the product

@mattab
Copy link
Member

mattab commented Dec 1, 2014

this should work now, please open new issue in case you experience this

@mattab mattab closed this as completed Dec 1, 2014
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Dec 1, 2014
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. Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants