ShiftFast Docs
Integrations

Analytics

Event tracking and user behavior — the kit doesn't ship this by default.

The kit doesn't ship product analytics — no page-view or event tracking wired in. That's a separate concern from Observability: Sentry covers errors and session replay, not user behavior.

All three options below plug in the same way: a script/provider added once in src/app/[locale]/layout.tsx, so every page gets tracking without touching individual routes. Any env var they need is client-safe, so it takes the NEXT_PUBLIC_ prefix — see Adding your own variable. For custom events beyond page views, the two common call sites are a plan button click (src/components/shared/plan-action-button.tsx) and a contact form submit (contact-section.tsx).

PostHog

Full-featured: events, funnels, session replay, feature flags.

Install the SDK and add NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST to .env:

pnpm add posthog-js

Create src/lib/analytics/posthog-provider.tsx, a client component that calls posthog.init() once and wraps children in PostHogProvider (from posthog-js/react):

'use client'

import { PostHogProvider as PHProvider } from 'posthog-js/react'
import posthog from 'posthog-js'
import { useEffect } from 'react'

export function PostHogProvider({ children }: { children: React.ReactNode }) {
  useEffect(() => {
    posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
      api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
      capture_pageview: true,
    })
  }, [])

  return <PHProvider client={posthog}>{children}</PHProvider>
}

Wrap the app with it in src/app/[locale]/layout.tsx, alongside the existing ClerkProvider/ThemeProvider nesting, then track custom events with the usePostHog() hook:

const posthog = usePostHog()
posthog.capture('checkout_started', { plan: planId })

Plausible

Lightweight, privacy-first, cookie-free page-view tracking.

Add NEXT_PUBLIC_PLAUSIBLE_DOMAIN to .env — the domain your site is registered under in Plausible.

Render the tracking script in src/app/[locale]/layout.tsx, inside <head> via Next's <Script> component so it doesn't block rendering:

import Script from 'next/script'

;<Script
  defer
  data-domain={process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN}
  src="https://plausible.io/js/script.js"
/>

Page views are tracked automatically from here — no provider or client wrapper needed.

Track custom events by calling the global window.plausible function:

declare global {
  interface Window {
    plausible?: (
      event: string,
      options?: { props: Record<string, unknown> }
    ) => void
  }
}

window.plausible?.('checkout_started', { props: { plan: planId } })

Vercel Analytics

Zero-config page views if you're already deploying to Vercel.

Vercel Analytics only collects data for deployments hosted on Vercel — see Deploying to Vercel.

Install the package — no environment variables needed, it reads the deployment context automatically:

pnpm add @vercel/analytics

Render <Analytics /> once in src/app/[locale]/layout.tsx, alongside the existing <Toaster>/<NextTopLoader> siblings inside <body>. Page views are tracked automatically from here:

import { Analytics } from '@vercel/analytics/next'

;<Analytics />

Track custom events with track():

import { track } from '@vercel/analytics'

track('checkout_started', { plan: planId })

Reach for Plausible if you just want page views without a cookie banner. Reach for PostHog if you also want event funnels, feature flags, or session replay in the same tool. Vercel Analytics is the least effort if you're already deploying there, but is Vercel-only.

On this page