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

# Google Analytics (GA4)

> 7 production-ready jobs — demographic personas, interest-based content strategy, funnel focus groups, landing page refresh, real-time spike response, channel-persona mapping, and device-aware creative recommendations

Google Analytics 4 holds your audience truth — who visits, where they come from, what they do, and where they drop off. These seven jobs pull that data through Mavera's surfaces (Custom Personas, Mave Agent, Focus Groups, Generate) so your personas, content, and creative are grounded in real behavioral data instead of assumptions.

```mermaid theme={"dark"}
flowchart TD
    subgraph data["GA4 Data"]
        demographics["Demographics"]
        interests["Interests"]
        funnels["Funnels"]
        landingPages["Landing Pages"]
        realtime["Real-time"]
        channels["Channels"]
        devices["Devices"]
    end
    subgraph surfaces["Mavera Surfaces"]
        personas["Custom Personas"]
        mave["Mave Agent"]
        focusGroups["Focus Groups"]
        generate["Generate"]
    end
    subgraph outputs["Outputs"]
        audiencePersonas["Audience Personas"]
        contentStrategy["Content Strategy"]
        funnelDiagnosis["Funnel Diagnosis"]
        pageRefresh["Page Refresh"]
        spikeResponse["Spike Response"]
        channelPersonas["Channel Personas"]
        formatRecs["Format Recs"]
    end
    demographics --> personas
    interests --> mave
    funnels --> focusGroups
    landingPages --> generate
    realtime --> mave
    channels --> personas
    devices --> mave
    personas --> audiencePersonas
    personas --> channelPersonas
    mave --> contentStrategy
    mave --> spikeResponse
    mave --> formatRecs
    focusGroups --> funnelDiagnosis
    generate --> pageRefresh
```

***

## API Reference Card

| Detail            | Value                                                                          |
| ----------------- | ------------------------------------------------------------------------------ |
| **Base URL**      | `https://analyticsdata.googleapis.com/v1beta`                                  |
| **Auth**          | OAuth 2.0 via service account (`GOOGLE_APPLICATION_CREDENTIALS` JSON key file) |
| **Rate limits**   | 50,000 requests/project/day; 10 concurrent requests/property                   |
| **Python client** | `google-analytics-data` — official GA4 Data API client                         |
| **Mavera base**   | `https://app.mavera.io/api/v1`                                                 |
| **Mavera auth**   | `Authorization: Bearer mvra_live_...`                                          |

<Info>
  All examples use three environment variables: `GOOGLE_APPLICATION_CREDENTIALS` (path to service account JSON), `GA4_PROPERTY_ID` (numeric property ID, e.g. `123456789`), and `MAVERA_API_KEY`. Python examples use the `google-analytics-data` client library; JavaScript examples use the REST API directly with a service account access token.
</Info>

***

## Prerequisites

