Skip to main content

Python implementation of the Piwik HTTP API.

Note: This project is called python-piwik on PyPI since pypiwik is already taken by an abandoned project.

# Usage

Basic usage:

from pypiwik.tracker import PiwikTracker tracker = PiwikTracker(’http://example.com’, 1)

now you can call

tracker.track_page_view()

to make a server-to-server tracking request, or call

tracker.tracking_code()

to generate the correct Javascript snippet.

## Tracking variables

Tracking variables are set as class attributes on the tracker object. Have a look at the pypiwik.tracker.PARAMETERS dictionary to see which attribute maps to which tracking parameter, e.g.:

tracker = PiwikTracker(’http://example.com’, 1) tracker.action_name = ‘Help / Support’ tracker.track_page_view()

You can also pass the tracking variables to the track_page_view or tracking_code call as kwargs. The code above is equivalent to the following:

tracker = PiwikTracker(’http://example.com’, 1) tracker.track_page_view(action_name=’Help / Support’)

## Custom variables

Custom variables can be set in the page_custom_vars and visit_custom_vars dictionary to track custom variables in the page and visit scope:

_Note:_ Piwik allows at most 5 custom variables per scope. When making server-to-server requests, the code does not check for the numbers of variables in the dictionary.

## Server API

When making server-to-server calls, pypiwik will use HTTP headers for the following variables to reduce the request size:

  • user_agent

  • referer

  • lang

If you want to pass the values as regular variables, set spoof_request to False on the tracker instance.

## Cloning another request

If you want to make server-to-server requests based on a HTTP request of an actual user, pass the request object to __init__:

tracker = PiwikTracker(’http://example.com’, 1, request)

_Note:_ atm, only Django-like request objects supported (an object which has a META dictionary).

# TODO

Metadata

Release files for python-piwik 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-piwik 0.2
File Size Uploaded Provenance Actions
python-piwik-0.2.tar.gz 23.5 kB Without provenance Details for python-piwik-0.2.tar.gz

Release files / python-piwik-0.2.tar.gz

Download URL python-piwik-0.2.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
593e663f44721b63f6cd50800df2f634aa7a43228be5e1e01de4bd0aeff3d23c
BLAKE2b-256 checksum
How to use checksums
2af9cdf6179f1967fdc67f4c90ee537c3e130450bc1b6abcdc1c73a74347d299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for python-piwik 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page