Add PostHog analytics — full event tracking across all pages
Tracks pageviews, hero/CTA clicks, product teaser clicks, app card and detail views, newsletter signups, nav interactions, and footer link clicks with structured properties for PostHog dashboards. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
components/PostHogProvider.tsx
Normal file
21
components/PostHogProvider.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import { usePathname } from 'next/navigation'
|
||||
import { initPostHog, posthog } from '@/lib/posthog'
|
||||
|
||||
export default function PostHogProvider({ children }: { children: React.ReactNode }) {
|
||||
useEffect(() => {
|
||||
initPostHog()
|
||||
}, [])
|
||||
|
||||
const pathname = usePathname()
|
||||
|
||||
useEffect(() => {
|
||||
if (posthog.__loaded) {
|
||||
posthog.capture('$pageview', { $current_url: window.location.href })
|
||||
}
|
||||
}, [pathname])
|
||||
|
||||
return <>{children}</>
|
||||
}
|
||||
Reference in New Issue
Block a user