I'm trying to work out how to get the top 5 pages from my Google Analytics Project API in PHP. So far I've made the following code, but it doesn't appear to work - any ideas?
我正在尝试研究如何从PHP中获取Google Analytics Project API的前5页。到目前为止,我已经制作了以下代码,但它似乎没有用 - 任何想法?
private function getTopPages($profileId) {
$optParams = array(
'sort' => 'ga:pageviews',
'max-results' => '5');
return $this->analytics->data_ga->get(
'ga:' . $profileId,
'2012-09-01',
'2012-09-30',
'ga:pagePath',
$optParams);
}
2 个解决方案
#1
0
private function getTopPages($profileId) {
$optParams = array(
'max-results' => 5,
'dimensions' => 'ga:pageTitle,ga:pagePath',
'sort' => '-ga:pageviews',
);
return $this->analytics->data_ga->get(
'ga:' . $profileId,
'2012-09-01',
'2012-09-30',
'ga:pageviews',
$optParams);
}
inspired by: http://axiacore.com/blog/how-get-list-most-popular-pages-google-analytics-python/
灵感来自:http://axiacore.com/blog/how-get-list-most-popular-pages-google-analytics-python/
#2
0
I don't know the specifics of the php calls, but I see the following potential problems with your call:
我不知道php调用的具体细节,但我看到你的调用存在以下潜在问题:
- You would need to specify the sort as descending. It is probably ascending by default.
- 您需要将排序指定为降序。它可能默认提升。
- You need to specify somewhere your metric as ga:pageviews. While you have this in your sort option, you also need to specify it for the metric. Is this the ga: parameter?
- 您需要将指标指定为ga:pageviews。在排序选项中使用此选项时,还需要为度量标准指定它。这是ga:参数吗?
I have found GA Explorer Tool to be of help.
我发现GA Explorer Tool可以提供帮助。
#1
0
private function getTopPages($profileId) {
$optParams = array(
'max-results' => 5,
'dimensions' => 'ga:pageTitle,ga:pagePath',
'sort' => '-ga:pageviews',
);
return $this->analytics->data_ga->get(
'ga:' . $profileId,
'2012-09-01',
'2012-09-30',
'ga:pageviews',
$optParams);
}
inspired by: http://axiacore.com/blog/how-get-list-most-popular-pages-google-analytics-python/
灵感来自:http://axiacore.com/blog/how-get-list-most-popular-pages-google-analytics-python/
#2
0
I don't know the specifics of the php calls, but I see the following potential problems with your call:
我不知道php调用的具体细节,但我看到你的调用存在以下潜在问题:
- You would need to specify the sort as descending. It is probably ascending by default.
- 您需要将排序指定为降序。它可能默认提升。
- You need to specify somewhere your metric as ga:pageviews. While you have this in your sort option, you also need to specify it for the metric. Is this the ga: parameter?
- 您需要将指标指定为ga:pageviews。在排序选项中使用此选项时,还需要为度量标准指定它。这是ga:参数吗?
I have found GA Explorer Tool to be of help.
我发现GA Explorer Tool可以提供帮助。