-
Notifications
You must be signed in to change notification settings - Fork 9
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
Matomo Analytics (using localStorage) #947
Conversation
src/app/pages/HomePage/index.tsx
Outdated
@@ -180,6 +181,7 @@ export const HomePage: FC = () => { | |||
/> | |||
</Box> | |||
</ThemeByNetwork> | |||
<CookieConsent /> |
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.
Doesn't appear in subpages http://localhost:1234/mainnet/sapphire
})) | ||
|
||
return ( | ||
<Snackbar |
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.
Deployed to Cloudflare Pages
|
rebased, going to force push |
7740c8b
to
803b2b0
Compare
803b2b0
to
75775d2
Compare
// Generate snippet https://matomo.oasis.io/index.php?module=CoreAdminHome&action=trackingCodeGenerator&idSite=1&period=day&date=yesterday&updated=false | ||
// Snippet from https://developer.matomo.org/guides/tracking-javascript-guide#finding-the-piwik-tracking-code | ||
window._paq = window._paq || [] | ||
export const matomoDomain = 'https://matomo.oasis.io/' | ||
// https://matomo.org/faq/how-to/faq_23654/ | ||
window._paq.push(['setDomains', ['*.domain1.com', '*.domain2.com']]) | ||
window._paq.push(['enableCrossDomainLinking']) | ||
/* tracker methods like 'setCustomDimension' should be called before 'trackPageView' */ | ||
window._paq.push(['setCookieDomain', '*.example.org']) | ||
window._paq.push(['setDoNotTrack', true]) | ||
window._paq.push(['enableLinkTracking']) | ||
window._paq.push(['setTrackerUrl', `${matomoDomain}matomo.php`]) | ||
window._paq.push(['setSiteId', '3']) | ||
|
||
window._paq.push([ | ||
'setCustomRequestProcessing', | ||
(queryString: string) => { | ||
const params = new URLSearchParams(queryString) | ||
for (const name of ['action_name', 'url', 'urlref']) { | ||
const v = params.get(name) | ||
if (v) { | ||
params.set(name, redactURL(v)) | ||
} | ||
} | ||
|
||
return params.toString() | ||
}, | ||
]) |
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 would add this configuration to addMatomo
function. And only set those config on consent.
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.
reason? we need these right away so that any custom _paq.push(...) come in after things are configured, otherwise they won't get anonymized etc. if a user subsequently opts in
// Generate snippet https://matomo.oasis.io/index.php?module=CoreAdminHome&action=trackingCodeGenerator&idSite=1&period=day&date=yesterday&updated=false | ||
// Snippet from https://developer.matomo.org/guides/tracking-javascript-guide#finding-the-piwik-tracking-code | ||
window._paq = window._paq || [] | ||
export const matomoDomain = 'https://matomo.oasis.io/' |
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.
New issue: pontusx.
I would just enable/disable our analytics with .env.production (instead of generalizing everything in env: matomoDomain, setDomains, setCookieDomain, setSiteId, sha384-)
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.
what's .env.production?
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.
Adding a Cookie Banner visual component (without the tracking functionality)
Before:
After: