简体   繁体   English

如何将未经采样的报告从Google AnalyticsAPI存储到Google云端硬盘?

[英]How to store unsampled reports from Google Analytics API to Google Drive?

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 我阅读了有关如何将未采样报告的数据从Google Analytics API检索到Google云端硬盘的说明: https//developers.google.com/analytics/devguides/config/mgmt/v3/unsampled-reports#introduction

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 据我了解,以下是检索未采样报告的步骤:1。将未采样的报告存储到Google Drive API 2.使用Drive API下载文件

However, I couldn't find the instructions on how to store the unsampled reports to Google Drive API. 但是,我找不到有关如何将非抽样报告存储到Google云端硬盘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. 如果可以,请告诉我如何使用Drive API下载文件。

Thank you in advance. 先感谢您。

First of all, Unsampled Report is only available to Google Analytics 360 (Previously Google Analytics Premium) users. 首先,非抽样报告仅适用于Google Analytics 360(以前称为Google Analytics Premium)用户。 So if you use only the free version of the product this feature is simply not available, the API should give you an error. 因此,如果您仅使用产品的免费版本,则此功能根本不可用,API应该会给您一个错误。

The Unsampled API has 3 methods: Unsampled API有3种方法:

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

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. 因此,使用Unsampled Reporting API的动态显然与Core Reporting API略有不同。 After a query on the Core Reporting API you get the results right away. 在对Core Reporting API进行查询后,您可以立即获得结果。 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. 粗略地说,这是从Unsampled API导出数据的工作方式。

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

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

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