我正在使用 PHP 访问 Google 分析 API,这对我有用,但我想进一步过滤结果.现在我正在使用:
I am accessing the Google analytics API with PHP which works on my end but I'd love to filter the results a bit further. Right now I am using:
$OBJresult = $analytics -> data_ga -> get(
'ga:' . $profilID,
'2012-01-01',
date( "Y-m-d" ),
'ga:visits',
array(
'dimensions' => 'ga:pagePath',
'metrics' => 'ga:pageviews',
'sort' => '-ga:pageviews',
'max-results' => '25'
)
);
目前,这将返回一组 25 个按其命中排序的页面.我很想将结果限制在服务器内的特定路径.所以例如只查询 domain.com/news 并且只查看最热门的新闻页面是什么.我可以使用 PHP 进行过滤,但希望查询尽可能具体.
Currently this returns a set of 25 pages sorted by its hits. I would love to restrict the results to a specific path within the server. So e.g. only query domain.com/news and only see what the most hit news pages are. I can filter with PHP but rather have the query as specific as possible.
感谢您的帮助
使用 filters
选项.
$OBJresult = $analytics->data_ga->get(
'ga:' . $profilID,
'2012-01-01',
date("Y-m-d"),
'ga:visits',
array(
'filters' => 'ga:pagePath==/news',
'dimensions' => 'ga:pagePath',
'metrics' => 'ga:pageviews',
'sort' => '-ga:pageviews',
'max-results' => '25'
)
);
请参阅此处,了解您的页面跟踪维度列表可以过滤.
See here for the list of page tracking dimensions you can filter on.
这篇关于谷歌分析 api 查询特定 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!