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.

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

报告相同问题?