【发布时间】:2016-06-16 08:25:38
【问题描述】:
getResults函数中如何使用参数?我需要获取有关我的网站用户正在观看哪些网址的信息。如果我使用ga:sessions,我会看到那里有多少用户。如果我将其更改为ga:pageviews,则数字(在结果数组中)会发生变化。所以这意味着API是“活的”。
如何获取人们开始观看我网站的 URL“进入点”。以及如何在'ga:sessions');这个地方发送参数?
我正在阅读的 API 说明是 here。
function getResults(&$analytics, $profileId) {
// Calls the Core Reporting API and queries for the number of sessions
// for the last seven days.
return $analytics->data_ga->get(
'ga:' . $profileId,
'7daysAgo',
'today',
'ga:sessions');
}
function printResults(&$results) {
// Parses the response from the Core Reporting API and prints
// the profile name and total sessions.
if (count($results->getRows()) > 0) {
// Get the profile name.
$profileName = $results->getProfileInfo()->getProfileName();
// Get the entry for the first entry in the first row.
$rows = $results->getRows();
// $sessions = $rows[0][0];
// Print the results.
echo '<pre>';
print_r($rows);
} else {
print "No results found.\n";
}
}
目前的结果是:
Array
(
[0] => Array
(
[0] => 3585
)
)
【问题讨论】:
标签: php google-api google-analytics-api google-api-php-client