An open API service indexing awesome lists of open source software.

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

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
```