Adds Matomo (aka Piwik) integration (#310)

* adds Matomo (aka Pwiki) integration

* adds tracking code in header
This commit is contained in:
Marco Blessing 2018-01-22 08:14:52 +01:00 committed by Dean Attali
parent 0ff0c5ad6b
commit 7677fbd01a
4 changed files with 46 additions and 4 deletions

View file

@ -32,6 +32,13 @@
 • 
<a href="{{ site.url }}">{{ site.url-pretty }}</a>
{% endif %}
{% if site.matomo %}
&nbsp;&bull;&nbsp;
{% if site.matomo.opt-out %}
<a href="http://{{- site.matomo.uri -}}/index.php?module=CoreAdminHome&action=optOut" target="_blank" class="text_muted">Do-not-Track</a>
{% endif %}
{% endif%}
</p>
<!-- Please don't remove this, keep my open source work credited :) -->
<p class="theme-by text-muted">

View file

@ -88,7 +88,7 @@
{% elsif site.avatar %}
<meta property="og:image" content="{{ site.url }}{{ site.avatar }}" />
{% endif %}
<!-- Twitter summary cards -->
<meta name="twitter:card" content="summary" />
@ -117,4 +117,8 @@
<meta name="twitter:image" content="{{ site.url }}{{ site.avatar }}" />
{% endif %}
{% if site.matomo %}
{% include matomo.html %}
{% endif %}
</head>

17
_includes/matomo.html Normal file
View file

@ -0,0 +1,17 @@
{% if site.matomo %}
<!-- Matomo -->
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//{{- site.matomo.uri -}}/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '{{- site.matomo.site_id -}}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
{% endif %}