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', ...]
```
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
Release history Release notifications | RSS feed
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)
Built Distributions
File details
Details for the file pygoogleanalytics-1.1.tar.gz
.
File metadata
- Download URL: pygoogleanalytics-1.1.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4390d25d21aa6ff3f69eee26d6b660f6866b5935a3e6bb3848d66301a142bb96 |
|
MD5 | c05afb65f25679a730b080db41fdaaab |
|
BLAKE2b-256 | bd23d419b3e6bbabf0c092ac09f280f2ef2ff5cd7494c4fc02db14cd9be70a9a |
File details
Details for the file pygoogleanalytics-1.1-py3-none-any.whl
.
File metadata
- Download URL: pygoogleanalytics-1.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae45240a577369e9e1625c80ee75949d5f9004f2fd8d4688422606251a825b5e |
|
MD5 | 6e6d3126d6be2a5da8aad863c7828251 |
|
BLAKE2b-256 | bd08d44637c238f4a5796f66e8a00cd85bc4ef34b750adcd3de34ede6c9cf99a |
File details
Details for the file pygoogleanalytics-1.1-py2-none-any.whl
.
File metadata
- Download URL: pygoogleanalytics-1.1-py2-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f794b4dae4c653017f4374d9c3f42f07fe2da63976ba16efdc5872517f7b9447 |
|
MD5 | c843c0e9977a581175fcf7bb9b1fd4ad |
|
BLAKE2b-256 | 6ef940d4a8f2be951ab993cd9f396bb620e158abfdb92299f61ae5419962901c |