Reputation: 93
I have an issue with Multi-Channel Funnels requests.
The JSON response is not the same that with classic request with ga: dimensions and metrics. It returns primitive values in rows and I can't get them.
Exemple : Here is a classic request with metric ga:transactionRevenue, and dimension ga:transactionId. I get this in rows :
"rows": [
[
"10292",
"-231.5"
],
[
"11330",
"0.0"
],
[
"12180",
"37.5"
],
(...)
Easy to retrieve.
Now with metric mcf:firstInteractionValue and dimension mcf:sourceMedium.
"rows": [
[
{
"primitiveValue": "(direct) / (none)"
},
{
"primitiveValue": "2066.2514"
}
],
[
{
"primitiveValue": "YH-TW / cpc"
},
{
"primitiveValue": "0.0"
}
],
[
{
"primitiveValue": "ameblo.jp / referral"
},
{
"primitiveValue": "0.0"
}
],
(...)
I tried the getRows() method, but it returns me a weird array. I also tried getPrimitiveValue() on MCFDataRows, but it return a null value.
$dataRows = $dataMCF->getRows();
for($i=0; $i<sizeof($dataRows); $i++){
echo $dataRows[$i]->getPrimitiveValue();
}
result: nothing
Can you please help me to get those values ? :3
Edit :
The object $dataRows[0]
Google_Service_Analytics_McfDataRows Object
(
[conversionPathValueType:protected] => Google_Service_Analytics_McfDataRowsConversionPathValue
[conversionPathValueDataType:protected] => array
[primitiveValue] =>
[collection_key:protected] => items
[modelData:protected] => Array
(
[0] => Array
(
[primitiveValue] => (direct) / (none)
)
[1] => Array
(
[primitiveValue] => 2066.2514
)
)
[processed:protected] => Array
(
)
)
I have the impression it is really simple, but i have been unable to get those values since this morning. I don't see how to get the modelData:protected array. I read the entire MCF classes of the API 3 times, without finding the right function.
Upvotes: 2
Views: 829
Reputation: 11
I personally modified Analytics.php since google is not able to provide data properly.
I added this in class Google_Service_Analytics_McfDataRows:
public function getData(){
return $this->modelData;
}
Upvotes: 1
Reputation: 68
Try to use this:
$dataRows = $dataMCF->getRows();
foreach($dataRows AS $row){
$temp_row = array( );
foreach ((array)$row->toSimpleObject() as $key => $value) {
$temp_row[ $key ] = $value['primitiveValue'];
}
}
Upvotes: 2