Analytics
Overview
Learn how to use analytics in GoLiveKit.
GoLiveKit comes with a generic analytics module located at src/lib/analytics. It is designed to be provider-agnostic while currently having first-class support for Google Analytics.
Features
- Centralized Provider: An
AnalyticsProvidercomponent handling initialization logic. - Provider Agnostic: Easily extensible to support Plausible, PostHog, or other services.
- Custom Events: Utilities to track user interactions.
Supported Providers
Initialization
The analytics provider is automatically included in the root layout:
import { AnalyticsProvider } from '@/lib/analytics/analytics-provider';
export default function Layout({ children }) {
return (
<html>
<body>
{children}
<AnalyticsProvider />
</body>
</html>
);
}Adding a New Provider
To add a new analytics provider:
- Create a definition file in
src/lib/analytics/provider/. - Update
src/lib/analytics/analytics-provider.tsxto include the new provider component conditionally.