VisualAppeal / Matomo-PHP-API

PHP wrapper for the Matomo API.
MIT License
95 stars 33 forks source link

API on Dimension Week/Month/Year don't work on CustomVariables.getCustomVariablesValuesFromNameId #16

Closed approached closed 9 years ago

approached commented 9 years ago

Hi@all,

i tried to use Dimension Week/Month/Year on CustomVariables.getCustomVariablesValuesFromNameId but it still don't works. I have every time response with empty arrays.

Request URL: http://exmaple.com/index.php?module=API&method=CustomVariables.getCustomVariablesValuesFromNameId&token_auth=MYTOKEN&idSite=1&period=year&format=json&language=de&idSubtable=2&segment=customVariablePageValue1%3D%3D7&date=2014-02-22,2015-02-22

Only dimension day work it.

approached commented 9 years ago

Refference: https://github.com/piwik/piwik/issues/7272

thelfensdrfer commented 9 years ago

When you make this call on the offical demo, the response is empty too, so this is no issue with this library. See: http://demo.piwik.org/index.php?module=API&method=CustomVariables.getCustomVariablesValuesFromNameId&idSite=7&period=year&format=json&language=de&idSubtable=2&segment=customVariablePageValue1%3D%3D7&date=2014-02-22,2015-02-22

approached commented 9 years ago

You make it very easy. I hope with this example you feel the spirit.

Example with DAY: http://demo.piwik.org/index.php?module=API&method=CustomVariables.getCustomVariablesValuesFromNameId&idSite=7&period=day&format=json&language=de&idSubtable=2&date=2014-04-22,2015-06-01

Example with YEAR: http://demo.piwik.org/index.php?module=API&method=CustomVariables.getCustomVariablesValuesFromNameId&idSite=7&period=year&format=json&language=de&idSubtable=2&date=2014-04-22,2015-06-01

thelfensdrfer commented 9 years ago

This is a strange behavior, but since this is the response from the api, the library can't fix it?

approached commented 9 years ago

Yes it can. Look here https://github.com/piwik/piwik/issues/7272

thelfensdrfer commented 9 years ago

As far as I understand the comment from mattab, you have to call getCustomVariables before getCustomVariablesValuesFromNameId.

So extract the idSubtable value from this response: http://demo.piwik.org/index.php?module=API&method=CustomVariables.getCustomVariables&idSite=7&period=year&format=json&language=de&idSubtable=2&date=2014-04-22,2015-06-01

In this example idSubtable for Forum status is 13947. With this idSubtable you get a response for the year range: http://demo.piwik.org/index.php?module=API&method=CustomVariables.getCustomVariablesValuesFromNameId&idSite=7&period=year&format=json&language=de&idSubtable=13947&date=2014-04-22,2015-06-01