> ## Documentation Index
> Fetch the complete documentation index at: https://veryfront.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Analytics

> Run GA4 reports and realtime reports, and discover Analytics accounts and properties

## At a glance

* **Availability**: Experimental ([how to enable](/cloud/integrations)).
* **Auth**: OAuth 2.0.
* **Connection**: A user authorizes the connection in the provider's consent screen.
* **Scopes**: `https://www.googleapis.com/auth/analytics.readonly`.
* **Docs**: [https://developers.google.com/analytics/devguides/reporting/data/v1](https://developers.google.com/analytics/devguides/reporting/data/v1)

## Credentials

Set these per environment. See [Connect an integration](/cloud/integrations).

With a managed OAuth app, Connect works without these variables; set them to use your own OAuth app instead.

| Variable               | Required | Description                                                                           |
| ---------------------- | -------- | ------------------------------------------------------------------------------------- |
| `GOOGLE_CLIENT_ID`     | Yes      | Google OAuth Client ID [Docs](https://console.cloud.google.com/apis/credentials).     |
| `GOOGLE_CLIENT_SECRET` | Yes      | Google OAuth Client Secret [Docs](https://console.cloud.google.com/apis/credentials). |

## Setup

1. **Create or reuse a Google Cloud project**: Go to [https://console.cloud.google.com](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](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](https://developers.google.com/analytics/devguides/reporting/data/v1)

## Tools

| Tool                   | Access | Description                                                                                             |
| ---------------------- | ------ | ------------------------------------------------------------------------------------------------------- |
| List Account Summaries | Read   | List GA4 accounts and their properties accessible to the connected user (use this to find property IDs) |
| Run Report             | Read   | Run a GA4 report for a property over one or more date ranges                                            |
| Run Realtime Report    | Read   | Run a GA4 realtime report showing activity from the last 30 minutes                                     |
| Get Report Metadata    | Read   | List 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.
