谷歌分析API查询特定的网址 [英] google analytics api query a specific url

查看:106
本文介绍了谷歌分析API查询特定的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHP访问Google Analytics(分析)API,该API适用于我的最终目标,但我希望能够进一步过滤结果。
现在我正在使用:

  $ OBJresult = $ analytics  - > data_ga  - > get(
'ga:'。$ profilID,
'2012-01-01',
date(Ymd),
'ga:visits',
数组(
'维度'=>'ga:pagePath',
'metrics'=>'ga:pageviews',
'sort'=>'-ga:pageviews ',
'max-results'=>'25'

);

目前,这将返回一组25个页面,按其命中次序排序。
我想将结果限制在服务器中的特定路径。所以例如只查询domain.com/news,只查看最热门的新闻页面。
我可以使用PHP进行过滤,但要尽可能具体地查询。



感谢您的帮助

解决方案

使用过滤器选项。 $ b

  $ OBJresult = $ analytics-> data_ga-> get(
'ga:'。$ profilID,
'2012-01-01',
date( ymd),
'ga:visits',
array(
'filters'=>'ga:pagePath == / news',
'dimensions'=> 'ga:pagePath',
'metrics'=>'ga:pageviews',
'sort'=>'-ga:pageviews',
'max-results'=> ;'25'

);

请参阅这里列出您可以过滤的页面跟踪维度。


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'
    )
);

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.

Thanks for the help

解决方案

Use the filters option.

$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查询特定的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