Page Summary
-
This quickstart guide demonstrates how to set up tools and access, enable the API, install an SDK, and make an API call using either the Data API or the Admin API.
-
You can choose to authenticate with a user account or a service account for this quickstart.
-
Before beginning, you need to create a service account and Google Cloud VM instance, install and initialize the gcloud CLI, and grant the service account access to a Google Analytics property.
-
The Admin API needs to be enabled for your Google Cloud project.
-
SDKs are available for various programming languages, including Java, PHP, Python, Node.js, .NET, Ruby, and Go, and REST access is also supported.
-
The guide provides code samples in multiple languages to demonstrate how to make an API call to list Google Analytics accounts accessible to the authenticated user.
You can use the Data API or Admin API for this quickstart:
You can authenticate with a user account or service account:
In this quickstart, you create and send a
list
request.
Here's a summary of the steps:
- Set up tools and access.
- Enable the API.
- Install an SDK.
- Make an API call.
Before you begin
Install and initialize the gcloud CLI.
To generate Application Default Credentials and give your account the necessary scopes, run the following:
gcloud auth application-default login --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/analytics.readonly"In the Google Analytics UI, grant your user account access to a Google Analytics property.
Enable the Admin API
To select or create a Google Cloud project, and enable the API, click Enable the Google Analytics Admin API.
Enable the Google Analytics APIInstall an SDK
Install the SDK for your programming language.