Skip to content
Universal Analytics Python module
Branch: master
Clone or download
Latest commit 78ee36a Oct 16, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
UniversalAnalytics Changed timing from float to int Apr 17, 2016
test Migrate to proper Python unittests Nov 11, 2014
.gitignore Fix packaging to include version tags Dec 4, 2014
DESCRIPTION.rst Update <> for distribution through PyPi Nov 10, 2013
LICENSE Fix packaging to include version tags Dec 4, 2014
Makefile Minor fix to Makefile for versioning logic Dec 5, 2014 Fix packaging to include version tags Dec 4, 2014

Universal Analytics for Python

This library provides a Python interface to Google Analytics, supporting the Universal Analytics Measurement Protocol, with an interface modeled (loosely) after Google's analytics.js.

NOTE this project is reasonably feature-complete for most use-cases, covering all relevant features of the Measurement Protocol, however we still consider it beta. Please feel free to file issues for feature requests.




The easiest way to install universal-analytics is directly from PyPi using pip by running the following command:

pip install universal-analytics-python

Or use latest code:

pip install -e git+

Otherwise you can download source code and install it directly:

python install


For the most accurate data in your reports, Analytics Pros recommends establishing a distinct ID for each of your users, and integrating that ID on your front-end web tracking, as well as back-end tracking calls. This provides for a consistent, correct representation of user engagement, without skewing overall visit metrics (and others).

A simple example:

from UniversalAnalytics import Tracker

tracker = Tracker.create('UA-XXXXX-Y', client_id = CUSTOMER_UNIQUE_ID)
tracker.send('event', 'Subscription', 'billing')

Please see the test/ script for additional examples.

This library support the following tracking types, with corresponding (optional) arguments:

  • pageview: [ page path ]
  • event: category, action, [ label [, value ] ]
  • social: network, action [, target ]
  • timing: category, variable, time [, label ]

Additional tracking types supported with property dictionaries:

  • transaction
  • item
  • screenview
  • exception

Property dictionaries permit the same naming conventions given in the analytics.js Field Reference, with the addition of common spelling variations, abbreviations, and hyphenated names (rather than camel-case). These are also demonstrated in the tests/ file.

Further, the property dictionaries support names as per the Measurement Protocol Parameter Reference, and properties/parameters can be passed as named arguments.


  # as python named-arguments
  tracker.send('pageview', path = "/test", title = "Test page") 
  # as property dictionary 
  tracker.send('pageview', {
    'path': "/test",
    'title': "Test page"

Features not implemented

  • Throttling

We're particularly interested in the scope of throttling for back-end tracking for users who have a defined use-case for it. Please contact us if you have such a use-case.


universal-analytics-python is licensed under the BSD license

You can’t perform that action at this time.