tristanbailey / pyGACustomDimensions

This set of Python scripts allows for the mass creation and modification of Google Analytics custom dimensions, using the Management API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyGACustomDimensions

This set of Python scripts allows for the mass creation and modification of Google Analytics custom dimensions, using the Management API. This can be adapted with other API connectors, with Java or Javascript for instance.

*** Reference:

*** Requires:

  • A Google Cloud Platform project with the Analytics API enabled, a set of credentials and a secrect key (.p12 or JSON, although this project uses .p12).
  • A Google Analytics account with access granted to the e-mail address set in the credentials
  • Python 3 or higher
  • Python module pyOpenSSL; install using pip: pip install --upgrade pyOpenSSL
  • Python Google API client library; install using pip: pip install --upgrade google-api-python-client

*** Usage: Open a shell prompt (bash et al. for Linux, Terminal for Mac, IDLE for Windows) and enter: python %script name% where %script name% is the name of one of the .py scripts. Each script includes user prompts for details such as their Google Analytics property ID, whether their property is a Google Analytics Premium/360 property, whether to set custom dimensions as inactive or to choose a default dimension scope.

*** Scripts and features:

  • config.py: configuration file
  • accountList.py: used to pull a list of all Google Analytics accounts your credentials can access
  • exportAllCustomDimensions.py: export custom dimension definitions as CSV files, which can be reimported using importCSV.py
  • fillAllCustomDimensions.py: fills all available custom dimension slots in your property, which allows for setting/updating dimensions at specific indexes.
  • updateAllCustomDimensions.py: runs a blanket dimension update, setting a scope and an activation status for all dimensions in the property.

The inputs folder contains template CSV files for use with the scripts. The exports folder contains CSV files generated by exportAllCustomDimensions.py

About

This set of Python scripts allows for the mass creation and modification of Google Analytics custom dimensions, using the Management API.

License:MIT License


Languages

Language:Python 100.0%