feat: add Matomo analytics tracking

Tracking features:
- Matomo analytics integration (site ID: 4)
- Initial pageview tracking on load
- HTMX language change tracking as virtual pageviews
- Link tracking enabled for outbound clicks

Security updates:
- Update CSP to allow matomo.drolo.club for script-src and connect-src
- Matomo script loaded asynchronously

Implementation:
- Added Matomo tracking code before </body>
- Track HTMX navigation events (language changes)
- Preserve privacy with self-hosted Matomo instance
This commit is contained in:
juanatsap
2025-11-09 15:02:31 +00:00
parent 6da7da0c49
commit 857162385f
2 changed files with 29 additions and 2 deletions
+2 -2
View File
@@ -30,11 +30,11 @@ func SecurityHeaders(next http.Handler) http.Handler {
// Content Security Policy (comprehensive)
csp := "default-src 'self'; " +
"script-src 'self' 'unsafe-inline' https://unpkg.com https://code.iconify.design; " +
"script-src 'self' 'unsafe-inline' https://unpkg.com https://code.iconify.design https://matomo.drolo.club; " +
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; " +
"font-src 'self' https://fonts.gstatic.com; " +
"img-src 'self' data: https:; " +
"connect-src 'self' https://api.iconify.design; " +
"connect-src 'self' https://api.iconify.design https://matomo.drolo.club; " +
"frame-ancestors 'self'; " +
"base-uri 'self'; " +
"form-action 'self'"