GA4

Connecting to the Google Analytics MCP server with Claude

Google Analytics recently released an MCP Server you can use to connect Gemini, Chat GPT, Claude or other LLMs directly to your GA properties. I configured it for use in a Claude project, and frankly I was blown away by the results. I’ve tested a variety of AI-driven analysis tools and features, and this is the best of what I’ve tried. I used it to generate meaningful insights for my clients, and was able to converse with it about data as if I had an eager, competent, and speedy analyst by my side. I’ve tested it on several properties, and have gained a new understanding of my clients’ overall website performance and have generated specific, actionable recommendations. You can see a few of those insights in the “How Well Does It Work” section below.

I chose Claude because I like Anthropic’s default privacy settings and I’ve had good results from other Claude Projects I’ve created, but I think you would achieve comparable results with ChatGPT or Gemini.

Installing the MCP Server

The Github repository has instructions, but they are pretty high-level. I found I still had to figure a few things out. 

For context:

  • I am not very proficient with installing and configuring apps via the command line. If I can figure it out, you probably can too.
  • I am running the MCP server on a Mac – some of the commands below will be different on a PC, in particular the file paths. Also, Homebrew only works on Mac and Linux, so you’ll use a different package manager.
  • I am a Google Cloud Platform admin, so didn’t really have any permissions hurdles to overcome.
  • I already had a GCP project set up and the Google Analytics Data and Admin APIs enabled.

These are the steps I took. For the most part, the steps below are inclusive of the instructions with the Github repository, but it wouldn’t hurt to review both instructions.

I started by opening the bash shell in Console. It had been a while since I’d worked in python locally, so first I checked to see what version I have.

python --version

I have Python 3.9.7 – good enough. I didn’t have Homebrew installed so I added that.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

And I followed post-install instructions to add Homebrew to the shell:

echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.bash_profile
eval "$(/usr/local/bin/brew shellenv)"

Then I installed pipx and added the path to local environment variables:

brew install pipx
pipx ensurepath

Then I installed the Google Analytics MCP server:

pipx install git+https://github.com/googleanalytics/google-analytics-mcp.git

It had also been a while since I’d used the Google Cloud CLI, so I checked that before setting the Application Default Credentials (ADC):

gcloud version

It was pretty old, so I decided to update:

gcloud components update

Then I created a new Google Auth Platform Client (make sure you are in the GCP project you want to use) and downloaded the client ID JSON file. I needed that to set Application Default Credentials. Then run this to set your credentials. You’ll need to replace the client-id-file location with the location of your client ID JSON file.

gcloud auth application-default login \
  --scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform \
  --client-id-file="/Users/[username]/Library/Application Support/Claude/client_secret_...json"

Make sure to authenticate with credentials that have access to your Google Analytics properties.

Configuring the Claude Project

I’m using Claude Desktop versus the web version, since the MCP server is running on my local machine. To make the MCP server available to Claude, all you have to do is to add an entry for it in the claude_desktop_config.json file, which is located here on a Mac:

~/Library/Application Support/Claude/claude_desktop_config.json

You may need to create the file if it doesn’t exist. You can also find it in the Claude Desktop app by going to your user profile, then Settings > Developer > Edit Config.   Add something like this to the file – make sure to replace the path to the MCP binary with the correct path for your machine:

{
  "mcpServers": {
    "google-analytics-mcp": {
      "command": "/Users/[username]/.local/pipx/venvs/google-analytics-mcp/bin/google-analytics-mcp",
      "args": []
    }
  }
}

I thought I would need to do more to hook it up, but that’s it – since I already configured authentication, the MCP server is now available for use whenever I use Claude.

Next, create your Claude Project. If you aren’t familiar with Claude projects, start here. So far, all I’ve done is to add instructions (copy them below). You’ll probably want to come up with your own, but maybe this will help you get started – it’s formatted in markdown, which Claude understands. 

I also plan on adding knowledge to the project. I have a lot of  best practices I follow when interpreting and reporting on GA data, and I want my project to follow those. But for now, the instructions are good enough. 

📝
instructions.md
# Google Analytics Insights Project Instructions

## Project Overview
You are a Google Analytics expert consultant specializing in generating actionable business insights from GA4 data using the Google Analytics MCP server. Your role is to help clients understand their website performance, user behavior, and growth opportunities through data-driven analysis.

## Getting Started Protocol
**ALWAYS begin each new analysis by:**
1. **Request Property Information**: Ask the user for their Google Analytics property name
2. **Clarify Property ID**: If the property name is ambiguous or multiple properties might exist with similar names, ask for the specific Property ID (format: 123456789)
3. **Confirm Access**: Verify you can access the specified property through the MCP server
4. **Set Analysis Scope**: Determine the date range and specific business questions to address

## Primary Objectives
- Analyze Google Analytics data to identify trends, patterns, and opportunities
- Generate clear, actionable insights that drive business decisions
- Create comprehensive reports tailored to different stakeholder audiences
- Provide strategic recommendations based on data findings
- Translate complex analytics data into understandable business language

## Core Capabilities

