https://github.com/callicoder/python-google-analytics-popular-pages
Python script to find the Top n pages from your Google analytics account and write the data to a file/stdout
https://github.com/callicoder/python-google-analytics-popular-pages
google-analytics google-analytics-api python
Last synced: about 2 months ago
JSON representation
Python script to find the Top n pages from your Google analytics account and write the data to a file/stdout
- Host: GitHub
- URL: https://github.com/callicoder/python-google-analytics-popular-pages
- Owner: callicoder
- Created: 2019-08-09T11:09:41.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-30T20:50:50.000Z (about 4 years ago)
- Last Synced: 2025-04-19T08:34:31.287Z (2 months ago)
- Topics: google-analytics, google-analytics-api, python
- Language: Python
- Size: 6.84 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
### Analyzer
Python script to find the Top n pages from your Google analytics account and write the response to a file/stdout in json/yaml format
### How to run
+ **Use virtualenv to create a virtual environment**
```bash
# Create a virtual env
$ virtualenv venv# Activate virtual env
$ source venv/bin/activate
```+ **Install dependencies using pip**
```bash
$ pip install -r requirements.txt
```+ **Specify Google service account credentials file location**
Follow [these instructions](https://cloud.google.com/iam/docs/creating-managing-service-accounts#iam-service-accounts-create-console) to create a service account in Google console. Download the `key.json` file and set the `KEY_FILE_LOCATION` in `.env`.
Note: You'll also need to enable Google analytics APIs.
+ **Add Google Analytics VIEW_ID in environment**
Follow these steps to get the VIEW_ID for your analytics account:
* Sign in to Google Analytics.
* Click Admin, and navigate to View.
* In the VIEW column, click View Settings.
* You'll find View ID in Basic Settings.+ **Run the script**
```bash
$ python main.py
```