These samples show how to use the Google Analytics Admin API from Node.js.
- Enable APIs - Enable the Analytics Admin API and create a new project or select an existing project.
- Download The Credentials - Configure your project using Application Default Credentials.
Click "Go to credentials" after enabling the APIs. Click "Create Credentials"
and select "Service Account Credentials" and download the credentials file. Then set the path to
this file to the environment variable
GOOGLE_APPLICATION_CREDENTIALS
:export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
- Clone the repo and cd into this directory.
git clone https://github.com/googleanalytics/nodejs-docs-samples cd nodejs-docs-samples/google-analytics-admin
- Install dependencies.
npm install
- Review the comments starting with
TODO(developer)
and update the code to use correct values. - Run with the command
node SAMPLE_FILE
. For example:node quickstart.js