useTrackEvent()

Use the useTrackEvent() hook to track an event

Track a custom event

The useTrackEvent() hook is used to track a custom event. You can track any event that you want to track in your application.

pages/dashboard.tsx
import React from 'react';
import { useTrackEvent } from '@journium/react';

function SignupButton() {
  const trackEvent = useTrackEvent();

  const handleSignup = () => {
    trackEvent('user_signup', {
      method: 'email',
      source: 'landing_page',
      plan: 'free'
    });
  };

  return <button onClick={handleSignup}>Sign Up</button>;
}

Last updated on

On this page