Skip to content

Commit

Permalink
[Matomo] Able to specify host and siteId
Browse files Browse the repository at this point in the history
  • Loading branch information
Daneo Van Overloop committed May 26, 2018
1 parent 61e0711 commit 4da4f63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{{ if .RSSLink }}
<link href="{{ .RSSLink }}" rel="alternate" type="application/rss+xml">
{{ end }}
{{ if .Site.Params.MatomoUrl }}{{ partial "matomo.html" . }}{{ end }}
{{ partial "extra-in-head.html" . }}
</head>
<body>
Expand Down
19 changes: 19 additions & 0 deletions layouts/partials/matomo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{ $siteId := cond (isset .Site.Params "matomositeid") .Site.Params.MatomoSiteId "1" }}
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
{{ if .Site.Params.MatomoDomainPrefixed }}_paq.push(["setDocumentTitle", document.domain + "/" + document.title]); {{ end }}
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//{{ .Site.Params.MatomoUrl }}/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '{{ $siteId }}']);
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);
})();
{{ if .Site.Params.MatomoEnableFallback }}
<noscript><p><img src="//{{.Site.Params.MatomoUrl}}/piwik.php?idsite={{ $siteId }}&amp;rec=1" style="border:0;" alt="" /></p></noscript>
{{ end }}
</script>
<!-- End Matomo Code -->

0 comments on commit 4da4f63

Please sign in to comment.