Google Analytics Fetch 自定义报告

Google Analytics Fetch Custom Report

我正在尝试在 React.JS 内置的自定义仪表板上显示来自 Google Analytics 的数据。我在我的 Google Analytics 仪表板中创建了一个自定义报告,并希望进行 GET 调用以检索此自定义报告以获取报告的数据。

GA documentation 仅显示了使用查询构建您自己的自定义报告的示例,并未实际调用已创建的自定义报告。有没有办法对特定自定义报告进行 GET 调用以获取其数据?

这是 Google Analytics

提供的示例
function queryReports() {
gapi.client.request({
  path: '/v4/reports:batchGet',
  root: 'https://analyticsreporting.googleapis.com/',
  method: 'POST',
  body: {
    reportRequests: [
      {
        viewId: VIEW_ID,
        dateRanges: [
          {
            startDate: '7daysAgo',
            endDate: 'today'
          }
        ],
        metrics: [
          {
            expression: 'ga:sessions'
          }
        ]
      }
    ]
  }
}).then(displayResults, console.error.bind(console));
}

不,没有其他方法可以以编程方式访问用户的自定义报告,您可能需要保存报告请求以便重新使用。每个报告 API batchGet 端点的请求都应该包含一个明确提供的 reportRequests 对象。