Google Analytics API not returning same data as Analytics dashboard

狂风中的少年 提交于 2019-12-07 15:44:45

问题


I'm trying to write a Google Analytics API query that simply returns the monthly unique visitors for each month over the last year.

This is the data I see in the Google Analytics dashboard.

I've used the Analytics API explorer to write the query, I've verified the ID and account is authed correctly. I'm using the ga:month dimension to get the data month-by-month.

This is the query, and the resultant data

These numbers are nothing at all like the ones I see on the Analytics dashboard.

This is a graph of that data.

I'm very confused. I can't see what is different between what I specify in the Google Analytics dashboard and what I've entered in the API query, or why I should get such wildly different numbers.

Edit: I've deduced that the problem lies when the start and end date span across 2013 to 2014. If my start and end date are both in 2013, the numbers are correct. But if it spans across from 2013 to 2014, the numbers are incorrect. Not sure how to fix it.


回答1:


I suspect you are having an issue with Sampling level

samplingLevel

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.


来源:https://stackoverflow.com/questions/22639479/google-analytics-api-not-returning-same-data-as-analytics-dashboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!