0

so I'm really new to working with the Google Analytics API. I have managed to make the request work:

{
  "dateRange": {
    "startDate": "2021-01-08",
    "endDate": "2021-05-05"
  },
  "activityTypes": [
    "GOAL"
  ],
  "user": {
    "type": "CLIENT_ID",
    "userId": "2147448080.1620199617"
  },
  "viewId": "1556XXX89"
}

such that I can get back a json format file like:

{
  "sessions": [
    {
      "sessionId": "1620199614",
      "deviceCategory": "mobile",
      "platform": "Android",
      "dataSource": "web",
      "activities": [
        {
          "activityTime": "2021-05-05T07:53:08.366983Z",
          "source": "(direct)",
          "medium": "(none)",
          "channelGrouping": "Direct",
          "campaign": "(not set)",
          "keyword": "(not set)",
          "hostname": "somewebsite.com",
          "landingPagePath": "/client/loginorcreate/login",
          "activityType": "GOAL",
          "customDimension": [
            {
              "index": 1
            },
            {
              "index": 2
            },
            {
              "index": 3,
              "value": "59147"
            }
          ],
          "goals": {
            "goals": [
              {
                "goalIndex": 1,
                "goalCompletions": "1",
                "goalCompletionLocation": "/order/registerorder/postregister.html",
                "goalPreviousStep1": "page-z",
                "goalPreviousStep2": "page-y",
                "goalPreviousStep3": "page-x",
                "goalName": "order"
              }
            ]
          }
        }
      ],
      "sessionDate": "2021-05-05"
    }
  ],
  "totalRows": 1,
  "sampleRate": 1
}

now, ideally, I would get a different format response, and more importantly on where I don't have to specify each individual client ID. is there such a request format I can build, which would return something like:

clientID1 | activityTime | sessionId | activities
clientID2 | activityTime | sessionId | activities
clientID3 | activityTime | sessionId | activities

thanks!

1 Answers1

0

The google analytics api returns data in the json format that you are seeing currently. How you format that data will be up to you this must however been done locally by you.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449