-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Matomo tracking #55
base: master
Are you sure you want to change the base?
Conversation
c56687c
to
4da4f63
Compare
64635c5
to
3fe0c07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. Lets do it more like the google analytics internal template, maybe we can then merge it upstream as a internal hugo template.
@@ -17,6 +17,7 @@ | |||
{{ if .RSSLink }} | |||
<link href="{{ .RSSLink }}" rel="alternate" type="application/rss+xml"> | |||
{{ end }} | |||
{{ if .Site.Params.MatomoUrl }}{{ partial "matomo.html" . }}{{ end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this at the top of body
just after the google_analytics
in the header.html
? Also lets do the if
check inside the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do 👍
@@ -0,0 +1,21 @@ | |||
{{ $siteId := cond (isset .Site.Params "matomositeid") .Site.Params.MatomoSiteId "1" }} | |||
{{ $clientSideDNT := cond (isset .Site.Params "matomoclientsidednt") .Site.Params.MatomoClientSideDNT true }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets do the DNT check just like in the google analytics template https://raw.githubusercontent.com/gohugoio/hugo/master/tpl/tplimpl/embedded/templates/google_analytics.html and introduce a param like matomoRespectDoNotTrack
. If that option is true
it should not even include the tracking snippet, just like in the google analytics. Also be sure to check for user DNT setting in browser var dnt = (navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack);
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I see where you're getting at.
However, this specific flag serves to include a JS snippet that prevents the request from being sent at all if the user's DNT setting is turned on.
So the check you're referring to is in the javascript that is included. https://github.com/matomo-org/matomo/blob/6f5b85b6f7d2195362ae03480120f4cef5ec4dc1/js/piwik.js#L6564
Knowing this, would you still add it yourself? :)
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); | ||
})(); | ||
</script> | ||
{{ if .Site.Params.MatomoEnableFallback }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this fallback ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a Matomo specific option, not really a fallback for the option on its own, but if the user has JS disabled this 'fallback' provides a way of tracking it using an img
element.
So, a better suggestion for the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do people still disable javascript ? I mean most of today pages are JS heavy :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally know a few ¯\_(ツ)_/¯
This PR adds the following options to
Params
:1
)P.S. This is my first encounter with Hugo's templating, if something can be done better, please suggest / correct 👍