Skip to content

fix(analytics): ensure link click tracking works with ButtonLink#17595

Merged
wackerow merged 3 commits into
devfrom
fix/matomo-link-tracking
Feb 19, 2026
Merged

fix(analytics): ensure link click tracking works with ButtonLink#17595
wackerow merged 3 commits into
devfrom
fix/matomo-link-tracking

Conversation

@pettinarip
Copy link
Copy Markdown
Member

@pettinarip pettinarip commented Feb 19, 2026

Summary

  • Fix BaseLink to properly combine tracking onClick with passed onClick props
  • Simplify ButtonLink to pass customEventOptions to BaseLink instead of handling tracking separately
  • Include destination URL in event name for better analytics visibility

Problem

Previously, ButtonLink's onClick handler would override BaseLink's tracking, causing clicks to not be tracked when customEventOptions wasn't provided. This meant buttons like "Browse apps" on the homepage weren't being tracked in Matomo.

Solution

  1. Refactored BaseLink to extract onClick from props and create a combined handler that both tracks events AND calls any passed onClick
  2. Simplified ButtonLink to just pass customEventOptions and onClick to BaseLink rather than handling tracking itself
  3. Appended destination URL to event name: Clicked on internal link - /apps

Test plan

  • Deploy preview and verify click events are now tracked for ButtonLink components without explicit customEventOptions
  • Verify destination URL appears in event name in Matomo
  • Verify existing ButtonLinks with customEventOptions still track correctly

- Enable sendBeacon API in Matomo for reliable tracking during navigation
- Fix BaseLink to properly combine tracking onClick with passed onClick props
- Simplify ButtonLink to pass customEventOptions to BaseLink instead of
  handling tracking separately

Previously, ButtonLink's onClick handler would override BaseLink's tracking,
causing clicks to not be tracked when customEventOptions wasn't provided.
Now BaseLink handles all tracking with proper fallback to default event values.

See: https://matomo.org/faq/how-to/faq_33087/
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 19, 2026

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 7dd28e0
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/69972aecd2c1de00085432eb
😎 Deploy Preview https://deploy-preview-17595.ethereum.it
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 57 (🟢 up 2 from production)
Accessibility: 94 (no change from production)
Best Practices: 100 (no change from production)
SEO: 99 (🔴 down 1 from production)
PWA: 59 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Append the href to the event name so the destination URL is visible
in Matomo analytics: "Clicked on internal link - /apps"
@wackerow wackerow merged commit ded400a into dev Feb 19, 2026
7 checks passed
@wackerow wackerow deleted the fix/matomo-link-tracking branch February 19, 2026 16:16
@pettinarip pettinarip mentioned this pull request Feb 19, 2026
@pettinarip pettinarip mentioned this pull request Feb 27, 2026
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.

2 participants