简体   繁体   English

如何在1个请求中从Google Analytics(分析)获取所有页面的唯一身份用户

[英]How to get unique users from Google Analytics for all pages in 1 request

Is there any way to get unique users for all my pages in 1 GA request? 有什么方法可以在1个GA请求中为我的所有页面获取唯一身份用户? I have cca 7.000 pages on my portal and I try to get unique visits of last week, last fortnights, month and quarter year. 我的门户网站上有cca 7.000页,并且尝试获得上周,最后两周,月份和季度的唯一访问量。 But google interrupts my script if there is many requests, so i delay every request by 1,5 seconds... This is problem because it is interrupted anyway but bigger problem is the time getting the data. 但是,如果有很多请求,谷歌会中断我的脚本,所以我将每个请求延迟1.5秒...这是有问题的,因为无论如何它都会被中断,但是更大的问题是获取数据的时间。 It is 7000 * 4(periods) * 1,5s + some time to process the data - it's over 10 hours, maybe longer (it runs from yesterday evening and still running). 它是7000 * 4(期间)* 1,5s +一些时间来处理数据-它超过10个小时,甚至更长(它从昨天晚上开始运行并仍在运行)。 Is there some request to get all the pages in 1 request? 是否有要求将所有页面合并为1个请求? Now i've got somethin like: 现在我有了类似的东西:

$optParams = array(
    'filters' => $filter, // ga:hostname==' . $detailUrl (from other script)
    'max-results' => '25');

if('' != $segment) {
    $optParams['segment'] = $segment;
}

$data = $this->_analytics->data_ga->get(
    'ga:' . $this->_profileId,
    $from,
    $to,
    'ga:users', // users = unique visitors, sessions = visits
    $optParams);

$uniqueVisitors = $data->totalsForAllResults['ga:users'];

// Don't want to reach API request limit. Waiting for 1.5s
usleep(1500000); // 1500000

return $uniqueVisitors;

This function returns unique visitor (I hope so) for current page for 1 period... 此功能返回当前页面的唯一访问者(希望如此)1个周期...

Make separate queries for each time period, using ga:pagePath and ga:users. 使用ga:pagePath和ga:users在每个时间段分别进行查询。 Do NOT include any date or time dimension. 不要包括任何日期或时间维度。 You will get unique users for each page during that time period. 在该时间段内,您将为每个页面获得唯一身份用户。

And increase your max-results to 10,000... 并将您的最大结果增加到10,000 ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM