Files
computer-playbook/roles/sys-front-inj-matomo
Kevin Veen-Birkenbach c835ca8f2c refactor(front-injection): stabilize run_once flow and explicit web-service loading
- sys-front-inj-all: load web-svc-cdn and web-svc-logout once; reinitialize inj_enabled after services; move run_once block to top; reorder injections.
- sys-front-inj-css: move run_once call into 01_core; fix app_style_present default; simplify main.
- sys-front-inj-desktop/js/matomo: deactivate per-role run_once blocks; keep utils/run_once where appropriate.
- sys-front-inj-logout: switch to files/logout.js + copy; update head_sub mtime lookup; mark set_fact tasks unchanged.
- sys-svc-cdn: inline former 01_core tasks into main; ensure shared/vendor dirs and set run_once in guarded block; remove 01_core.yml.

Rationale: prevent cascading 'false_condition: run_once_sys_svc_cdn is not defined' skips by setting run-once facts only after the necessary tasks and avoiding parent-scope guards; improves determinism and handler flushing.

Conversation: https://chatgpt.com/share/68ecfaa5-94a0-800f-b1b6-2b969074651f
2025-10-13 15:12:23 +02:00
..

Nginx Matomo Tracking Role

This Ansible role automates the integration of Matomo tracking code into Nginx-served websites. It simplifies the process of adding the Matomo analytics tracking script and image tracker to all your web pages served through Nginx.

Features

  • Automated insertion of Matomo tracking script into the </head> tag of HTML pages.
  • Integration of a noscript image tracker before the </body> tag for tracking users with JavaScript disabled.
  • Configuration to apply changes on every request, ensuring that dynamic content and single-page applications are also tracked.

Requirements

  • Nginx installed on the target server.
  • Matomo analytics platform set up and accessible.

Dependencies

  • None. This role is designed to be included in Nginx server block configurations.

Customization

You can customize the tracking script and the noscript image tracker by editing the matomo-tracking.js.j2 and matomo.subfilter.conf.j2 templates.

Author Information

This role was created in 2023 by Kevin Veen Birkenbach, providing a seamless way to add Matomo analytics to any website served via Nginx.