Add support for Matomo (formerly Piwik) (#508)

Co-authored-by: Luiz F. A. de Prá <luizdepra@users.noreply.github.com>
This commit is contained in:
Alphonse Mariya
2021-01-22 17:39:34 +01:00
committed by GitHub
parent edea1118eb
commit 1d4b612a44
5 changed files with 57 additions and 16 deletions

View File

@@ -91,3 +91,4 @@
- [Felix](https://github.com/lazyyz) - [Felix](https://github.com/lazyyz)
- [Peter Duchnovsky](https://pduchnovsky.com) - [Peter Duchnovsky](https://pduchnovsky.com)
- [Alex Miranda](https://ammiranda.com) - [Alex Miranda](https://ammiranda.com)
- [Alphonse Mariya](https://github.com/alfunx)

View File

@@ -80,24 +80,37 @@ disqusShortname = "yourdiscussshortname"
[params.cloudflare] [params.cloudflare]
token = "token" token = "token"
# If you want to use Matomo(https://matomo.org) for analytics, add this section
[params.matomo]
# Default value is "1", overwrite this if you are cloud-hosting
siteID = "ABCDE"
# For cloud-hosting, use provided URL, e.g. example.matomo.cloud
serverURL = "analytics.example.com"
# If you want to implement a Content-Security-Policy, add this section # If you want to implement a Content-Security-Policy, add this section
[params.csp] [params.csp]
childsrc = ["'self'"] childsrc = ["'self'"]
fontsrc=["'self'", fontsrc = [
"https://fonts.gstatic.com", "'self'",
"https://cdn.jsdelivr.net/"] "https://fonts.gstatic.com",
formaction = ["'self'"] "https://cdn.jsdelivr.net/"
framesrc = ["'self'"] ]
imgsrc = ["'self'"] formaction = ["'self'"]
objectsrc = ["'none'"] framesrc = ["'self'"]
stylesrc = ["'self'", imgsrc = ["'self'"]
"'unsafe-inline'", objectsrc = ["'none'"]
"https://fonts.googleapis.com/", stylesrc = [
"https://cdn.jsdelivr.net/"] "'self'",
scriptsrc = ["'self'", "'unsafe-inline'",
"'unsafe-inline'", "https://fonts.googleapis.com/",
"https://www.google-analytics.com"] "https://cdn.jsdelivr.net/"
prefetchsrc = ["'self'"] ]
scriptsrc = [
"'self'",
"'unsafe-inline'",
"https://www.google-analytics.com"
]
prefetchsrc = ["'self'"]
[taxonomies] [taxonomies]
category = "categories" category = "categories"

View File

@@ -145,6 +145,10 @@
{{ if and .Site.Params.cloudflare .Site.Params.cloudflare.token }} {{ if and .Site.Params.cloudflare .Site.Params.cloudflare.token }}
{{- partial "analytics/cloudflare" . -}} {{- partial "analytics/cloudflare" . -}}
{{ end }} {{ end }}
{{ if and .Site.Params.matomo .Site.Params.matomo.serverURL }}
{{- partial "analytics/matomo" . -}}
{{ end }}
</body> </body>
</html> </html>

View File

@@ -0,0 +1,13 @@
<script type="application/javascript">
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://{{ $.Site.Params.matomo.serverURL }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{{ $.Site.Params.matomo.siteID | default "1" }}']);
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>

View File

@@ -139,6 +139,16 @@ models:
- type: string - type: string
name: token name: token
label: token for Cloudflare Web Analytics label: token for Cloudflare Web Analytics
- type: object
name: matomo
label: Matomo (optional)
fields:
- type: string
name: siteID
label: Site ID for Matomo
- type: string
name: serverURL
label: URL for Matomo
- type: object - type: object
name: languages name: languages
fields: fields: