Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Repository files navigation

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.

ServiceStatus
CircleCICircleCI

Usage

A simple example:

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

Please see the test/test_everything.py 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/main.py file.

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

Example:

# as python named-argumentstracker.send('pageview', path="/test", title="Test page")
# as property dictionarytracker.send('pageview', {
'path': "/test",
'title': "Test page"
})

Attribution

This package is a fork of a package by the same name by Analytics Pros.

License

universal-analytics-python is licensed under the BSD license

About

Universal Analytics Python module

Resources

Stars

7 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages