Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Google Analytics Data API examples

Open in Cloud Shell

These samples show how to use the Google Analytics Data API from Python.

Build and Run

  1. Enable APIs - Enable the Analytics Data API and create a new project or select an existing project.
  2. Download The Credentials - Configure your project using [Application Default Credentials][adc]. 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
  1. Clone the repo and cd into this directory
    $ git clone https://github.com/googleapis/python-analytics-data
    $ cd python-analytics-data/samples/snippets
  1. Install dependencies via pip3. Run pip3 install --upgrade google-analytics-data.
  2. **Review the comments starting with TODO(developer) and update the code to use correct values.
  3. Run with the command python3 SNIPPET_NAME.py. For example:
    $ python3 quickstart.py