【发布时间】:2015-11-09 14:08:22
【问题描述】:
我想获取活跃用户的谷歌分析实时数据。我使用了来自的 google api client php https://code.google.com/p/google-api-php-client/source/browse/trunk/src/?r=474#
For screenviews after setting metrics and dimensions
$metrics = 'ga:screenviews';
$optParams = array('dimensions' => 'ga:screenName');
$service = new Google_AnalyticsService($client);
try {
$result = $service->data_ga->get(
$GA_VIEW_ID,
$start_date,
$end_date,
$metrics,
$optParams
);
} catch(Exception $e) {
var_dump($e);
}
我得到了正确的结果。 我想获取实时数据,但无法获取。我已经尝试如下。
$metrics = 'rt:medium'; $optParams = array('dimensions' => 'rt:activeUsers');
try {
$results = $service->data_realtime->get(
$GA_VIEW_ID,
'rt:activeUsers',
$optParams);
} catch (apiServiceException $e) {
// Handle API service exceptions.
$error = $e->getMessage();
}
// Error : Undefined property: Google_AnalyticsService::$data_realtime
请给我解决方案以获取实时数据。
【问题讨论】:
-
你有实时 API 的测试访问权限吗?
标签: php google-api google-analytics-api google-api-php-client