Remix web analytics installation
This guide is for Remix v2. For Remix v3, see our React Router v7 docs. Install the PostHog JavaScript library using your package manager: Add Create a Import the Click around and view a couple pages to generate some events. PostHog automatically captures pageviews, clicks, and other interactions for you. If you'd like, you can also manually capture custom events: After installing PostHog and ensuring autocapture is enabled, head to your web analytics dashboard to see your data. And then check out our getting started guide. PostHog tip: Web analytics works with anonymous events. This means if you are primarily using PostHog for web analytics, it can be significantly cheaper for you.Install the package
RequiredConfigure Vite
Requiredposthog-js and posthog-js/react to ssr.noExternal in your vite.config.ts so they get bundled for SSR:Create a provider
Requiredprovider.tsx file in the app folder. Set up the PostHog provider to initialize after hydration:Wrap your app
RequiredPHProvider component in your app/root.tsx file and use it to wrap your app:Send events
Next steps
Recommended