I’m not a Google Analytics expert. I don’t want to learn the interface just to get basic data about my site. And honestly, if I can centralize another workflow into my Claude CLI, I’m going to do that - Claude’s already my super-intern who can wear any and all the hats.

As I started thinking about growing this site, I realized Claude already knows everything else about it - the content, the structure, the code. Why wouldn’t I want Claude to know the traffic data too?

WHY ANALYTICS VIA CLAUDE IS MORE POWERFUL

This isn’t just about convenience. When Claude has access to your analytics, it can do things you probably wouldn’t bother doing manually.

Cross-reference content with performance:

Which of my blog posts have the highest bounce rate? Look at the content of those posts and tell me what might be causing people to leave.

Spot patterns across dimensions:

Compare average session duration by device category and traffic source over the last 90 days. What stands out?

Get context you’d never dig for:

Show me conversion rates by traffic source, comparing last 30 days vs previous 30 days. Which sources are trending up or down?

Actually act on insights:

Based on my top performing pages, what topics should I write about next?

The difference between you clicking through GA4 dashboards vs Claude having the data: you’ll ask questions you never would have bothered to investigate manually. Claude can query 200+ dimensions and metrics through natural language - the kind of analysis that would take you forever to configure in the actual interface.

READ-ONLY ACCESS The MCP server is read-only, so Claude can look at your data but can’t accidentally break your analytics setup. Just viewing, no modifying.

STEP 1: THE SETUP

GA4 is free, by the way - the paid version (GA4 360) is for enterprises doing $50k+/year. The free tier handles 10 million events per month, which is way more than most of us need.

There’s some Google Cloud console clicking involved - it’s unavoidable for connecting to Google’s APIs. But you do this once and never touch it again.

You can also ask Claude to walk you through this:

I want to set up the GA4 MCP server so you can access my Google Analytics data. Walk me through creating a Google Cloud service account, enabling the right API, and getting my GA4 property ID.

Claude will guide you step by step. But here’s the overview so you know what to expect:

  1. Go to Google Cloud Console
  2. Create a new project (or use an existing one)
  3. Enable the Google Analytics Data API - Go to APIs & Services → Library, search for “Google Analytics Data API”, click Enable, wait a minute or two
  4. Go to IAM & Admin → Service Accounts → Create Service Account
  5. Name it something like claude-analytics
  6. Download the JSON key file

ENABLE THE RIGHT API I enabled the wrong one at first - there are multiple Google Analytics APIs and I picked the old one. You want “Google Analytics Data API” specifically. If you get PERMISSION_DENIED errors later, this is probably why.

STEP 2: GIVE IT ACCESS TO YOUR GA4 PROPERTY

  1. Go to Google Analytics
  2. Admin → Property Access Management
  3. Add your service account email (looks like claude-analytics@your-project.iam.gserviceaccount.com)
  4. Give it “Viewer” role - read-only is all you need

STEP 3: GET YOUR PROPERTY ID

While you’re in GA4 Admin, grab your Property ID. It’s a number like 123456789 - not the measurement ID that starts with G-. I mixed these up at first and got empty results until I realized my mistake.

STEP 4: HAVE CLAUDE CREATE THE MCP CONFIG

Once you have your service account JSON and property ID, ask Claude:

Create an MCP config for Google Analytics in my project. My service account email is [email from the JSON], my private key is [copy from the JSON], and my GA4 property ID is [your number]. Put it in .mcp.json and add that file to .gitignore so I don't accidentally commit my credentials.

Claude will create the config file and protect it from being committed.

PROTECT YOUR KEYS Your .mcp.json contains your private key. If you commit this to a public repo, someone could access your analytics data. I’ve had the API key leak experience and don’t need a repeat.

STEP 5: RESTART CLAUDE TO TEST YOUR MCP

MCP servers only connect when Claude starts, so exit your session and start fresh. Run /mcp to confirm you see google-analytics connected, then ask “How many visitors did I have yesterday?” If you get data, you’re done. If you get “0 visitors” when you know there’s traffic, don’t panic - GA4 data takes 24-48 hours to appear in the API.

WHAT YOU CAN BUILD WITH GA4 MCP

Once Claude has analytics access, you can go beyond one-off questions.

Create a weekly report skill:

Create a Claude Code skill that generates a weekly analytics summary - top pages, traffic sources, and any notable trends. Output it as markdown I can review.

Build content performance checks into your workflow:

Add a command that shows me how my last 5 published posts are performing. Include pageviews, average time on page, and bounce rate.

Automate insight gathering:

Set up a prompt I can run that compares this week's traffic to last week and flags anything unusual - big drops, spikes, or changes in traffic sources.

The point is Claude doesn’t just answer questions - it can build repeatable workflows around your data. Your analytics become part of how you operate instead of a separate thing you check occasionally.

GA4 MCP TROUBLESHOOTING

  • MCP server not connected: .mcp.json needs to be in your project root. Restart Claude Code. Check the private key format - it needs the \n characters preserved.
  • PERMISSION_DENIED: You probably enabled the wrong API. Look for “Google Analytics Data API” specifically.
  • 0 visitors when you know there’s traffic: GA4 data takes 24-48 hours. Make sure you’re using the Property ID (just numbers), not the Measurement ID (starts with G-).
  • Service account can’t access property: Add the service account email to GA4 Property Access Management with Viewer role.