Skip to main content

At a glance

Credentials

Set these per environment. See Connect an integration. With a managed OAuth app, Connect works without these variables; set them to use your own OAuth app instead.
VariableRequiredDescription
GOOGLE_CLIENT_IDYesGoogle OAuth Client ID Docs.
GOOGLE_CLIENT_SECRETYesGoogle OAuth Client Secret Docs.

Setup

  1. Create or reuse a Google Cloud project: Go to https://console.cloud.google.com and select or create the project that holds your OAuth credentials.
  2. Enable the Analytics APIs: Enable both the Google Analytics Data API and the Google Analytics Admin API in the API Library.
  3. Configure OAuth credentials: Under APIs & Services → Credentials, create (or reuse) an OAuth 2.0 Client ID of type Web application and add your callback URL (e.g. https://your-app.example.com/api/auth/google-analytics/callback) to the authorized redirect URIs.
  4. Set environment variables: Add GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET to your .env. These are shared with the other Google connectors (Calendar, Gmail, Drive, Sheets).
  5. Verify access: Connect your Google account, run List Account Summaries to find a property ID, then run a report with metrics [{“name”:“activeUsers”}] and dateRanges [{“startDate”:“7daysAgo”,“endDate”:“today”}].
  • This connector is read-only (analytics.readonly scope) and targets GA4 properties; Universal Analytics is sunset
  • Property IDs are numeric (e.g. 123456789) - not the G-XXXX measurement ID
Provider API reference: https://developers.google.com/analytics/devguides/reporting/data/v1

Tools

ToolAccessDescription
List Account SummariesReadList GA4 accounts and their properties accessible to the connected user (use this to find property IDs)
Run ReportReadRun a GA4 report for a property over one or more date ranges
Run Realtime ReportReadRun a GA4 realtime report showing activity from the last 30 minutes
Get Report MetadataReadList the dimensions and metrics available for a GA4 property (use before building reports)

Example prompts

  • Show active users and sessions for my Google Analytics property over the last 7 days, broken down by country.
  • Show the number of active users on my site right now using Google Analytics realtime data.