Skip to main content

Why track button clicks?

Page views tell you where users go. Button clicks tell you what they do. Knowing which buttons your users click most — and which ones they ignore — helps you understand what matters to your users and what doesn’t. Examples of things to learn from button tracking:
  • Which call-to-action button converts better — “Start Free Trial” or “Try Now”?
  • Are users clicking the pricing page button or ignoring it?
  • How many users click “Upgrade” but never complete the purchase?

The basic pattern

To track a button, you need to add an onClick action to it. If your button already has an action, just add track() inside it. If it doesn’t, add a new action. Before:
components/PricingButton.jsx
After (tracking added):
components/PricingButton.jsx
Here is exactly how it looks in different frameworks:
components/Hero.jsx

Adding context with properties

Always add a location property so you know where in your app the button was clicked. Same button might exist in multiple places:
utils/analytics.js
This lets you compare which placement drives the most signups.
Links work the same way as buttons:
components/Navbar.jsx

Real-world example — CTA buttons on a landing page



Naming your events

Use this pattern: [noun]_[action]