-
Notifications
You must be signed in to change notification settings - Fork 155
Support for Matomo tracking #55
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
base: master
Are you sure you want to change the base?
Changes from all commits
eb2ac1d
38edc3f
ce60273
ef06f92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| {{ $siteId := cond (isset .Site.Params "matomositeid") .Site.Params.MatomoSiteId "1" }} | ||
| {{ $clientSideDNT := cond (isset .Site.Params "matomoclientsidednt") .Site.Params.MatomoClientSideDNT true }} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. Knowing this, would you still add it yourself? :) |
||
| <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 }} | ||
| {{ if $clientSideDNT}} _paq.push(["setDoNotTrack", true]); {{ 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); | ||
| })(); | ||
| </script> | ||
| {{ if .Site.Params.MatomoEnableFallback }} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this fallback ?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 So, a better suggestion for the name?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally know a few ¯\_(ツ)_/¯ |
||
| <noscript><p><img src="//{{.Site.Params.MatomoUrl}}/piwik.php?idsite={{ $siteId }}&rec=1" style="border:0;" alt="" /></p></noscript> | ||
| {{ end }} | ||
| <!-- End Matomo Code --> | ||
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
bodyjust after thegoogle_analyticsin theheader.html? Also lets do theifcheck 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 👍