Connecting to the Google Analytics GA4 MCP Server

Stuart Brameld, Founder at Growth Method

Article written by

Stuart Brameld

Google just dropped something pretty cool for anyone working with analytics data and AI. They've built an official Model Context Protocol (MCP) server that connects your favourite AI tools directly to Google Analytics 4.

Think about it: instead of logging into GA4, clicking through dashboards, and copying numbers into spreadsheets, you can now just ask your AI assistant "How many users visited my site last week?" and get real answers.

"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

Here's Matt explaining the whole thing:

The server taps into both the GA4 Reporting API and Admin API, so you can pull metrics, dimensions, apply filters, and grab property details. It's basically a bridge between your analytics data and any AI tool that supports MCP.

What can you actually do with it?

The GA4 MCP server comes packed with tools. Here's the full lineup:

Tool Name

What It Does

get_dimensions

Grabs all the dimensions for your property, including custom ones

get_metrics

Gets all available metrics for your property, including custom metrics

get_standard_dimensions

Lists standard GA4 dimensions

get_standard_metrics

Lists standard GA4 metrics

run_report_date_ranges_hints

Shows you what date ranges you can use

run_report_metric_filter_hints

Helps you understand how to filter metrics

run_report_dimension_filter_hints

Helps you understand how to filter dimensions

Real questions you can ask

Here are some practical questions you can throw at your AI once it's connected to your GA4 data:

  • "What were my top 5 traffic sources last month?"

  • "How did mobile vs desktop traffic perform this quarter?"

  • "Which pages have the highest bounce rate?"

  • "Show me conversion rates broken down by country"

  • "What's my real-time user count right now?"

  • "How many new users did I get from organic search last week?"

  • "Which campaigns drove the most revenue this month?"

  • "What's my average session duration trend over the past 3 months?"

The magic happens behind the scenes - your natural language questions get converted into proper GA4 API calls automatically.

Setting up the APIs

Before you can use this thing, you need to enable two APIs in Google Cloud Console:

1. Google Analytics Admin API

Head to Google Cloud Console and enable this one. It gives you programmatic access to your GA4 configuration data. Check out the API Explorer if you want to see what's possible.

2. Google Analytics Data API

Enable this one at Google Cloud Console too. This is what actually pulls your report data. The API Explorer shows all the endpoints.

Running it locally

Want to run the server on your machine? Follow the official instructions, but here's the gist.

You'll need pipx (it's like a virtual environment manager for Python CLI tools):

brew install pipx
pipx ensurepath
sudo pipx ensurepath --global
brew update && brew upgrade pipx

Then follow the setup steps in the GitHub repo to get everything running.

Going remote with Cloudflare Workers

If you want something more robust, you can deploy this as a remote MCP server on Cloudflare Workers.

Cloudflare makes this pretty easy. They even had an MCP Demo Day where companies like Atlassian, Asana, Webflow, Linear, Sentry, PayPal, Stripe, and Intercom all built their MCP servers on Cloudflare.

The remote version gives you the same functionality as running it locally, but with Cloudflare's global edge network handling the heavy lifting. It's basically a serverless gateway for querying GA4 data via JSON-RPC.

You get all the same tools:

  • get_account_summaries - List your GA accounts and properties

  • get_property_details - Get property info

  • run_report - Run standard GA4 reports

  • run_realtime_report - Get real-time data

  • get_dimensions - List available dimensions

  • get_metrics - List available metrics

Connecting your AI tools

Once your server is running (either locally or on Cloudflare), connecting it to AI tools is straightforward. If you went the Cloudflare route, just add your worker URL (https://ga4-mcp.xxxxxx-xxx.workers.dev) to your MCP client.

Popular options include:

For developers, you might want to try:

Check out PulseMCP for a full list of MCP clients.

Authentication options

Here's how the different auth methods stack up:

Method

Description

Can Verify GA Permissions?

Acts on Behalf of User?

Notes

Application Default Credentials (ADC)

Uses environment variables or Google Cloud SDK setup

✅ Yes

⚠️ Not directly, unless using user creds

Good for server-to-server or local dev with gcloud auth application-default login

Service Account (via ADC)

JSON key for a service account

✅ Yes

❌ No

Service account needs GA property access in GA Admin UI

OAuth 2.0

Interactive auth flow with user consent

✅ Yes

✅ Yes

Best for apps accessing GA data for multiple users. Handles token storage & refresh

API Key

Static project identifier key

✅ Yes (limited)

❌ No

Very limited; not great for user-specific GA data

For MCP, you'll typically use a Service Account with a JSON key. 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 point to your service account JSON file

  • Make sure your credentials include the Google Analytics read-only scope: https://www.googleapis.com/auth/analytics.readonly

This is still pretty new, but it's already changing how people interact with their analytics data. Instead of being a dashboard jockey, you can have actual conversations with your data. Pretty neat stuff.

"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

If you're looking to get more from your marketing data and drive pipeline growth, Growth Method is the GrowthOS built for marketing teams focused on pipeline — not projects. Book a call to see how it can help streamline your growth efforts.

Resources and links

Want to dive deeper? Here are the key resources:

Stuart Brameld, Founder at Growth Method
Stuart Brameld, Founder at Growth Method
Stuart Brameld, Founder at Growth Method

Article written by

Stuart Brameld

Category:

Acquisition Channels

Real experiments. Shared monthly.

Join 500+ growth professionals