I am trying to use this api CustomVariables.getCustomVariablesValuesFromNameId (idSite, period, date, idSubtable, segment = '') from piwik to fetch CustomVariable values. But there is no example for it and also how to get idsubtable value ?
Is there any way to fetch custom variable values from piwik using api ?
Any help or example would be appreciated.
Granted - this is not easy on first sight. So here's how it works:
You can find an example for
CustomVariables.getCustomVariables
at http://demo.piwik.org/index.php?module=API&action=listAllAPI&idSite=7&period=day&date=yesterday#CustomVariables. The resulting XML contains all existing Custom Variables.Lets take the following as an example:
The
<label>
in this case stands for the key of the custom variable. The included metrics such asnb_visits
,nb_actions
, etc. are summed values for that specific custom variable. In order to get the values of theForum status
custom variable you need to use the value ofidsubdatatable
as theidSubtable
parameter.This results in the following URL: http://demo.piwik.org/index.php?module=API&method=CustomVariables.getCustomVariablesValuesFromNameId&idSite=7&period=day&date=yesterday&format=xml&idSubtable=110&token_auth=anonymous
Calling this URL will yield something like the following result:
Each row's
<label>
contains a value for theForum status
custom variable and the metrics for that value.