Skip to content

Commit 1851a7b

Browse files
committed
feat: add Matomo tracking integration
1 parent 39e73ac commit 1851a7b

3 files changed

Lines changed: 41 additions & 5 deletions

File tree

config.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ unsafe= true # permet d'utiliser du HTML dans les articles markdown
9797
url = "https://www.google.com/search?q=site%3Acluboeno.com"
9898
weight = 6
9999

100-
101-
102-
103-
104100
# this will also be in author bio if there is no writer.
105101
[params.social]
106102
facebook = "https://www.facebook.com/lecluboeno"
@@ -214,3 +210,13 @@ unsafe= true # permet d'utiliser du HTML dans les articles markdown
214210
github = ""
215211
pinterest = ""
216212
stackoverflow = ""
213+
214+
[params.matomo]
215+
enable = true # Active/désactive globalement
216+
url = "https://analytics.lechaps.com/" # Termine par /
217+
siteID = 2
218+
219+
# Options utiles
220+
respectDNT = true # Respect du Do Not Track
221+
disableCookies = true # Matomo sans cookies (utile en dev / RGPD)
222+
noscript = true # Pixel <noscript> en fallback

themes/NederburgByLechaps/layouts/_default/baseof.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<!DOCTYPE html>
22
<html lang="{{ .Site.LanguageCode }}">
3-
<head>{{ partial "head.html" . }}</head>
3+
<head>
4+
{{ partial "head.html" . }}
5+
{{ if .Site.Params.matomo.enable }}
6+
{{ partial "matomo.html" . }}
7+
{{ end }}
8+
</head>
49
{{ block "body" . }}
510
<body class="home blog ct-body standard">
611
{{ end }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- $p := .Site.Params.matomo -}}
2+
{{- if and $p $p.enable $p.url $p.siteID -}}
3+
<script>
4+
var _paq = window._paq = window._paq || [];
5+
{{- if $p.respectDNT }} _paq.push(['setDoNotTrack', true]); {{ end -}}
6+
{{- if $p.disableCookies }} _paq.push(['disableCookies']); {{ end -}}
7+
{{- with $p.domains }} _paq.push(['setDomains', {{ . | jsonify }} ]); {{ end -}}
8+
_paq.push(['enableLinkTracking']);
9+
_paq.push(['trackPageView']);
10+
(function() {
11+
var u="{{ trim $p.url " " }}";
12+
_paq.push(['setTrackerUrl', u + 'matomo.php']);
13+
_paq.push(['setSiteId', '{{ $p.siteID }}']);
14+
var d=document,g=d.createElement('script'),s=d.getElementsByTagName('script')[0];
15+
g.async=true; g.src=u + 'matomo.js'; s.parentNode.insertBefore(g,s);
16+
})();
17+
</script>
18+
{{- if $p.noscript }}
19+
<noscript>
20+
<p><img referrerpolicy="no-referrer-when-downgrade"
21+
src="{{ trim $p.url " " }}matomo.php?idsite={{ $p.siteID }}&amp;rec=1"
22+
style="border:0" alt=""/></p>
23+
</noscript>
24+
{{- end -}}
25+
{{- end -}}

0 commit comments

Comments
 (0)