Query to visits

Hello guys, I’m looking for the method that return the value of ‘Custom Variable value’ (If you have a custom variable like ‘User’ the value of that should be the user name, I need that value), someone known where is it, I can’t find it.

I’ll apreciate your answer.

you can use CustomVariables.getCustomVariables with parameter &expanded=1

or you can call CustomVariables.getCustomVariablesValuesFromNameId with parameter &idSubtable=X where X is the value of idsubtable in the API response from the first call CustomVariables.getCustomVariables

Before at all, Thank you for your answer.

Now mmm I don’t know if I’m doing it by the correct way, but doesn’t work for me, I want to get this value on a variable

i don’t know if it’s returned as an array or a object, can you helpme?

Thanks again for the first reply.

I meant something like this $newRowToAdd[“custom_var_v1”] on core/ArchiveProcessing/Day.php but still doesn’t work (This give me an error), that Array ($newRowToAdd) is generated in this method public function getArrayInterestForLabel($label), in each loop is taking new values and calling updateInterestStats giving her new values in order to show it, but, how can take only the custom var key and value values?

So much thanks again matt.

Hello again, if I make something like this
print_r($newRowToAdd);
I get an output like this:


Array ( [referer_type] => 1 [referer_name] => [referer_keyword] => [referer_url] => [1] => 1 [2] => 1 [3] => 5 [4] => 5 [5] => 116 [6] => 0 [7] => 0 )
Array ( [referer_type] => 1 [referer_name] => [referer_keyword] => [referer_url] => http://mysite.com/test1.php [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 0 [6] => 1 [7] => 0 )
Array ( [label] => WI7;FF;1366x768 [1] => 2 [2] => 2 [3] => 6 [4] => 5 [5] => 116 [6] => 1 [7] => 0 )
Array ( [label] => WI7 [1] => 2 [2] => 2 [3] => 6 [4] => 5 [5] => 116 [6] => 1 [7] => 0 )
Array ( [label] => FF;15.0 [1] => 2 [2] => 2 [3] => 6 [4] => 5 [5] => 116 [6] => 1 [7] => 0 )
Array ( [label] => 1366x768 [1] => 2 [2] => 2 [3] => 6 [4] => 5 [5] => 116 [6] => 1 [7] => 0 )
Array ( [label] => en [1] => 2 [2] => 2 [3] => 6 [4] => 5 [5] => 116 [6] => 1 [7] => 0 )
Array ( [label] => eur [1] => 2 [2] => 2 [3] => 6 [4] => 5 [5] => 116 [6] => 1 [7] => 0 )
Array ( [label] => 10 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 0 [6] => 1 [7] => 0 )
Array ( [label] => 15 [1] => 1 [2] => 1 [3] => 5 [4] => 5 [5] => 116 [6] => 0 [7] => 0 )
Array ( [label] => 13 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 0 [6] => 1 [7] => 0 )
Array ( [label] => 18 [1] => 1 [2] => 1 [3] => 5 [4] => 5 [5] => 116 [6] => 0 [7] => 0 )
Array ( [label] => Ip [1] => 2 [2] => 2 [3] => 6 [4] => 5 [5] => 116 [6] => 1 [7] => 0 )
[b]Array ( [custom_var_k1] => User [custom_var_v1] => Jhon Doe[1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 0 [6] => 1 [7] => 0 )[/b]

But I don’t know how can I get “Jhon Doe” in a variable, can someone give me some advice?

Hello again matt,

I’m still having this problem, I tried to use

$myLabels = new Piwik_CustomVariables_API();
$myLabels → getCustomVariables(“1”,“Day”,“yesterday”, false, 1);
var_dump($myLabels);

not work, so, I used

$myLabels = Piwik_CustomVariables_API::getInstance()->getCustomVariables(“1”, “Day”, “yesterday”, false, 1, true);
var_dump($myLabels);

neither, how can use it?

I’ve seen this in the API reference page, but I cant get it:

can you give me some example of how to use is? or someone? please.

Thanks matt

nobody know how is it?

I’m still trying but something is wrong, I don’t know if is my code or I’m using the wrong function.

Thanks.

Hello again,

this is a little bit frustrating, I can’t do what I want to, but, I think I’m going in the correct way,

I’m doing

$output = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId(1, “day”, “yesterday”, 38, false, false);

and the output is giving me something like this:

object(Piwik_DataTable)#105 (14) { [“rows”:protected]=> array(0) { } [“parents”:protected]=> NULL [“currentId”:protected]=> int(1) [“depthLevel”:protected]=> int(0) [“indexNotUpToDate”:protected]=> bool(true) [“rebuildIndexContinuously”:protected]=> bool(false) [“tableSortedBy”:protected]=> bool(false) [“queuedFilters”:protected]=> array(3) { [0]=> array(2) { [“className”]=> string(22) “ReplaceSummaryRowLabel” [“parameters”]=> array(0) { } } [1]=> array(2) { [“className”]=> string(18) “ReplaceColumnNames” [“parameters”]=> array(0) { } } [2]=> array(2) { [“className”]=> string(21) “ColumnCallbackReplace” [“parameters”]=> array(2) { [0]=> string(5) “label” [1]=> string(10) “lambda_41” } } } [“rowsCountBeforeLimitFilter”:protected]=> int(0) [“enableRecursiveSort”:protected]=> bool(false) [“enableRecursiveFilters”:protected]=> bool(false) [“rowsIndexByLabel”:protected]=> array(0) { } [“summaryRow”:protected]=> NULL [“metadata”:protected]=> array(0) { } }
The object is created, but I don’t know how can get the custom variables now, I need to take the name from the user recorded on the db, I follow the code but it’s in another level, superior to mine, and I tried to modify it but I can’t take the user name from the table, I need some help with this,

can someone give a rope? please. Thanks

I recommend you use the API like on: http://piwik.org/docs/analytics-api/calling-techniques/#toc-call-the-piwik-api-in-php

this way you get Array back which is simpler to handle in PHP.

You can then get the idsubtable for the custom variable value.

  1. call getCustomVariables
  2. look the idsubtable for the custom var you wish to load
  3. call getCustomVariablesValuesFromNameId passing this parameter idSubtable