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

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.

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

报告相同问题?

悬赏问题

  • ¥60 不懂得怎么运行下载来的代码
  • ¥15 CST导出3D模型图为什么和软件显示不一样?
  • ¥15 加热反应炉PLC控制系统设计(相关搜索:梯形图)
  • ¥15 python 用Dorc包报错,我的写法和网上教的是一样的但是它显示无效参数,是什么问题
  • ¥15 经过滑动平均后的一维信号还原用什么结构好呢?
  • ¥15 指定IP电脑的访问设置
  • ¥30 matlab ode45 未发现警告,但是运行出错
  • ¥15 为什么devc++编译项目会失败啊
  • ¥15 vscode platformio
  • ¥15 代写uni代码,app唤醒