SEO + AI Lab

Google Analytics 4 MCP: Query GA4 from Claude Code | 2026 Guide

Claudio Novaglio
7 min read
Google Analytics 4 MCP per Claude Code — analisi comportamento utente

Google Analytics 4 MCP server: connect GA4 data to Claude Code with 7 specialized tools, zero configuration, direct query execution.

GA4 data lives in your workspace. But getting insights requires bouncing between Google Analytics UI, exporting reports, parsing CSV, and mapping segments across multiple events. What if you could query GA4 directly from Claude Code with natural language? "Show me traffic by device for the last 30 days, filtered by organic only" → instant structured data.

This article walks through the GA4 MCP server, the 7 available tools, how to set it up (20-30 minutes), and three workflows where it transforms GA4 from a reporting tool into an analysis workbench for SEO strategy.

What is the GA4 MCP server

The Google Analytics 4 MCP server is a bridge between Claude Code and your GA4 workspace. MCP stands for Model Context Protocol—a standard for connecting LLMs to external data sources and tools. Once configured, you can write prompts in Claude Code that execute GA4 queries natively, no API key copy-paste, no manual data export.

Why GA4 needs an MCP server

GA4's native API requires:

  1. Service account setup with JSON key management
  2. Request formatting in Python or JavaScript using the official SDK
  3. Parsing complex nested JSON responses
  4. Rate limit management (10,000 requests/day for standard accounts)

With the MCP server, you declare intent ("get event count by device") and the protocol handles the rest. No credential management in your workflow, no boilerplate API calls. The LLM talks to MCP, MCP talks to GA4.

The 7 GA4 MCP tools

The GA4 MCP server provides seven specialized tools, each handling a specific class of analysis.

ToolPurposeInputOutput
get_propertiesList GA4 properties in your accountNone (uses account credentials)Array of property IDs, names, URLs
get_event_dataQuery raw event counts and metadataProperty ID, date range, dimensions, filtersEvents, dimensions, counts, time series
get_user_propertiesAnalyze by user segments and cohortsProperty ID, user criteria, date rangeUser counts, lifetime value, first/last touch
get_conversion_dataGoal/conversion funnel analysisProperty ID, conversion event, date rangeConversion rate, steps in funnel, drop-off
get_page_dataPage-level traffic and engagementProperty ID, page path, filters, date rangeViews, users, bounce rate, scroll depth, time on page
get_traffic_source_dataTraffic source breakdownProperty ID, date range, source filtersSessions by source, medium, campaign, ROAS
get_custom_reportBuild arbitrary dimension-metric combinationsProperty ID, dimensions, metrics, date rangeCustom data matrix, exportable to CSV

The real-world limits

It's important to be honest: the MCP server is read-only access. You can't create events, modify property settings, or trigger custom dimensions from Claude Code. What you get is fast exploratory analysis without leaving your IDE.

