Skip to content

Commit

Permalink
feat: add matomo analytics support (#500)
Browse files Browse the repository at this point in the history
Closes #411
  • Loading branch information
lxndrblz committed Apr 6, 2024
1 parent 20e61c6 commit 418c14e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions layouts/partials/analytics/matomo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Piwik/Matomo -->
{{ with .Site.Params.Matomo }}
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//{{ .instance }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{{ .siteId }}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
{{ end }}
4 changes: 4 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@
{{- partial "analytics/umami" . -}}
{{ end }}

{{ if and hugo.IsProduction .Site.Params.Matomo.instance .Site.Params.Matomo.siteId }}
{{- partial "analytics/matomo" . -}}
{{ end }}


<!-- Twitter Cards -->
{{ template "_internal/twitter_cards.html" . }}
Expand Down

0 comments on commit 418c14e

Please sign in to comment.