gpt4 book ai didi

google-analytics - 如何从Google Analytics(分析)API中获取非抽样数据-即使是一天?

转载 作者:行者123 更新时间:2023-12-03 15:46:45 24 4
gpt4 key购买 nike

我正在尝试从Google Analytics(分析)API中获取非抽样数据,但是由于某些原因,它总是以抽样的形式出现。即使我只选择一天并只过滤一页。这是我在Google的查询浏览器上尝试过的方法:



我需要做些什么来克服这个问题?另外,是否有办法查看采样了多少数据(无需登录Google Analytics(分析)页面...)?

最佳答案

在查询中,您需要提供sampiling level

samplingLevel=DEFAULT Optional.
Use this parameter to set the sampling level (i.e. the number of visits used to
calculate the result) for a reporting query. The allowed values are consistent with
the web interface and include:
•DEFAULT — Returns response with a sample size that balances speed and accuracy.
•FASTER — Returns a fast response with a smaller sample size.
•HIGHER_PRECISION — Returns a more accurate response using a large sample size,
but this may result in the response being slower.

If not supplied, the DEFAULT sampling level will be used.


您尚未说明要使用哪种语言,因此您必须检查库中的该语言并弄清楚如何发送。



更新:尝试帮助代码。我还没有测试过,但是我想您会把它添加为可选参数。让我知道它是否不起作用,我将看看是否可以使它起作用。

$optParams = array(
'dimensions' => 'ga:dateHour,ga:hour',
'filters' => 'ga:pagePath=~'.$pagelink.'*',
'max-results' => 1,
'sort' => 'ga:dateHour',
'samplingLevel' => 'HIGHER_PRECISION' );


$results_starttime = $connect->data_ga->get( 'ga:' . $signedupuser["google id"],
$startdate_analysed,
$enddate_analysed,
'ga:uniquePageviews', $optParams );




Update2:确保已从GitHub google/google-api-php-client下载了我检查过的库,并且那里的Analytics.php确实具有支持sampleingLevel的代码。



更新3获得旧版本的lib可以从上面的GitHub检查链接获得一个。
google-api-php-client


状态:

Beta版本的下一个主要修订版(1.0.1-beta)
库可用,请尽可能迁移。较新的版本
在GitHub上发布。所有新开发和问题跟踪
发生在Github上。

关于google-analytics - 如何从Google Analytics(分析)API中获取非抽样数据-即使是一天?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21666526/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com