Skip to content

Commit

Permalink
Add matomo event tracking (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zishan-7 authored Oct 9, 2024
1 parent c4ee77a commit f0467aa
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
7 changes: 3 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,18 @@
<script src="/src/main.jsx" type="module"></script>
<script type="text/javascript">
var _paq = (window._paq = window._paq || []);
_paq.push(['disableCookies']);
_paq.push(['setDocumentTitle', document.domain + '/' + document.title]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = '//nethermind.matomo.cloud/';
var u = 'https://nethermind.matomo.cloud/';
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '4']);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.src = u + 'matomo.js';
g.src = 'https://cdn.matomo.cloud/nethermind.matomo.cloud/matomo.js';
s.parentNode.insertBefore(g, s);
})();
</script>
Expand Down
6 changes: 6 additions & 0 deletions src/onboarding/Register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export default function Register() {
const navigate = useNavigate();

const handleSignUp = async data => {
window._paq.push([
'trackEvent',
'Sign Up',
'Sign Up button clicked',
data.email
]);
if (!isClerkLoaded) return;

try {
Expand Down
44 changes: 38 additions & 6 deletions src/shared/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ export default function Footer() {
<ul className="flex flex-col gap-2 md:flex-row md:gap-8">
{mainLinks.map((item, i) => (
<li className="flex h-6 items-center" key={`footer-main-${i}`}>
<Link className="text-xs text-foreground-2" href={item.href}>
<Link
className="text-xs text-foreground-2"
href={item.href}
onPress={() =>
item.matomoEventData &&
window._paq.push(['trackEvent', ...item.matomoEventData])
}
>
{item.title}
<span className="material-symbols-outlined hidden lg:inline">
arrow_right_alt
Expand All @@ -33,6 +40,10 @@ export default function Footer() {
<Link
className={`${item.className} text-xs text-foreground-2`}
href={item.href}
onPress={() =>
item.matomoEventData &&
window._paq.push(['trackEvent', ...item.matomoEventData])
}
>
<span className="icon"></span>
{item.title}
Expand All @@ -57,31 +68,52 @@ export default function Footer() {
const mainLinks = [
{
title: 'Audit smart contract',
href: 'https://www.nethermind.io/smart-contract-audits'
href: 'https://www.nethermind.io/smart-contract-audits',
matomoEventData: [
'Contact',
'Audit smart contract',
'https://www.nethermind.io/smart-contract-audits'
]
},
{
title: 'Nethermind operator',
href: 'https://app.eigenlayer.xyz/operator/0x110af279aaffb0d182697d7fc87653838aa5945e'
href: 'https://app.eigenlayer.xyz/operator/0x110af279aaffb0d182697d7fc87653838aa5945e',
matomoEventData: [
'Contact',
'Nethermind operator',
'https://app.eigenlayer.xyz/operator/0x110af279aaffb0d182697d7fc87653838aa5945e'
]
},
{
title: 'Legal',
href: 'https://nethermind.io/legal'
},
{
title: 'API Docs',
href: `${import.meta.env.VITE_API_BASE_URL}/swagger`
href: `${import.meta.env.VITE_API_BASE_URL}/swagger`,
matomoEventData: [
'Contact',
'API Docs',
`${import.meta.env.VITE_API_BASE_URL}/swagger`
]
}
];

const socialLinks = [
{
title: 'Follow us',
className: 'footer-x',
href: 'https://x.com/NethermindEth'
href: 'https://x.com/NethermindEth',
matomoEventData: ['Social Media', 'X', 'https://x.com/NethermindEth']
},
{
title: 'Join us',
className: 'footer-discord',
href: 'https://discord.com/invite/PaCMRFdvWT'
href: 'https://discord.com/invite/PaCMRFdvWT',
matomoEventData: [
'Social Media',
'Discord',
'https://discord.com/invite/PaCMRFdvWT'
]
}
];

0 comments on commit f0467aa

Please sign in to comment.