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

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

问题描述

我正在使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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