浏览代码

Added matomo support (#633)

David Davó 2 年之前
父节点
当前提交
eefb6166eb
共有 2 个文件被更改,包括 19 次插入0 次删除
  1. 1 0
      README.md
  2. 18 0
      layouts/partials/analytics.html

+ 1 - 0
README.md

@@ -34,6 +34,7 @@ A [Hugo](https://gohugo.io/) theme for a personal portfolio with minimalist desi
   - GoatCounter
   - counter.dev
   - Google Analytics
+  - Matomo/Piwik
 - Comment Support
   - [Disqus](https://disqus.com/)
   - [Valine](https://valine.js.org/)

+ 18 - 0
layouts/partials/analytics.html

@@ -40,6 +40,24 @@
             src="//gc.zgo.at/count.js"
             ></script>
         {{ end }}
+
+        <!-- Piwik/Matomo -->
+        {{ with .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 }}
     {{ end }}
 {{ end }}