Skip to content
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

Closed
wants to merge 26 commits into from

Conversation

kaja-osojnik
Copy link
Collaborator

Adding a Cookie Banner visual component (without the tracking functionality)
Before:
Screen Shot 2023-10-16 at 12 00 02

After:
Screen Shot 2023-10-16 at 11 57 30

@@ -180,6 +181,7 @@ export const HomePage: FC = () => {
/>
</Box>
</ThemeByNetwork>
<CookieConsent />
Copy link
Member

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
localhost_1234_mainnet_emerald_token_0x903d32d7307b4b3FC4bc9a510CA658C91A346A67

}))

return (
<Snackbar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe snackbar isn't optimal. Mobile users can't ignore and scroll past it

localhost_1234_mainnet_emerald_token_0x903d32d7307b4b3FC4bc9a510CA658C91A346A67(extension360)

src/app/components/CookieConsent/index.tsx Outdated Show resolved Hide resolved
yarn.lock Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Oct 17, 2023

Deployed to Cloudflare Pages

Latest commit: 5582c08e5cb6c89049c9499245dcc26c64458c34
Status:✅ Deploy successful!
Preview URL: https://3ecb6ff5.oasis-explorer.pages.dev

@pro-wh
Copy link
Contributor

pro-wh commented Feb 1, 2024

rebased, going to force push

@pro-wh pro-wh force-pushed the kaja/matomo-tracking-implementation branch from 7740c8b to 803b2b0 Compare February 1, 2024 00:39
@pro-wh pro-wh force-pushed the kaja/matomo-tracking-implementation branch from 803b2b0 to 75775d2 Compare February 1, 2024 00:39
Comment on lines +9 to +36
// 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()
},
])
Copy link
Collaborator

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.

Copy link
Contributor

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/'
Copy link
Member

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-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's .env.production?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukaw3d lukaw3d changed the title Kaja/matomo tracking implementation Matomo Analytics (using localStorage) Feb 23, 2024
@lukaw3d
Copy link
Member

lukaw3d commented Mar 15, 2024

I rebased this on top of #1294 into a separate PR: #1332 (didn't want to force push here and delete all history)

@lukaw3d lukaw3d closed this Mar 15, 2024
@lukaw3d lukaw3d deleted the kaja/matomo-tracking-implementation branch March 15, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants