简体   繁体   中英

Google Analytics Reporting API Sort By Date

I have followed this tutorial on how to get data from the google report api, i was able to download some sample code.

https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/web-js

First I got it to work in the Query explorer, but then i change the sample code, it fails.

Here is what I tried:

      reportRequests: [
            {
              viewId: VIEW_ID,
              dateRanges: [
                {
                  startDate: "30daysAgo",
                  endDate: "today",
                },
              ],
              metrics: [
                {
                  expression: "ga:sessions",
                },
              ],

              dimensions: [{ expression: "ga:date" }],

              sort: [
                {
                  expression: "ga:sessions",
                },
              ],
            },
          ],

You have to to set ga:date in sort expression obj:

sort: [
  {
    expression: "ga:date",
  },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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