In 2026, Claude Code for data analysts is no longer a gimmick: it is an AI agent in your terminal that reads your schema, writes its own queries, runs them, and explains the results. Connected to GA4 and BigQuery through MCP, it turns the sentence “revenue growth by category this quarter” into executed SQL without you ever touching UNNEST. The promise is real. So is the catch: the AI sees the raw data, not your business logic. This guide shows how to build a reliable workflow, and where you should never trust it blindly.
From “writing SQL” to “talking to your data”
For a decade, an analyst spent most of their time translating a business question into SQL. The GA4 export to BigQuery multiplied analytical power, but it also multiplied friction: nested tables, event_params to unpack, partitions to filter. Writing a clean query took minutes, sometimes hours of debugging.
Agentic AI flips the workload. You state the intent in plain English, the agent proposes the SQL, runs it, and presents a commented result. The work does not vanish: it shifts toward phrasing the question precisely and critically reviewing what the agent produced. That is exactly where an analyst’s skill stays decisive.
Claude Code and MCP in one minute
Claude Code is Anthropic’s AI agent that runs in your terminal. It does not just answer: it acts, by reading files, running commands, and calling external tools.
It reaches those external tools through MCP (Model Context Protocol), an open protocol that connects an AI model to data sources and services. An “MCP server” exposes capabilities (read a BigQuery schema, run a query, call the GA4 API) that the agent can use. By 2026, MCP has become the standard, and analytics connectors have multiplied.
Keep in mind the nuance that changes everything: a BigQuery MCP server gives raw SQL access. There is no semantic layer, no validated metric definitions, no governed join logic. The agent sees columns, not your business logic.
Two entry points for an analyst
Depending on the question, two paths exist, with clear trade-offs.
| Criterion | GA4 API MCP | BigQuery MCP (GA4 export) |
|---|---|---|
| Data type | Aggregated (dimensions and metrics) | Raw, event level |
| Freshness | Near real time | Depends on export (next day for daily) |
| Row limits | API caps, possible sampling | No limit, unsampled data |
| Use case | Quick questions, checks, light reporting | Custom attribution, journeys, heavy queries |
| Cost | API quotas | Billed per data scanned |
| Main risk | Misread metric definitions | Bad joins and UNNEST, runaway cost |
Entry point 1: the GA4 API MCP
Ideal for everyday questions: “what are my top 10 viewed pages over 28 days?”, “which channel converted best last week?”. You query dimensions and metrics already computed by GA4, so with the official definitions. The downside: you also inherit the interface limits (sampling, row caps, cardinality).
Entry point 2: BigQuery on the GA4 export
This is maximum power. Raw, event-level, unsampled data: you can rebuild journeys, compute custom attribution, and blend with other sources. It is also where rigor matters most, because the agent writes free-form SQL on a complex schema. If the GA4 export to BigQuery is not set up yet, it is prerequisite number one: see the practical guide to working with the GA4 BigQuery export.
Step-by-step setup
Prerequisites
Before connecting anything: an active GA4 export to BigQuery, a Google Cloud project with billing enabled, and a service account (or user auth) with read-only rights on the dataset. Never give the agent more rights than it needs.
Wiring up an MCP server
Several options coexist in 2026. Google Cloud offers an official integration for BigQuery; on the ecosystem side, vendors such as Composio, Windsor.ai, Porter, Stape, or Sequel ship analytics-oriented MCP servers. Always verify the connector’s actual status and permissions when you install it, because the landscape moves fast. The principle stays the same: you declare the MCP server in your Claude Code configuration, with the access credentials, then restart the agent.
A first sanity-check prompt
Do not ask for an analysis right away. Start by validating the connection and schema understanding:
“List the tables in my GA4 dataset and describe the structure of the most recent events table.”
If the agent returns your events_YYYYMMDD tables and correctly describes event_name, event_params, or user_pseudo_id, the chain works. It is also the moment to confirm it has identified the nested columns.
High-ROI, concrete use cases
Express property audit
“Over the last 7 days, list the 20 most frequent event_name values, and flag any that look like duplicates or inconsistent naming.” In seconds you get a snapshot of tracking quality. The quality of those answers depends directly on how clean your collection is; if your events are already wrong, the agent will faithfully reflect it. That is the whole point made in the 7 data layer mistakes that skew your GA4 data.
Ad hoc exploration
“Compute MoM revenue growth by product category over the last 6 months.” The agent unpacks items, aggregates, pivots, and comments. You validate the logic in seconds instead of writing the query.
Generating complex BigQuery queries
This is one of the best uses: let the agent draft a first version of a heavy query (multiple joins, partition filters, nested UNNEST), which you then correct. You save on syntax and plumbing, you keep control of the business logic.
Drafting an attribution model
On raw data, you can ask for an attribution skeleton (first click, last non-direct click, position-based) to rebuild from sessions. Treat it as a draft to audit, never as a publishable result as is.
Where the AI goes off the rails
Here is the heart of the article, and what “no-code” tutorials gloss over. The agent is impressive on syntax, fallible on meaning.
Hallucinated joins are risk number one. The agent may join two tables on a plausible but wrong key, or invent a relationship that does not exist in your model. The SQL runs, the number shows up, and it is wrong.
Metric definitions are the other trap. “Session”, “active user”, “conversion” have precise definitions in GA4. On the raw export, the agent recomputes them its own way, which may not match the interface. Two “revenue” figures can diverge without it being a bug.
Cost matters too. A poorly scoped query, with no partition filter, can scan terabytes and cost you dearly. The agent has no native sense of your budget.
Finally, privacy. The GA4 export can contain identifiers and sensitive data. Granting broad access to an AI agent deserves real thought about scope, permissions, and compliance.
Golden rule: always have the SQL reviewed and cross-check the numbers against a known source before deciding anything.
Best practices to make it reliable
Document the context the agent cannot guess: a file describing your schema, your metric definitions, and your join rules dramatically improves relevance. Restrict access to the strict minimum, read-only, on the relevant datasets. Always enforce a partition filter to control cost. Review the generated SQL before running it on large volumes. And keep a human in the loop for every decision: the agent proposes, the analyst validates.
For recurring deliverables, the AI shines at preparation and verification more than at blind automation. It helps you build and audit what you will publish in your reports, as covered in automating your reports with Looker Studio and BigQuery.
Verdict: where to start
Claude Code connected to GA4 and BigQuery saves hours on exploration, query generation, and debugging. It does not replace the analyst: it shifts their value toward governance, knowledge of the GA4 schema, and business context, which become more important, not less.
Start with no risk: connect the GA4 API MCP read-only first, ask it questions whose answers you already know, and watch where it gets things wrong. Once you have calibrated your trust, open the BigQuery door for heavy analysis. Worth noting: this blog is itself run with these tools, which helps measure their strengths and limits in practice.
Curious about AI from the other angle, AI as a traffic source rather than a tool? See tracking ChatGPT, Gemini, and Claude traffic in GA4.