Master Google Analytics GA4 MCP to Unlock Data Insights

Article written by
Stuart Brameld
Ever wished you could just ask Google Analytics questions in plain English and get instant answers? That's exactly what the new Google Analytics GA4 MCP Server does. It bridges the gap between AI chatbots like Claude and your GA4 data, letting you query your analytics without wrestling with complex interfaces.
What is the Google Analytics MCP Server?
The official Google Analytics MCP server connects Large Language Models directly to your Google Analytics data. Instead of clicking through dashboards, you can ask natural language questions and get real insights.
As Matt Landers, Head of Developer Relations at Google Analytics, puts it:
"I'm thrilled to announce the launch of our open-source Model Context Protocol (MCP) server for Google Analytics! This bridges the gap between the powerful conversational abilities of Large Language Models (LLMs), like Gemini, and the rich, specific data within your Google Analytics property."
Matt Landers, Head of Developer Relations at Google Analytics
The server taps into both the GA4 Reporting API and Admin API, giving you access to metrics, dimensions, filters, and property details through simple conversation.
Available tools
The MCP server comes packed with tools that handle different aspects of your GA4 data:
Tool Name | What It Does |
---|---|
get_dimensions | Retrieves Core Reporting Dimensions for a specific property, including its custom dimensions |
get_metrics | Retrieves Core Reporting Metrics for a specific property, including its custom dimensions |
get_standard_dimensions | Retrieves the list of standard dimensions |
get_standard_metrics | Retrieves the list of standard metrics |
run_report_date_ranges_hints | Provides hints about the expected values for the date_ranges argument for the run_report tool |
run_report_metric_filter_hints | Provides hints about the expected values for the metric_filter argument for the run_report and run_realtime_report tools |
run_report_dimension_filter_hints | Provides hints for dimension filtering in reports |
Real-world use cases
Here's where this gets exciting. You can ask questions like a human would and get instant answers:
Traffic Analysis: "How many users visited my site last month compared to the month before?"
Content Performance: "Which blog posts drove the most conversions this quarter?"
Audience Insights: "What's the bounce rate for mobile users vs desktop users?"
Campaign Effectiveness: "Show me conversion rates by traffic source for the past 30 days"
Geographic Performance: "Which countries generate the most revenue?"
Behaviour Flow: "What pages do users visit most after landing on my homepage?"
Real-time Monitoring: "How many active users are on my site right now?"
Custom Events: "How often are users clicking my CTA buttons?"
E-commerce Deep Dive: "What's my average order value by device type?"
The magic happens behind the scenes - your natural language gets translated into proper GA4 API calls automatically.
Testing your setup
You can test the GA4 MCP with popular client apps:
Claude
Cursor
VS Code
For developers who want more control, consider these options:
Setting up locally
Want to run this on your machine? Follow the official instructions and install pipx first. It creates isolated environments for Python CLI tools:
brew install pipx
pipx ensurepath
sudo pipx ensurepath --global
brew update && brew upgrade pipx
Cloud deployment option
For a more scalable approach, you can deploy as a remote MCP server on Cloudflare Workers using TypeScript and Wrangler.
This creates a serverless gateway for querying Google Analytics 4 via JSON-RPC. You get the same functionality as the local Python version but with Cloudflare's global edge network handling the heavy lifting.
The cloud version supports all the same tools:
get_account_summaries - List GA accounts and properties
get_property_details - Get property information
run_report - Run standard GA4 reports
run_realtime_report - Get real-time analytics data
get_dimensions - List available dimensions
get_metrics - List available metrics
Required API access
Before diving in, enable these two APIs in your Google Cloud Console:
Google Analytics Admin API - Enable here
Gives programmatic access to GA4 configuration data
Google Analytics Data API - Enable here
Accesses your actual report data
Authentication made simple
Here's the deal with authentication options:
Method | Description | Can Check GA Permissions? | Acts for Specific User? | Notes |
---|---|---|---|---|
Application Default Credentials (ADC) | Uses environment variables or Google Cloud SDK setup | ✅ Yes | ⚠️ Not directly, unless using user credentials under ADC | Great for server setups or local dev with gcloud auth application-default login |
Service Account (via ADC) | Uses a JSON key file for a service account | ✅ Yes | ❌ No | Service account needs GA property access granted in GA Admin UI |
OAuth 2.0 | Interactive flow for user consent and tokens | ✅ Yes | ✅ Yes | Best for multi-user apps. Handles token storage and refresh automatically |
API Key | Static key identifying your project | ✅ Yes (limited) | ❌ No | Very limited scope; not recommended for user-specific GA data |
Recommended approach: Use a Service Account JSON key since MCP works best with service accounts rather than interactive OAuth.
Here's what you need to do:
Share access to your GA4 property with the service account email (Viewer role or higher)
Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to your service account JSON file path
Make sure your credentials include the Google Analytics read-only scope: https://www.googleapis.com/auth/analytics.readonly
The bottom line
The Google Analytics GA4 MCP Server transforms how you interact with your analytics data. Instead of learning complex query languages or navigating through multiple dashboard screens, you just ask questions like you're talking to a colleague who happens to know everything about your website traffic.
Whether you run it locally for personal projects or deploy it to the cloud for team use, this tool makes GA4 data accessible to anyone who can ask a good question. And isn't that how analytics should work?
"We are on-track to deliver a 43% increase in inbound leads this year. There is no doubt the adoption of Growth Method is the primary driver behind these results."
Laura Perrott, Colt Technology Services
Growth Method is the GrowthOS built for marketing teams focused on pipeline — not projects. Book a call at https://cal.com/stuartb/30min.
Article written by
Stuart Brameld
Category:
Acquisition Channels