Export des stats de visites de RegardCitoyens, NosDéputés et NosSénateurs
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
data
js
.gitignore
LICENSE.md
README.md
collect.py
ga-api-credentials.json.example
index.html
requirements.txt
settings.py.example
update.sh

README.md

Stats-Analytics

Collects automatically daily stats (users, pageviews...) from Google Analytics monitored websites and version results in data.

Data is redistributed as OpenData under (ODbL licence).

Install

  • Create a virtualenv analytics using virtualenvwrapper and install dependencies:
sudo apt-get install virtualenvwrapper
source $(which virtualenvwrapper.sh)
mkvirtualenv analytics
pip install -r requirements.txt
  • Or install dependency library globally:
sudo pip install google-api-python-client

Configure

  • Create a new project in the Google API Console and create a service account. This will let you download a json file with credentials.

  • Move this file to the current directory and rename it ga-pi-credentials.json. It should look similar to ga-api-credentials.json.example.

  • In the Google API Console, click on the newly created accound to read its details and copy its e-mail address. Then connect to Google Analytics Admin Seettings and add a user with this e-mail and "Read & Analyze" permissions.

  • Copy settings.py.example and edit it to setup chosen websites (VIEWS) and resulting data (FIELDS).

cp settings.py{.example,}

Run

  • Collect all data
./collect.py
  • Book automatic git versioning of data with update.sh and a cronjob.
./update.sh

Crontab:

m  h  dom mon dow   command
5  3   *   *   *    $PATH_TO_THIS_REPO/update.sh 2>&1