Google Api返回的数据不是最新的(实时)

2024-10-04 03:16:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个具有多个属性的帐户,我正在查询Google Analytics API来为每个属性拉Sessions和{a3}。在

现在是太平洋标准时间晚上8点45分,我有三个楼盘的20小时(8点)的数据,但另外两个楼盘只有13小时(下午1点)的数据。在查看GA UI时,所有5个属性都有到晚上8点的数据。在

我希望创建一个报告,以每小时为基础汇总所有5个物业的指标,但如果两个物业要落后几个小时,我就不能这样做。在

下面是我用来查询API的代码:

# configure query details
dimensions = "ga:hour"
metrics = "ga:sessions,ga:pageviews"
samplingLevel = "HIGHER_PRECISION"

for site in sites:

    # Fetch data from API for yesterday
    data = service.data().ga().get(
                ids=site,
                start_date=YESTERDAY,
                end_date=YESTERDAY,
                metrics=metrics,
                dimensions=dimensions,
                samplingLevel=samplingLevel
            ).execute()

    # Fetch data from API for today
    data = service.data().ga().get(
                ids=site,
                start_date=TODAY,
                end_date=TODAY,
                metrics=metrics,
                dimensions=dimensions,
                samplingLevel=samplingLevel
            ).execute()

是否需要为落后于计划的属性启用某些设置/配置?


Tags: 数据apifordatadate属性sitefetch
1条回答
网友
1楼 · 发布于 2024-10-04 03:16:16

谷歌分析可能需要24到48小时才能完成数据处理。在此之前可用的数据将不会100%正确,因为它没有完成处理。也不能保证所有的数据至少24小时前都会在那里。你将不能用reporting api来做你所说的。在

虽然您的一些物业可能会提前显示数据,但这并不是完整的,也不能保证明天他们仍然会提前显示数据。在

Data processing latency
Processing latency is 24-48 hours. Standard accounts that send more than 200,000 sessions per day to Google Analytics will result in the reports being refreshed only once a day. This can delay updates to reports and metrics for up to two days. To restore intra-day processing, reduce the number of sessions you send to < 200,000 per day. For Premium accounts, this limit is extended to 2 billion hits per month.

我建议您考虑使用Real-time api来实现这一点,主要缺点是您可以通过实时api访问的维度和度量的数量非常有限。在

相关问题 更多 >