如何将来自 Google Analytics API 的非抽样报告存储到 Google Drive? [英] How to store unsampled reports from Google Analytics API to Google Drive?

查看:22
本文介绍了如何将来自 Google Analytics API 的非抽样报告存储到 Google Drive?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了有关如何将非抽样报告的数据从 Google Analytics API 检索到 Google Drive 的说明:https://developers.google.com/analytics/devguides/config/mgmt/v3/unsampled-reports#introduction

I read this instruction on how to retrieve data for unsampled reports from Google Analytics API to Google Drive: https://developers.google.com/analytics/devguides/config/mgmt/v3/unsampled-reports#introduction

据我了解,以下是检索非抽样报告的步骤:1. 将非抽样报告存储到 Google Drive API2.使用Drive API下载文件

As far as I understand, here are the steps to retrieve unsampled reports: 1. Store the unsampled reports to Google Drive API 2. Use Drive API to download the file

但是,我找不到有关如何将非抽样报告存储到 Google Drive API 的说明.你能详细告诉我如何做到这一点吗?另外,如果可以,请告诉我如何使用 Drive API 下载文件.

However, I couldn't find the instructions on how to store the unsampled reports to Google Drive API. Could you please tell me in details on how to do this? Also if you could, please tell me how to use Drive API to download the file as well.

提前致谢.

推荐答案

首先,非抽样报告仅适用于 Google Analytics 360(以前称为 Google Analytics Premium)用户.因此,如果您仅使用该产品的免费版本,则此功能根本不可用,API 应该会给您一个错误.

First of all, Unsampled Report is only available to Google Analytics 360 (Previously Google Analytics Premium) users. So if you use only the free version of the product this feature is simply not available, the API should give you an error.

Unsampled API 有 3 个方法:

The Unsampled API has 3 methods:

  • insert - 创建一个新的非抽样报告
  • get - 获取给定非抽样报告的状态
  • list - 列出您在给定 profileId 中创建的所有非抽样报告的状态
  • insert - Creates a new Unsampled Report
  • get - Get the status of a given Unsampled Report
  • list - list the status of all unsampled reports you created in a given profileId

现在您必须记住,生成非抽样报告可能需要几个小时.因此,使用 Unsampled Reporting API 的动态显然与 Core Reporting API 略有不同.在 Core Reporting API 上进行查询后,您会立即获得结果.使用 Unsampled API,您只需创建一个报告并等待它准备就绪.

Now you have to keep in mind that Unsampled Reports can take a few hours to be generated. So the dynamics of using the Unsampled Reporting API are obviously a bit different from the Core Reporting API. After a query on the Core Reporting API you get the results right away. With the Unsampled API you just create a report and have to wait for it to be ready.

以下是从 Unsampled API 导出数据的大致工作原理.

Here's, roughly, how exporting data from the Unsampled API works.

  1. 使用insert 方法来创建新的非抽样报告.响应可能有status: PENDING 表示正在处理报告.您想存储从该请求中获得的 id 参数.
  2. 等一个小时
  3. 使用步骤 (1) 中的 id 并发出 get 请求到 API.这将为您提供非抽样报告的当前状态.如果这仍然是 PENDING,请返回步骤 (2).
  4. 如果状态为 COMPLETE,则报告应该是完整的,并且已经在 Google 云端硬盘中等待您.API 应该返回一个 driveDownloadDetails.documentId 您想要存储它.
  5. 使用 Google Drive API 获取文件内容您从步骤 (4) 中获得的参考
  1. Use the insert method on the API to create a new Unsampled Report. The Response will probably have a status: PENDING which means the report is being processed. You want to store the id parameter you get from this request.
  2. Wait for an hour
  3. Use the id from step (1) and issue a get request to the API. This will give you the current status of the unsampled report. If this is still PENDING go back to step (2).
  4. If the status is COMPLETE the report should be complete and already waiting for you in Google Drive. The API should return a driveDownloadDetails.documentId you want to store this.
  5. Use the Google Drive API to fetch the contents of the file reference you got from step (4)

这篇关于如何将来自 Google Analytics API 的非抽样报告存储到 Google Drive?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