Skip to content

Commit

Permalink
Merge pull request #367 from Xpirix/matomo_integration
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux authored Jul 26, 2024
2 parents 75f6a39 + b7b27eb commit bd77ce7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ newsfeed ='https://feed.qgis.org/?lang=en&json=1'
## This will turn on Coockie popup. True to show popup
cookiesstate = false

# Matomo
matomoURL = "//matomo.qgis.org/"
matomoSiteId = '6'

# commit hash file
commitFile = "config/commit.toml"

Expand Down
12 changes: 12 additions & 0 deletions themes/hugo-bulma-blocks-theme/assets/js/matomo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u=matomoURL;
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', matomoSiteId]);
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);
})();
9 changes: 7 additions & 2 deletions themes/hugo-bulma-blocks-theme/layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
{{/* QR Encoding Logic */}}
{{ $qrencodejs := resources.Get "js/qrcodegen-v1.8.0-es6.js"| resources.Minify | resources.Fingerprint }}
<script defer src="{{ $qrencodejs.RelPermalink }}"></script>
<script>
var matomoURL = {{ .Site.Params.matomoURL }}
var matomoSiteId = {{ .Site.Params.matomoSiteId }}
</script>

{{/* Homegrown JS functions */}}
{{ $expandjs := resources.Get "js/card-expand.js" }}
Expand All @@ -153,11 +157,12 @@
{{ $qrcreatejs := resources.Get "js/qrcreate.js" }}
{{ $fusejs := resources.Get "js/fuse.js" }}
{{ $markjs := resources.Get "js/mark.min.js" }}
{{ $matomojs := resources.Get "js/matomo.js" }}
{{/* See https://www.youtube.com/watch?v=T33NN_pPeNI */}}
{{ $js := slice $animatejs $expandjs $navbarjs $qrcreatejs $fusejs $markjs | resources.Concat "js/all.js" | resources.Minify | resources.Fingerprint }}
{{ $js := slice $animatejs $expandjs $navbarjs $qrcreatejs $fusejs $markjs $matomojs | resources.Concat "js/all.js" | resources.Minify | resources.Fingerprint }}
{{ if (eq .Site.Params.cookiesstate true) }}
{{ $cookiejs := resources.Get "js/cookie.js" }}
{{ $js = slice $animatejs $expandjs $navbarjs $qrcreatejs $fusejs $markjs $cookiejs | resources.Concat "js/all.js" | resources.Minify | resources.Fingerprint }}
{{ $js = slice $animatejs $expandjs $navbarjs $qrcreatejs $fusejs $markjs $matomojs $cookiejs | resources.Concat "js/all.js" | resources.Minify | resources.Fingerprint }}
{{ end }}
<script defer src="{{ $js.RelPermalink }}"></script>
{{/* Search needs to be rendered as a template to ensure urls are correct */}}
Expand Down

0 comments on commit bd77ce7

Please sign in to comment.