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:
Console
Learn how to use the console for tracking events.
Google Analytics
Learn how to use Google Analytics for tracking events.
PostHog
Learn how to use PostHog for tracking events.
Umami
Learn how to use Umami for tracking events.
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' });
};