Connect Google Analytics 4

Google Analytics 4 is the default web analytics provider for most sites. Connecting it to VibesAnalytics lets your agent auto-discover your GA4 properties, map your canonical events to GA4's, and pull normalized web metrics — without you copy-pasting measurement IDs.

Before you start

  • A GA4 property with a web data stream for your site.
  • Your VibesAnalytics project already created (see Getting Started).

Connect

Have your agent call connect_provider with provider ga4 for your project. VibesAnalytics walks the OAuth flow and auto-discovers the properties and data streams available to your account — no manual ID lookup.

The OAuth grant is read-only (analytics.readonly) for pulling reports; the extra analytics.edit scope is only requested when you ask the agent to provision a brand-new property for you. Either way, you never paste a key — and you should not confuse the three GA4 credentials: the public Measurement ID (G-XXXXXXXXXX) that the gtag uses to send data, the Measurement Protocol API secret for optional server-side sending, and this Data API grant for reading data back. The numeric Property ID (properties/123…) the Data API reads from is not the same string as the G- Measurement ID.

What the contract gives you

After connecting, get_integration_contract includes the GA4 specifics:

  • The NEXT_PUBLIC_GA_MEASUREMENT_ID env var to inject.
  • The gtag/next/script setup (load with afterInteractive).
  • Route-change tracking for the App Router (fire a page_view on usePathname changes).
  • Event mappings: signup_completed → GA4 sign_up, purchase_completed → GA4 purchase (with value and currency).

Verify

Use GA4 DebugView to confirm events fire in real time, then call validate_tracking in VibesAnalytics to confirm the provider is connected and events are flowing. Remember that GA4's standard reports lag a few hours — DebugView is the fast feedback loop.

Data quality: when to trust the numbers

GA4 quietly degrades data in ways that are easy to miss. VibesAnalytics now reads GA4's response metadata on every pull and stamps it onto your metrics, so insights can flag reduced confidence instead of presenting estimates as fact:

  • Sampling — for large date ranges GA4 estimates from a subset of events. We flag it.
  • (other) rows — high-cardinality breakdowns get collapsed into an (other) bucket, so dimension totals undercount. We flag it.
  • Thresholding — on low-traffic properties (especially with Google Signals on), GA4 withholds small-count rows. The Data API gives no signal that this happened, so we surface it as a standing caveat rather than a per-row flag.

We also record the attribution model (data-driven by default) and reporting identity in effect, because they change what the numbers mean. When any of these apply, you'll see a data_quality_warning insight — treat the affected metrics as directional, not exact.

A note on resilience

GA4 is a client-side pixel: ad blockers and consent tooling will drop some events. Pair it with owned events so your core funnel stays accurate even when the pixel is blocked — see Owned Events vs Provider Events.