<Steps>
  <Step title="GA4 property with data">You need an active GA4 property with at least 30 days of traffic. Find the property ID in GA4 → Admin → Property Settings.</Step>
  <Step title="Service account with GA4 access">Create a [service account](https://console.cloud.google.com/iam-admin/serviceaccounts) in Google Cloud, download the JSON key, then add the service account email as a **Viewer** in GA4 → Admin → Property Access Management.</Step>
  <Step title="Enable the Analytics Data API">In Google Cloud Console, navigate to APIs & Services → Enable the [Google Analytics Data API](https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com).</Step>

  <Step title="Install dependencies">
    ```bash theme={"dark"}
    pip install google-analytics-data requests
    ```
  </Step>

  <Step title="Environment variables">
    ```bash theme={"dark"}
    export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
    export GA4_PROPERTY_ID="123456789"
    export MAVERA_API_KEY="mvra_live_xxxxx"
    ```
  </Step>
</Steps>

***

## Jobs

| # | Job                                                                                                    | GA4 Data                                             | Mavera Surface  | Output                                    |
| - | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------- | --------------- | ----------------------------------------- |
| 1 | [Audience Demographics → Persona Creation](/integrations/ga4/audience-demographics-personas)           | RunReport: age, gender, country, device, conversions | Custom Personas | High-value intersection personas          |
| 2 | [Interest Category → Content Strategy](/integrations/ga4/interest-content-strategy)                    | Interests dimension report                           | Mave Agent      | Content plan bridging product + interests |
| 3 | [Conversion Path → Focus Group Validation](/integrations/ga4/conversion-focus-group)                   | Funnel report with step drop-off                     | Focus Groups    | Persona feedback on drop-off points       |
| 4 | [Landing Page Performance → Content Refresh](/integrations/ga4/landing-page-refresh)                   | Top landing pages with bounce + engagement           | Generate        | Audience-specific copy rewrites           |
| 5 | [Real-Time Audience → Trending Response](/integrations/ga4/realtime-trending-response)                 | Real-time active users by page/source                | Mave Agent      | Spike diagnosis + response plan           |
| 6 | [Acquisition Channel × Persona Mapping](/integrations/ga4/channel-persona-mapping)                     | Session source/medium × demographics                 | Custom Personas | Channel-demographic persona map           |
| 7 | [Device Behavior → Creative Format Recommendations](/integrations/ga4/device-creative-recommendations) | Device category, resolution, engagement              | Mave Agent      | Format adjustments per device             |

***

## Rate Limits & Production Notes

| GA4 API Endpoint  | Limit                                  | Strategy                                             |
| ----------------- | -------------------------------------- | ---------------------------------------------------- |
| RunReport         | 10 concurrent per property; 50,000/day | Queue reports; use date range caching                |
| RunRealtimeReport | Same quota pool                        | Poll at max 1/minute for dashboards                  |
| RunFunnelReport   | Same quota pool                        | Cache results; funnels rarely need real-time refresh |

<Warning>
  The GA4 Data API enforces **10 concurrent requests per property**. If you run jobs 1–7 in parallel, you'll exceed this limit. Run sequentially or batch with 300ms delays. Retry on `429` with exponential backoff.
</Warning>

**Production checklist:**

| Concern                      | Recommendation                                                                                                                                                        |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Service account key rotation | Rotate keys every 90 days via Google Cloud IAM. Store in a secrets manager, never in code.                                                                            |
| Date ranges                  | Always use relative ranges (`30daysAgo`) for scheduled jobs. Absolute dates risk stale data.                                                                          |
| Data freshness               | Standard GA4 properties have 24–48h processing delay for non-real-time reports. Real-time reports cover the last 30 minutes only.                                     |
| Sampling                     | Reports over 10M events may be sampled. Use shorter date ranges or the [GA4 BigQuery export](https://support.google.com/analytics/answer/9358801) for unsampled data. |
| Mavera credits               | Monitor at [Dashboard](https://app.mavera.io/settings/usage). Mave chat calls consume credits proportional to prompt length.                                          |
| Thresholding                 | GA4 redacts rows with small user counts to protect privacy. If critical segments are missing, reduce dimension cardinality or extend date ranges.                     |

***

## What's Next

<CardGroup cols={2}>
  <Card title="All Integrations" icon="plug" href="/integrations">
    50+ API integrations with full code
  </Card>

  <Card title="GA4 Data API Docs" icon="chart-line" href="https://developers.google.com/analytics/devguides/reporting/data/v1">
    Official GA4 Data API reference
  </Card>

  <Card title="Personas API" icon="users" href="/api-reference/personas">
    Full reference for POST /api/v1/personas
  </Card>

  <Card title="Focus Groups API" icon="comments" href="/api-reference/focus-groups">
    Full reference for POST /api/v1/focus-groups
  </Card>

  <Card title="Mave Agent" icon="brain" href="/api-reference/mave">
    Full reference for POST /api/v1/mave/chat
  </Card>

  <Card title="Generate API" icon="wand-magic-sparkles" href="/api-reference/generations">
    Full reference for POST /api/v1/generations
  </Card>
</CardGroup>
