2
votes

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",
                },
              ],
            },
          ],
1
Have you tried changing to sort to ga:date ?DaImTo
I have fixed itrened

1 Answers

1
votes

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

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