← back to guides
    integrationsbeginner2 minutes
    April 8, 2026

    How to Connect Claude Code to Google Analytics 4 via MCP (2026)

    Connect Claude Code to GA4 in under 2 minutes using Cogny's managed MCP server. OAuth handled for you — no GCP project, no service account, no self-hosting.

    TL;DR

    Cogny provides a managed, remote MCP server for Google Analytics 4 with built-in OAuth. Connect Claude Code to your GA4 properties without creating a GCP project, setting up service accounts, or enabling APIs manually.

    What you get:

    • Single federated MCP server at app.cogny.com/mcp — tools determined by connected accounts
    • Full GA4 reporting access — dimensions, metrics, segments
    • Real-time and historical data queries
    • Automatic token refresh and credential management
    • Works with Claude Code, Claude Desktop, Cursor, Windsurf, and any MCP client

    Time required: 2 minutes | Difficulty: Beginner | Prerequisites: Google Analytics 4 property with Viewer access or higher


    Why Use a Managed MCP Server?

    Connecting to GA4 programmatically typically requires:

    1. Creating a Google Cloud Platform project
    2. Enabling the Analytics Data API
    3. Setting up OAuth credentials or a service account
    4. Downloading key files and configuring authentication
    5. Hosting a server to run the MCP endpoint
    6. Managing token refresh and API quotas

    Cogny handles all of this. Sign in with Google, select your GA4 properties, and get a working MCP endpoint immediately.


    What Can Claude Do With GA4 Data?

    With the GA4 MCP server, Claude can:

    • Query any GA4 dimension and metric combination
    • Analyze user behavior, traffic sources, and conversions
    • Build cohort and funnel analyses
    • Compare date ranges and segments
    • Identify anomalies and trends
    • Cross-reference with Google Ads and Search Console data (when connected)

    Setup in 3 Steps

    Step 1: Create a Cogny Account

    Go to cogny.com, sign up, and create a warehouse.

    Step 2: Connect Google Analytics 4

    In your dashboard, find Google Analytics 4 under the channels list and click connect.

    Sign in with your Google account that has GA4 access. Select which properties to connect.

    Step 3: Add to Claude Code

    In your Cogny dashboard, generate an API key. Then add the Cogny MCP server to your Claude Code config. This is the same endpoint for all Cogny integrations — the tools available are determined by which accounts you've connected.

    {
      "mcpServers": {
        "cogny": {
          "type": "http",
          "url": "https://app.cogny.com/mcp",
          "headers": {
            "Authorization": "Bearer YOUR_API_KEY"
          }
        }
      }
    }
    

    Done. Claude now has read access to your GA4 data — and any other platforms you connect through Cogny.


    Example Prompts

    • "What are my top landing pages by conversion rate this month?"
    • "Show me traffic sources with the highest engagement rate"
    • "Compare this week's sessions to last week — break down by channel"
    • "Which pages have a bounce rate above 70% and more than 1,000 sessions?"
    • "Build a funnel analysis from page_view → add_to_cart → purchase"
    • "What's the user retention curve for visitors acquired via Google Ads?"

    Works With Any MCP Client

    • Claude Code (CLI) / Claude Desktop (Mac/Windows)
    • Cursor / Windsurf / Continue
    • Any custom client built with the MCP SDK

    Standard HTTP+SSE transport.


    Security

    • Read-only access — Claude cannot modify your GA4 configuration
    • OAuth tokens encrypted in Supabase Vault
    • Automatic token refresh before expiry
    • Signed URLs with HMAC-SHA256 (5-minute expiry)
    • Revoke access anytime from Cogny or Google account settings

    Compared to Self-Hosted

    FeatureCogny ManagedSelf-Hosted
    Setup time2 minutes30+ minutes
    GCP projectNot neededRequired
    Service accountNot neededRequired
    API enablementAutomaticManual
    Token refreshAutomaticYou build
    Server hostingManagedYou host

    Common Questions

    Q: Do I need a Google Cloud project? No. Cogny's managed server handles API access through its own GCP configuration.

    Q: Can I query real-time data? Yes. The GA4 MCP server supports both real-time and historical data queries.

    Q: Does this work with GA4 BigQuery export? The GA4 MCP server queries the Analytics Data API directly. For BigQuery-exported GA4 data, use Cogny's BigQuery integration separately.

    Q: Can I access multiple GA4 properties? Yes. Connect all properties through Cogny — accessible via one MCP endpoint.


    Next Steps


    About Cogny MCP Servers

    Cogny provides managed, remote MCP servers for 12+ marketing and business platforms with built-in OAuth, token management, and enterprise-grade security.

    Last Updated: April 2026

    get started

    Try Cogny free

    Connect your marketing platforms to Claude Code in under 2 minutes. No credit card required.