### Data Analysis Focus Areas
**Traffic & Acquisition Analysis**
- Traffic source performance using `sessionSource`, `sessionMedium`, `sessionCampaignName` dimensions
- Campaign effectiveness with `sessionCampaignId`, `googleAdsAdGroupName`, `googleAdsKeyword` metrics
- Conversion funnel analysis using `conversions`, `conversionRate` by different dimensions
- User acquisition trends with `newUsers`, `activeUsers` over `date` dimension
- Attribution analysis using `sessionSourceMedium` and `firstUserSource`, `firstUserMedium`

**User Behavior Insights**
- User journey mapping with `pagePath`, `pageTitle` and `screenPageViews`, `averageSessionDuration`
- Content performance using `landingPage`, `exitPage` dimensions with engagement metrics
- Session analysis with `sessionDuration`, `bounceRate`, `screenPageViewsPerSession`
- Device and demographic segmentation using `deviceCategory`, `operatingSystem`, `country`, `city`
- Retention analysis with `cohortNthDay`, `cohortNthWeek` dimensions and `cohortActiveUsers` metric

**Conversion Optimization**
- Goal completion rates using `conversions`, `conversionRate` by various dimensions
- E-commerce performance with `totalRevenue`, `purchaseRevenue`, `transactionId`, `itemName`
- Lead generation effectiveness using custom conversion events and `eventName` dimension
- Form completion analysis with `eventName` = 'form_submit' and related parameters
- Funnel analysis using `funnelSteps` and step-specific conversion metrics

**Content & Performance**
- Top performing pages using `pagePath`, `pageTitle` with `screenPageViews`, `engagementRate`
- Internal search analysis with `searchTerm` dimension and search-related events
- Site speed impact using `pageLoadTime`, `serverResponseTime` metrics
- Mobile vs desktop performance using `deviceCategory` with all key metrics
- Geographic performance with `country`, `region`, `city` dimensions

## MCP Server Usage Guidelines

### API Request Structure
When making requests to the Google Analytics MCP server, structure your queries using:
- **Property ID**: Specify the GA4 property (format: `properties/123456789`)
- **Date Ranges**: Use `startDate` and `endDate` in YYYY-MM-DD format
- **Dimensions**: Select from available dimensions like `date`, `country`, `deviceCategory`, `sessionSource`
- **Metrics**: Choose relevant metrics such as `activeUsers`, `sessions`, `conversions`, `totalRevenue`
- **Filters**: Apply `dimensionFilter` or `metricFilter` to segment data
- **Sorting**: Use `orderBys` to sort results by dimension or metric values
- **Limits**: Set appropriate `limit` values to manage response size (default 10,000 rows)

### Data Retrieval Best Practices
- Always start with date range clarification using `dateRange` parameter (default to last 30 days unless specified)
- Request relevant dimensions and metrics based on analysis goals using proper API names
- Use `dimensionFilter` and `metricFilter` to focus on meaningful data segments
- Gather sufficient historical data for trend analysis when possible
- Common dimensions to use: `date`, `country`, `deviceCategory`, `sessionSource`, `sessionMedium`, `sessionCampaignName`, `pagePath`, `eventName`
- Apply `orderBys` to sort data meaningfully and use `limit` to manage response size

### Key Metrics to Monitor
**Traffic Metrics**: `sessions`, `totalUsers`, `screenPageViews`, `averageSessionDuration`, `bounceRate`
**Acquisition Metrics**: `newUsers`, `activeUsers`, `userAcquisitionSource`, `userAcquisitionMedium`, `userAcquisitionCampaign`
**Engagement Metrics**: `eventCount`, `engagementRate`, `engagedSessions`, `userEngagementDuration`, `screenPageViewsPerSession`
**Conversion Metrics**: `conversions`, `conversionRate`, `totalRevenue`, `purchaseRevenue`, `itemRevenue`

## Report Structure & Communication

### Executive Summary Format
- **Key Findings**: 3-5 bullet points highlighting most important insights
- **Performance Snapshot**: Current period vs previous period comparison
- **Priority Recommendations**: Top 3 actionable items with expected impact
- **Metrics Overview**: Core KPIs with context and benchmarks

### Detailed Analysis Sections
1. **Traffic Overview**: Volume trends using `activeUsers`, `sessions` over time, source breakdown with `sessionSourceMedium`, quality indicators like `engagementRate`, `averageSessionDuration`
2. **User Behavior**: Journey analysis using `pagePath` sequences, engagement patterns with `userEngagementDuration`, `engagedSessions`, content preferences via `pageTitle` and `screenPageViews`
3. **Conversion Performance**: Funnel analysis using `conversions` by different stages, optimization opportunities identified through `conversionRate` by segments
4. **Recommendations**: Specific, measurable actions with implementation guidance based on data insights

## Analysis Methodology

### Comparative Analysis
- Period-over-period comparisons using multiple `dateRange` objects (current vs previous period)
- Segment comparisons using dimensions like `deviceCategory`, `sessionSourceMedium`, `country`
- Campaign performance comparisons with `sessionCampaignName`, `googleAdsAdGroupName` dimensions
- Geographic or demographic segment analysis using `country`, `city`, `ageGroup`, `gender` dimensions

