dtsfnyay300457 2016-01-15 04:53
浏览 44
已采纳

PHP - Google Analytics(分析) - 获取上一个小时的综合浏览量

I'm using Google Analytics Client Api(https://github.com/google/google-api-php-client.git) to get the pageviews. It worked when I tried to get data from 7daysAgo to today, my code is:

function getResults(&$analytics, $profileId) {
   return $analytics->data_ga->get(
       'ga:' . $profileId,
       '7daysAgo',
       'today',
       'ga:visits',
        array(
            'filters' => 'ga:pagePath==/project_z2o/',
            'dimensions' => 'ga:pagePath',
            'metrics' => 'ga:pageviews',
            'sort' => '-ga:pageviews',
            'max-results' => '25'
        ));
     }

but now, I want to get the data of the last previous hour. ex: current time is: 01-15-2016 11:49:50 and I run my code. I want to get the pageviews between 01-15-2016 10:49:50 and 01-15-2016 11:49:50. How can I get it. Please help. Thanks.

  • 写回答

1条回答 默认 最新

  • drm30963 2016-01-15 05:37
    关注

    You cannot usually get the last hour, since GA need some time to process hits (in the docs given as 4-24 hours, although on small sites processing sometimes seems almost instantly).

    You can however get a limited set of information (pageviews, events, traffic sources, location, goal conversions) via the Realtime API which might be better suited for what you need.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB动图的问题
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名