Skip to main content

Wrapper for Google Analytics API python call

Project description

## PyGoogleAnalytics

Wrapper for Google Analytics API python calls

### Setup

First and foremost you need a google analytics api service account.
Details are available here see https://developers.google.com/analytics/devguides/reporting/core/v4/ for more details
Instructions are available here https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-py

```
$ pip install git+ssh://git@github.com/ademilly/pygoogleanalytics.git
```

### Usage

```python
import pygoogleanalytics

# Inputs for standard google analytics reporting api
api = pygoogleanalytics.APICaller(
['https://www.googleapis.com/auth/analytics.readonly'],
('https://analyticsreporting.googleapis.com/$discovery/rest'),
PATH_TO_P12_SECRET_FILE,
SERVICE_ACCOUNT_ADDRESS
)

# prepare a dimensionFilterClauses with a 'and' operator
request_filter = pygoogleanalytics.RequestFilter('and').add_filter(
{
"dimensionName": "some_dimension",
"operator": "some_operation",
"expressions": "some_expression"
}
).add_filter(
{
"dimensionName": "some_dimension",
"operator": "some_operation",
"expressions": "some_expression"
}
)

some_kpi = pygoogleanalytics.Requester(api).build_request().for_view(
'some_view_id'
).between(
'some_start_date', 'some_end_date'
).for_variables(
['var1', 'var2', ...]
).with_filter_clause(request_filter).run_request().get_value('metrics')

print some_kpi
```

output:
```
['some_value', ...]
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygoogleanalytics-1.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distributions

pygoogleanalytics-1.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

pygoogleanalytics-1.1-py2-none-any.whl (12.7 kB view details)

Uploaded Python 2

File details

Details for the file pygoogleanalytics-1.1.tar.gz.

File metadata

File hashes

Hashes for pygoogleanalytics-1.1.tar.gz
Algorithm Hash digest
SHA256 4390d25d21aa6ff3f69eee26d6b660f6866b5935a3e6bb3848d66301a142bb96
MD5 c05afb65f25679a730b080db41fdaaab
BLAKE2b-256 bd23d419b3e6bbabf0c092ac09f280f2ef2ff5cd7494c4fc02db14cd9be70a9a

See more details on using hashes here.

File details

Details for the file pygoogleanalytics-1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pygoogleanalytics-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae45240a577369e9e1625c80ee75949d5f9004f2fd8d4688422606251a825b5e
MD5 6e6d3126d6be2a5da8aad863c7828251
BLAKE2b-256 bd08d44637c238f4a5796f66e8a00cd85bc4ef34b750adcd3de34ede6c9cf99a

See more details on using hashes here.

File details

Details for the file pygoogleanalytics-1.1-py2-none-any.whl.

File metadata

File hashes

Hashes for pygoogleanalytics-1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 f794b4dae4c653017f4374d9c3f42f07fe2da63976ba16efdc5872517f7b9447
MD5 c843c0e9977a581175fcf7bb9b1fd4ad
BLAKE2b-256 6ef940d4a8f2be951ab993cd9f396bb620e158abfdb92299f61ae5419962901c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page