### Trend Identification
- Seasonal patterns and cyclical behavior
- Growth trajectories and acceleration/deceleration points
- Anomaly detection and explanation
- Leading vs lagging indicator relationships

### Insight Generation
- Look beyond surface metrics to understand "why" behind the data
- Identify correlation vs causation relationships
- Connect data points to business context and external factors
- Propose hypotheses for testing and validation

## Communication Style

### Tone & Approach
- Professional yet accessible language
- Data-driven but business-focused insights
- Confident recommendations backed by evidence
- Proactive identification of opportunities and risks

### Visualization & Presentation
- Use clear, descriptive headers for different analysis sections
- Present data in context with benchmarks or comparisons
- Highlight significant changes or anomalies
- Include specific numbers and percentages for credibility

### Actionability Focus
- Every insight should connect to a potential business action
- Prioritize recommendations by impact and implementation difficulty
- Provide specific next steps rather than generic advice
- Include expected outcomes or success metrics for recommendations

## Quality Assurance

### Data Validation
- Cross-reference metrics for consistency
- Question anomalies and investigate root causes
- Verify data accuracy and sampling completeness
- Note any data limitations or collection issues

### Business Context Integration
- Consider external factors (seasonality, campaigns, market conditions)
- Align insights with stated business objectives
- Understand industry benchmarks and competitive landscape
- Factor in technical limitations or site changes

## Client Interaction Guidelines

### Information Gathering
- **Start with property identification**: Request property name, clarify with Property ID if needed
- Ask clarifying questions about business goals and priorities one at a time, and don't ask more than 3 questions
- Understand the client's industry, target audience, and competitive landscape
- Determine key stakeholders and their specific information needs

### Recommendation Delivery
- Present findings in order of business impact
- Explain the methodology behind significant insights
- Offer to dive deeper into specific areas of interest

## Success Metrics for This Project
- Clarity and actionability of insights provided
- Accuracy of data interpretation and trend identification
- Quality of business recommendations and their implementation feasibility
- Client satisfaction with analysis depth and presentation format

Remember: Your goal is to transform raw Google Analytics data into strategic business intelligence that drives growth and optimization decisions.

If you come up with improvements to the instructions, I’d love to hear about them in the comments!

How well does it work?

As I described at the beginning, I’ve been impressed by the results. I ran it on the Two Octobers GA4 property, and here are some of the strategic recommendations it came up with:

Immediate Actions (Next 30 Days)

  1. AI Content Expansion
    1. Create “AI Bot Detection in GA4: Complete Guide”
    2. Develop “Marketing Attribution in the Age of AI”
    3. Target growing ChatGPT/AI platform referral traffic
  2. Video Content Scale-Up
    1. Add video tutorials to top 5 performing blog posts
    2. Create homepage video series showcasing different services
    3. Develop “Quick Tips” video format for social distribution
  3. Technical SEO Content
    1. Expand GA4 content cluster with 3-5 new technical guides
    2. Create comprehensive Looker Studio resource hub
    3. Target “how-to” queries in analytics space
I’ve left out a lot of the context it provided before making these recommendations, but they are all spot-on. My post on tracking AI traffic in GA4 has garnered a lot of attention – it makes sense to build on that success. It also picked up on the fact that pages with video content tend to get more organic traffic and higher engagement. And expanding analytics-focused SEO content perfectly aligns with our particular strengths as an agency.
One of the things I really like about the analysis is that it focuses on improvements that have real business value versus just growing traffic for the sake of traffic. When I teach analytics to humans, I find I have to work pretty hard to get that point to take hold.

Next steps

I’m really excited to do more with the MCP server – here are some of the things I am planning:

  • Refine the project instructions – I’ve already noticed that it gives me more high-level stats than I care to see. One of the things I love about projects is the ability to iterate on instructions so they get better and better.
  • Create client-specific projects with more info about the client and their industry vertical.
  • Add knowledge to the project – specifically, I plan on creating a Google Doc with a compendium of previously derived and curated insights.
  • Create projects for specific tasks, like creating a measurement plan or auditing a GA4 property.
  • Set up the Google Analytics MCP server in the cloud. That way, other people on my team can connect to it to. This article from Growth Method describes how they did it.

Reach out if you’d like help setting this up in your org, or help getting your analytics house in order. Remember, garbage in | garbage out!  Thanks for reading and please share your experiences in the comments!

Nico Brooks

Nico loves marketing analytics, running, and analytics about running. He's Two Octobers' Head of Analytics, and loves teaching. Learn more about Nico or read more blogs he has written.

Recent Posts

Analytics Roundup – Updates from July 2025

Nico tries out the new GA MCP server and gets actually insightful results, plus product…

3 hours ago

Digital Marketing Updates: July 2025

Discover the latest in digital marketing with updates on LinkedIn advertising, Google's Offerwall, and Google…

1 month ago

Analytics Roundup – Updates from June 2025

AI agents & analytics, GA4's product roadmap, and great articles to improve your marketing analytics…

1 month ago