FeaturesAnalytics
PreviousNext

Google Analytics

Configure Google Analytics provider environment variables.

What It Does

Enables GA4 event and page-view tracking through the @kit/google-analytics provider.

When To Use

  • You selected google in createAnalyticsManager([...]).

Prerequisites

  • A GA4 property and Measurement ID.

How To Use

Find your GA_MEASUREMENT_ID first:

Create a GA4 property and open Admin.

Under Data collection and modification, open Data Streams.

Select your Web stream.

Copy the GA_MEASUREMENT_ID shown in the stream details.

Google Analytics Measurement ID location

Google Analytics Measurement ID location

Set client env vars:

NEXT_PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX
NEXT_PUBLIC_GA_DISABLE_LOCALHOST_TRACKING=true
NEXT_PUBLIC_GA_DISABLE_PAGE_VIEWS_TRACKING=false

These variables are validated in kit/analytics/google-analytics/envs.ts.

MCP Context

capability: google_analytics_provider
entrypoints:
  - kit/analytics/google-analytics/envs.ts
inputs:
  - NEXT_PUBLIC_GA_MEASUREMENT_ID
outputs:
  - ga_tracking_enabled
constraints:
  - measurement id must match GA4 property
side_effects:
  - client analytics traffic sent to Google Analytics

Agent Recipe

  1. Add GA env vars.
  2. Ensure provider list includes google.
  3. Verify data in GA real-time view.

Troubleshooting

  • No page views: check NEXT_PUBLIC_GA_DISABLE_PAGE_VIEWS_TRACKING.
  • Local spam: set NEXT_PUBLIC_GA_DISABLE_LOCALHOST_TRACKING=true.

How is this guide?

Last updated on 3/23/2026