Skip to main content

Track requests to your Flask website with Matomo

Project description

image0 PyPI Docs

Flask-Matomo is a library which lets you track the requests of your Flask website using Matomo (Piwik).

Installation

pip install flask-matomo

Usage

from flask import Flask, render_template
from flask_matomo import *

app = Flask(__name__)
matomo = Matomo(app, matomo_url="https://matomo.mydomain.com",
                id_site=5, token_auth="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

@app.route("/")
def index():
  return render_template("index.html")

if __name__ == "__main__":
  app.run()

In the code above:

  1. The Matomo object is created by passing in the Flask application and arguments to configure Matomo.

  2. The matomo_url parameter is the url to your Matomo installation.

  3. The id_site parameter is the id of your site. This is used if you track several websites with on Matomo installation. It can be found if you open your Matomo dashboard, change to site you want to track and look for &idSite= in the url.

  4. The token_auth parameter can be found in the area API in the settings of Matomo. It is required for tracking the ip address.

Meta

This project is licensed under the MIT License - see the LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-Matomo-1.2.0.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file Flask-Matomo-1.2.0.tar.gz.

File metadata

File hashes

Hashes for Flask-Matomo-1.2.0.tar.gz
Algorithm Hash digest
SHA256 12d77ebe25545d97f6efe888ca6dc86ce7bc959eac6a05f01d781b504a3124e0
MD5 ee4f5be29d92c0903ea2ce498b35b5ae
BLAKE2b-256 35caf8b9f9b95d3a376006b7ae4a6e0cd4cb10cecce42fb2c91ecbb7210894bc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page