PocketStarter Docs

Analytics setup

Google Analytics Integration

PocketStarter comes with built-in Google Analytics support.

Quick Setup

1. Get your Google Analytics ID

  1. Go to Google Analytics
  2. Create a new property or use an existing one
  3. Copy your Measurement ID (starts with G-)

2. Add to your environment variables

Add this to your .env.local file:

NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX

Replace G-XXXXXXXXXX with your actual Google Analytics Measurement ID.

How it works

The analytics component works automatically:

  • ✅ It checks if a Google Analytics ID is set; if not, nothing is loaded.
  • ✅ It only runs in production (not during development).
  • ✅ It uses the Next.js Script component for optimal loading performance.