mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-09 11:47:14 +02:00
Optimized networking and matomo
This commit is contained in:
@@ -11,23 +11,9 @@ This Ansible role automates the integration of Matomo tracking code into Nginx-s
|
||||
- Nginx installed on the target server.
|
||||
- Matomo analytics platform set up and accessible.
|
||||
|
||||
## Role Variables
|
||||
- `matomo_domain`: The domain of your Matomo installation.
|
||||
- `domain`: The domain of the website you wish to track.
|
||||
- `matomo_auth_token`: Matomo auth token
|
||||
|
||||
## Dependencies
|
||||
- None. This role is designed to be included in Nginx server block configurations.
|
||||
|
||||
## Example Usage
|
||||
To enable Matomo tracking on your Nginx website, include the role in your playbook and set the required variables.
|
||||
|
||||
```yaml
|
||||
- hosts: webserver
|
||||
roles:
|
||||
- { role: nginx-global-matomo, matomo_domain: 'matomo.example.com', base_domain: 'example.com', matomo_site_id: '1' }
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
- name: Check if site already exists in Matomo
|
||||
uri:
|
||||
url: "https://{{matomo_domain}}/index.php?module=API&method=SitesManager.getSitesIdFromSiteUrl&url=https://{{base_domain}}&format=json&token_auth={{matomo_auth_token}}"
|
||||
url: "https://{{domains.matomo}}/index.php?module=API&method=SitesManager.getSitesIdFromSiteUrl&url=https://{{base_domain}}&format=json&token_auth={{matomo_auth_token}}"
|
||||
method: GET
|
||||
return_content: yes
|
||||
status_code: 200
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
- name: Add site to Matomo and get ID if not exists
|
||||
uri:
|
||||
url: "https://{{ matomo_domain }}/index.php"
|
||||
url: "https://{{ domains.matomo }}/index.php"
|
||||
method: POST
|
||||
body: "module=API&method=SitesManager.addSite&siteName={{ base_domain }}&urls=https://{{ base_domain }}&token_auth={{ matomo_auth_token }}&format=json"
|
||||
body_format: form-urlencoded
|
||||
|
@@ -7,7 +7,7 @@ _paq.push(["trackPageView"]);
|
||||
_paq.push(["trackAllContentImpressions"]);
|
||||
_paq.push(["enableLinkTracking"]);
|
||||
(function() {
|
||||
var u="//{{matomo_domain}}/";
|
||||
var u="//{{domains.matomo}}/";
|
||||
_paq.push(["setTrackerUrl", u+"matomo.php"]);
|
||||
_paq.push(["setSiteId", "{{matomo_site_id}}"]);
|
||||
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0];
|
||||
|
@@ -1,2 +1 @@
|
||||
matomo_domain: "matomo.{{primary_domain}}"
|
||||
base_domain: "{{ domain | regex_replace('^(?:.*\\.)?(.+\\..+)$', '\\1') }}"
|
||||
|
Reference in New Issue
Block a user