Known issue (#73): Windows timeout on large dataset queries (>1M events in single day). Workaround: narrow the date range or add more specific filters before the query.

Another limitation: GA4's native API doesn't expose funnel/path analysis natively. The conversion_data tool reconstructs funnels from event sequences, which means accuracy depends on how precisely your events track the customer journey.

Setup: 20-30 minutes

Prerequisites

  1. A GA4 property with at least 7 days of data
  2. A Google Cloud project (free, if under 10K requests/day)
  3. Claude Code with MCP support enabled

Step 1: Create a Google Cloud project service account

Go to Google Cloud Console → Create project → Service Accounts → Create service account. Generate a JSON key and download it. This key is your GA4 API credential.

Step 2: Grant GA4 property read access

In your GA4 property Admin → Property Access Management, add your service account email as an Editor or Viewer. Wait 5 minutes for permission sync.

Step 3: Configure MCP in Claude Code

Add the GA4 MCP configuration to your MCP settings (usually .claude/mcp.json or equivalent). Specify the property ID and service account credentials. The exact steps depend on your Claude Code version, but the core is: MCP server name, GA4 property, authentication method.

Step 4: Test with a simple query

In Claude Code prompt: "Show me the top 5 pages by traffic for the last 7 days." If the MCP server is configured, you'll get structured data back. If not, you'll see a connection error.

Three workflows where GA4 MCP transforms SEO strategy

Workflow 1: Real-time content performance by intent

Traditional approach: manually export GA4 report for "Page path and screen class", filter to blog URLs, cross-reference with your keyword mapping to see which article intent clusters drive traffic.

With GA4 MCP:

  1. Prompt: "For the last 30 days, show me traffic to /blog/* pages, grouped by landing page, sorted by users DESC. Include scroll depth."
  2. Get back structured data with engagement metrics.
  3. Follow up: "From the top 10 pages, which have <40% average scroll depth?" Immediately identifies underperforming content.
  4. Iterate: "Compare the H1 and word count of the bottom 5 by engagement to the top 5. Any patterns?"

Workflow 2: Attribution for GEO

GEO (Generative Engine Optimization) drives traffic differently than traditional organic. You need to identify which queries are coming through AI Overviews vs regular organic.

With GA4 MCP:

  1. Query: "Show me events where the traffic source contains 'perplexity' or 'gpt' or 'chatgpt' or 'claude', last 30 days, broken by page."
  2. Create a custom segment: "Users who arrived via AI search AND viewed at least 3 pages."
  3. Analyze: "What's the conversion rate for AI vs traditional organic over the same period?"

Workflow 3: Cross-platform integration

The real power is when you combine GA4 queries with other MCP tools (Screaming Frog for crawl data, DataForSEO for SERP rankings, Google Search Console for impressions). You get a unified data layer for SEO strategy.

Example workflow:

  1. Query GSC via MCP: "Top 100 keywords by impressions, last 90 days, from the /blog category."
  2. Query GA4 via MCP: "Pages matching those URLs, traffic breakdown by source, last 90 days."
  3. Combine: "Which high-impression GSC keywords drive little traffic? Potential quick wins for content optimization."

Integration with the three-pillar SEO system

GA4 MCP isn't just a data access tool—it completes the three-pillar SEO analysis system:

PillarResponsibilityMCP Server
CrawlUnderstand site structure, technical healthScreaming Frog (crawl output)
SearchUnderstand rankings, impressions, visibilityGoogle Search Console (GSC, SERP data)
AnalyticsUnderstand engagement, conversions, behaviorGoogle Analytics 4 (traffic, events, users)

When all three are available as MCP tools, you stop moving data between systems. You ask one unified query engine: "Which crawled pages with GSC impressions drive conversion traffic?" Claude Code queries all three, synthesizes the answer in seconds.

Limitations and honest assessment

What the GA4 MCP server doesn't do

  • Can't create or modify GA4 events—read-only access only
  • Can't set up new properties or change tracking code
  • Can't export to BigQuery or run custom SQL queries (GA4 API limitation, not MCP)
  • Funnel analysis reconstructed from events, not true funnel UI

Performance on large datasets

GA4 API has rate limits (10K requests/day standard, 100K with enterprise). If your property processes millions of events/day, a single "broad" query (all events, no date filter) can consume half your daily quota. Always filter by date range and add metric specificity before querying.

Windows timeout issue #73: some queries on large date ranges hang on Windows systems. The workaround is simple: narrow the date range or add dimension filters. It's not a blocker but worth knowing.

When to use GA4 MCP vs exporting manually

GA4 MCP is best for exploratory, iterative analysis. You ask a question, get data, ask a follow-up, refine. Manual export is still faster for one-off static reports (e.g., "monthly board dashboard").

ScenarioUse MCP?Why
Exploring which content underperformsYesIterative queries, live refinement
Creating a monthly traffic reportNoStatic once-a-month export to PDF is faster
Identifying high-impression low-traffic keywordsYesRequires GSC + GA4 synthesis
Auditing tracking setup for missing eventsYesQuery GA4 schema, validate event payload
Comparing traffic patterns before/after redesignYesCustom date range filters, iterative

Frequently asked questions

Do I need BigQuery for GA4 MCP to work?

No. BigQuery is Google's data warehouse option for GA4, useful if you're running complex analysis at scale. GA4 MCP uses the standard Reporting API, which is limited but sufficient for most SEO analysis. BigQuery is overkill for typical content audits.

Can I use GA4 MCP with multiple properties?

Yes. The get_properties tool lists all properties in your account. You specify a property ID for each query, so you can analyze multiple sites in one Claude Code session.

What about data privacy and security?

GA4 MCP uses the same Google Cloud authentication as the native GA4 API. Your service account credentials are stored securely in your Claude Code environment, not transmitted to Anthropic. Data returned by queries is GA4 data your account already has access to.

Does GA4 MCP work with GA4 event configuration?

Partially. You can query GA4 events by whatever dimensions and metrics your property measures. But you can't modify the event schema or create new events from Claude Code. That still requires GA4's property settings UI or the Management API.

For deeper context on multi-agent workflows in SEO, read my guide to workflow patterns for SEO AI agents. GA4 MCP is one piece of the larger orchestration puzzle.

Frequently Asked Questions

A bridge between Claude Code and GA4 workspace. Use 7 specialized tools to query GA4 data directly without API boilerplate. 20-30 minute setup, then analyze traffic, conversions, events natively.

No. GA4 MCP uses the standard Reporting API, sufficient for most SEO analysis. BigQuery is overkill for content audits and traffic analysis.

Yes. The get_properties tool lists all properties in your account. Specify property ID for each query, analyze multiple sites in one session.

Read-only access (can't create/modify events). Windows timeout on large datasets (issue #73, use narrower date ranges). Funnel analysis reconstructed from events, not true GA4 funnel UI.

Use MCP for exploratory iterative analysis. Use manual export for one-off static reports. MCP shines for GSC+GA4 synthesis and content performance audits.

Yes. Uses same Google Cloud authentication as native GA4 API. Service account credentials stored securely in Claude Code environment. Data returned is what your account already accesses.

Yes, for querying existing events. Can't modify event schema or create new events from Claude Code—that requires GA4 settings UI or Management API.

About the author

Claudio Novaglio

Claudio Novaglio

SEO Specialist, AI Specialist e Data Analyst con oltre 10 anni di esperienza nel digital marketing. Lavoro con aziende e professionisti a Brescia e in tutta Italia per aumentare la visibilità organica, ottimizzare le campagne pubblicitarie e costruire sistemi di misurazione data-driven. Specializzato in SEO tecnico, local SEO, Google Analytics 4 e integrazione dell'intelligenza artificiale nei processi di marketing.

Want to improve your online results?

Let's talk about your project. The first consultation is free, no commitment.