PyGA - Python Google Analytics server-side tracking
What it is
It's a small module for python server-side google analytics tracking (or, simply, pyGA). It lets you track your page views via server-side.
The goal is to make the code cleaner, pythonic and more usable.
Original Google Analytics Reference is here
What it is good for
It's good for mobile web if you don't want to use any js on your pages (like for old phones, for example)
It's extremely useful if your site provides an external API, so you can track your API calls. That's the main reason why this implemention exists.
from pyga import GATracker ga = GATracker('domain.com', 'UA-xxxx') ga.track('/api/news/', user_session_id, ip_address, useragent)
import flask from flask import request, session #secret_key must be set to use session, see flask docs from pyga import FlaskGATracker #<...> ga = FlaskGATracker('domain.com', 'UA-xxxx') ga.track(request, session)
(ip address and so on keys will be described here)
#in you views.py from pyga import DjangoGATracker def some_view(request): ga = FlaskGATracker('domain.com', 'UA-xxxx') ga.track(request) #<...>
pip install -e git+https://bitbucket.org/DataGreed/pyga.git#egg=pyga-dev