time) in Google Sheets

I'm trying to access the Google Analytics API via Google Sheets (Google Script).

So within the script, I'm trying to use the URI as described here: https://developers.google.com/analytics/devguides/reporting/realtime/v3/reference/data/realtime/get

The API call looks something like this:

GET https://www.googleapis.com/analytics/v3/data/realtime?ids=3254435&metrics=ga%3AActiveUsers&key={YOUR_API_KEY}

Within my Google Analytics Script, I've also created a Public API Access key: 在这里输入图像描述

However, I can't seem to get any data whether if I'm appending the token key in the URI or within the header.

Can any one point me to the right direction?

Thanks


The public api key is for public access APIs. Data that is not owned by a user. You need to create client id from web application.

Then you will be able to authenticate it using Oauth2.

this might get you started. https://developers.google.com/apps-script/advanced/analytics

How to know when you need to be authenticated:

  • Public API: Aanalytics metadata API meta data doesn't belong to any user its public data anyone can access.

  • User data API: Google Analytics Real-time Data the data returned is owned by a user, it is not public data viewable by everyone. Documentation states

  • Requires authorization

    If the documentation says requires authentication then you have to be authenticated to access that call.


    You can use Google Analytics API easily just by enabling them in App Script.

    Below is the Guide to using Real-time API in Google Spreadsheet https://www.tatvic.com/blog/google-analytics-real-time-data-in-google-sheet/

    Just like above you can use any API no need to take care of tokens.

    链接地址: http://www.djcxy.com/p/68124.html

    上一篇: Google Analytics数据上传

    下一篇: 时间)在Google表格中