General
Analytics

Overview

Learn how to use analytics in your applications.

Analytics help you see how people are using your app so you can make smarter decisions and build better features.

Providers

In the packages/analytics/provider folder you can find the configured provider. There are multiple providers available:

Usage

Page Views

Route changes are automatically tracked in the AnalyticsProvider (no additional code required).

User Identification

client-component.tsx
import { useAnalytics } from '@workspace/analytics/hooks/use-analytics';

const analytics = useAnalytics();

const onClick = () => {
  analytics.identify('anonymous'); // or user.id
};

Event Tracking

client-component.tsx
import { useAnalytics } from '@workspace/analytics/hooks/use-analytics';

const analytics = useAnalytics();

const onClick = () => {
  analytics.trackEvent('buttonClicked', { button: 'addContact' });
};

Combination

client-component.tsx
import { useAnalytics } from '@workspace/analytics/hooks/use-analytics';

const analytics = useAnalytics();

const onClick = () => {
  analytics.identify('anonymous'); // or user.id
  analytics.trackEvent('buttonClicked', { button: 'addContact' });
};