【发布时间】:2016-09-07 01:41:05
【问题描述】:
我正在使用 Google API V4 https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-php
我遇到了 setAlias 函数的问题。 When there are multiple metrics selected, all the returned headers are same.
代码:
<?php
$metrices = {FORM ARRY WITH MULTIPLE METRICES}
$nmetrices = array();
if(is_array($metrices) && count($metrices) > 0){
$i=0;
foreach($metrices as $metric){
$nmetrices[$i] = new Google_Service_AnalyticsReporting_Metric();
$nmetrices[$i]->setExpression($metric);
$nmetrices[$i]->setAlias($metric);
$i+=1;
}
}?>
例子:
我选择了“ga:users”和“ga:percentNewSessions”,但返回的结果的标题为:“ga:users”这两个指标。
ga:medium: (none)
ga:date: 20150810
Metric type: INTEGER
**ga:users: 764
ga:users: 97.38219895287958**
ga:medium: (none)
ga:date: 20150811
Metric type: INTEGER
**ga:users: 2495
ga:users: 85.50284629981024**
【问题讨论】:
标签: php google-analytics-api google-analytics-firebase