2
votes

I am trying to fetch data from Google Analytics API v3(analytics.data.ga.get) for the first time. I have entered ids, start-date, end-date, metrics, dimensions in APIs Explore like below in screenshot:

enter image description here

One thing I don't know where I can find my API_KEY as I have to pass API_KEY in get request url.

https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A62299534&start-date=2015-01-01&end-date=2017-07-13&metrics=ga%3Ausers%2Cga%3Apageviews&dimensions=ga%3ApagePath&key={YOUR_API_KEY}

Thanks in advance.

1

1 Answers

0
votes

The API explorer is a little bit mistaken in that you actually need an access_token to make a request. You will first need to setup a Developer project, and setup OAuth 2.0 for your application.

Instructions can be found in the quickstart guides

But for quicker way of getting an access_token that is valid for limited time you can use the Query Explorer to formulate a request, and then click the button at the bottom of the report that says Include current access_token in the Query URI (will expire in ~60 minutes).