Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tikazyq/google-analytics-api-wrapper
The Goolge Analytics wrapper is a convenient tool to extract data from GA via API. It is especially useful when the user has many GA profiles / web properties.
https://github.com/tikazyq/google-analytics-api-wrapper
Last synced: 9 days ago
JSON representation
The Goolge Analytics wrapper is a convenient tool to extract data from GA via API. It is especially useful when the user has many GA profiles / web properties.
- Host: GitHub
- URL: https://github.com/tikazyq/google-analytics-api-wrapper
- Owner: tikazyq
- License: mit
- Created: 2015-03-06T21:01:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-06-04T05:07:48.000Z (5 months ago)
- Last Synced: 2024-10-12T04:07:03.552Z (25 days ago)
- Language: Python
- Size: 168 KB
- Stars: 6
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# google-analytics-api-wrapper
=======
The Goolge Analytics wrapper is a convenient tool to extract data from GA via API. It is especially useful when the user has many GA profiles / web properties.### Installation
```
$ pip install google-api-python-client pandas
$ python setup.py install
```
### Usage##### Authorize
Please go to https://console.developers.google.com to start an API project. Make sure you have enabled analytics API.
Create a new OAuth client ID and download it to your working directory.
Authorize your access to the API.
```python
from analytics_query import analytics_query as aqaq.authorize()
```Then authorize the app with your Google account that can access your GA account.
The console will then store your refresh token and access token in the file called "analytics.dat" in the working directory.
Now you can make the API call.
##### Query GAThe get_api_query method will take the parameters to fetch data from GA API and return as a pandas DataFrame.
```python
from analytics_query import analytics_query as aqdf = aq.get_api_query(start_date='7 days ago',
end_date='yesterday',
metrics='ga:date',
dimensions='ga:sessions')df.head()
```