Skip to main content

Track requests to your Flask website with Matomo

Project description

Flask-Matomo-D

PyPI

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

Installation

pip install flask-matomo-d

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",
                secure=True,
                allowed_paths=None)

@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.
  5. The secure parameter indicates whether the verification of trusted certificates is performed, by default is True.
  6. The allowed_paths indicates allowed paths of every incoming request to be tracked, use regex sintax. Ex: 'dasd|paht1|admin'

Meta

Lucas Hild - https://lucas-hild.de 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-D-0.0.2.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file Flask-Matomo-D-0.0.2.tar.gz.

File metadata

  • Download URL: Flask-Matomo-D-0.0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.1 requests/2.26.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/2.7.18

File hashes

Hashes for Flask-Matomo-D-0.0.2.tar.gz
Algorithm Hash digest
SHA256 74dd4488a00231fd2a6f5318b424a1449eb3ee3ae83c0bdb52979d2e8e83501c
MD5 36be530325ee967ae0d86ecf82cd4f91
BLAKE2b-256 c92229b0b65242177c6c1421628e18b59269e860c73ee330738fb33d7ce140ad

See more details on using hashes here.

Supported by

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