How to Set Up Google Analytics MCP with TeamDay
📊

Set Up Google Analytics MCP

Step-by-step guide with TeamDay AI automation

Google AnalyticsMCPSetup GuideAI AutomationGoogle Cloud

How to Set Up Google Analytics MCP with TeamDay (Complete Guide)

By JozoFebruary 19, 20268 min read

Google Analytics MCP connects your AI agents directly to your analytics data. Instead of switching between dashboards and chat windows, you can ask your AI assistant questions like "What was my traffic last month?" or "Which pages have the highest bounce rate?" and get instant answers from live data.

The problem? Setting it up requires navigating Google Cloud Console, creating service accounts, enabling APIs, and configuring credentials across multiple interfaces. We walked through every step ourselves and documented exactly what works, what breaks, and how TeamDay's AI agent can automate most of the process for you.

What is MCP and Why Does It Matter?

MCP (Model Context Protocol) is an open standard that lets AI assistants connect to external tools and data sources. Think of it as USB for AI — a universal way to plug real-world services into your AI conversations.

💬

Without MCP

Open Google Analytics → find the report → export data → paste into chat → ask AI to analyze

With MCP

Ask your AI: "What's my traffic trend this month?" → AI queries Google Analytics directly → instant answer

🤖

With TeamDay

AI agent monitors analytics automatically, generates reports, spots anomalies, and suggests optimizations — on schedule

The Google Analytics MCP server (built by Google) gives your AI access to 6 tools: account summaries, property details, custom dimensions, standard reports, realtime reports, and Google Ads link data.

What You Need Before Starting

  • A Google Analytics 4 property — with the tracking tag installed on your website (GA4, not Universal Analytics)
  • A Google Cloud project — free to create at console.cloud.google.com
  • Admin access to both your Google Cloud project and Google Analytics property
  • A TeamDay accountsign up free

Don't have GA4 tracking installed yet? Make sure your website has the GA4 measurement tag (G-XXXXXXXXXX) before setting up the MCP. The connection will work without it, but you'll get zero data — we learned this the hard way during testing.

Setup Guide: 5 Steps to Connect Google Analytics

We tested every step on a real site. Here's exactly what to do, including the pitfall that trips up most people (Step 4).

1

Enable Google Analytics APIs

Go to your Google Cloud project and enable two specific APIs. There are hundreds of Google APIs — you need exactly these two:

# In Google Cloud Console > APIs & Services > Library
Google Analytics Admin API
Google Analytics Data API

Or if you have gcloud CLI installed, your TeamDay agent can run this command for you:

$ gcloud services enable analyticsadmin.googleapis.com \
  analyticsdata.googleapis.com --project=YOUR_PROJECT_ID

TeamDay automation: Your AI agent can run this command directly in the chat terminal. Just tell it your project ID and it handles the rest.

2

Create a Service Account

A service account is a special Google identity for machines (not humans). Your AI agent will use this identity to read your analytics data.

  1. Go to IAM & Admin > Service Accounts in Google Cloud Console
  2. Click Create Service Account
  3. Name it something descriptive: teamday-analytics-reader
  4. Skip the optional role assignment (permissions are set in Google Analytics, not here)
  5. Click Done

Or with gcloud:

$ gcloud iam service-accounts create teamday-analytics-reader \
  --display-name="TeamDay Analytics Reader" \
  --project=YOUR_PROJECT_ID
3

Download the JSON Key

The JSON key file is your service account's credential. It's what TeamDay will use to authenticate with Google Analytics on your behalf.

  1. Click on your new service account in the list
  2. Go to the Keys tab
  3. Click Add Key > Create New Key
  4. Choose JSON format
  5. Click Create — the file downloads automatically
$ gcloud iam service-accounts keys create ~/ga-key.json \
  --iam-account=teamday-analytics-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com \
  --project=YOUR_PROJECT_ID

The downloaded JSON file looks like this (your values will be different):

{
  "type": "service_account",
  "project_id": "your-project-id",
  "private_key_id": "abc123...",
  "private_key": "-----BEGIN PRIVATE KEY-----\n...",
  "client_email": "teamday-analytics-reader@your-project.iam.gserviceaccount.com",
  ...
}

Keep this file safe. It contains a private key that grants access to your analytics data. Never commit it to a public repository.

4

Grant the Service Account Access to Google Analytics

⚠ This is the step most people miss

Creating a service account in Google Cloud does not automatically give it access to Google Analytics. These are two completely separate permission systems. Without this step, everything will appear to work but return zero data.

  1. Go to analytics.google.com
  2. Select your property (the website you want to analyze)
  3. Click Admin (gear icon, bottom left)
  4. Under your property, find Property Access Management
  5. Click the blue + button → Add users
  6. Paste the service account email: teamday-analytics-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com
  7. Set role to Viewer (read-only is sufficient)
  8. Click Add

You can find the exact email address in your JSON key file — it's the client_email field. Your TeamDay agent can extract and display it for you.

5

Add Credentials to TeamDay

Now connect everything in TeamDay:

  1. Open your Space in TeamDay
  2. Go to IntegrationsAdd MCP
  3. Select Google Analytics from the library
  4. Service Account JSON — paste the entire contents of the JSON key file you downloaded
  5. Google Cloud Project ID — enter your project ID (also visible as project_id in the JSON file)
  6. Click Create & Add to Space

TeamDay encrypts your credentials with AES-256 before storing them. The raw JSON key is never stored in plain text.

Let Your AI Agent Do the Heavy Lifting

Here's where TeamDay changes the game. Instead of manually navigating Google Cloud Console, you can ask your AI agent to handle Steps 1-3 directly in the chat.

TeamDay runs Claude Code in a sandbox environment with access to command-line tools — including gcloud CLI. This means your agent can execute the setup commands programmatically.

You:
Help me set up Google Analytics MCP. My GCP project is "my-project-123".
Claude:
I'll set up the Google Analytics MCP for you. Let me:
1. Enable the required APIs...
> gcloud services enable analyticsadmin.googleapis.com analyticsdata.googleapis.com
2. Create a service account...
> gcloud iam service-accounts create teamday-analytics-reader
3. Generate the JSON key...
> gcloud iam service-accounts keys create /tmp/ga-key.json
Done! Now I need you to do one manual step:
Go to Google Analytics > Admin > Property Access Management
and add this email as Viewer:
teamday-analytics-reader@my-project-123.iam.gserviceaccount.com

What the Agent Automates

  • Enable Google Analytics APIs
  • Create service account
  • Generate and download JSON key
  • Configure MCP credentials
  • Test the connection

What You Do Manually

  • Authenticate with gcloud auth login
  • Add service account email to GA4 Property Access Management (no API exists for this)

Google provides no API for managing GA4 property access, so this step requires the web UI.

4 out of 6 setup steps are fully automatable. The agent handles all the technical work — you just need to grant permission in one Google interface and confirm you're done.

What You Can Do After Setup

Once the MCP is connected, your AI agent has direct access to your Google Analytics data. Here are real examples of what you can ask:

Traffic Analysis

"What was my total traffic last month? How does it compare to the same month last year?"

Page Performance

"Which pages have the highest bounce rate? What are my top 10 most visited pages?"

User Behavior

"What's the average session duration by traffic source? Where are my visitors coming from?"

Realtime Monitoring

"How many users are on my site right now? What pages are they viewing?"

Scheduled Reports

Set up a TeamDay Mission to generate weekly traffic reports automatically. Your agent pulls the data, analyzes trends, and delivers a summary — every Monday morning.

Combine with Other Integrations

The real power shows when you combine Google Analytics with other MCP servers in TeamDay — like Search Console for SEO data or Ahrefs for competitive analysis. Your agent can cross-reference traffic data with keyword rankings and backlink profiles for a complete picture of your website's performance.

Common Pitfalls and Troubleshooting

"Connection works but returns zero data"

Cause: You skipped Step 4 (adding the service account to GA4 Property Access Management), or your website doesn't have the GA4 tracking tag installed.

Fix: Check that the service account email appears in your GA4 property's access list. Verify your website has the gtag.js script with your measurement ID.

"Permission denied" when enabling APIs

Cause: You're authenticated with the wrong Google account. The account must be an Owner or Editor on the GCP project.

Fix: Run gcloud auth list to see which account is active. Switch with gcloud config set account your@email.com

"API not enabled" errors

Cause: Only one of the two required APIs was enabled, or they were enabled on the wrong project.

Fix: Verify both analyticsadmin.googleapis.com and analyticsdata.googleapis.com are enabled on the same project where your service account lives.

"Wrong account" confusion

Cause: Google Cloud project is owned by one Google account, but GA4 property is under a different account.

Fix: The service account is not tied to your personal Google login. You can create it under any GCP project, then add its email to any GA4 property you have admin access to — they don't need to be under the same Google account.

Quick Reference: All Commands

For reference, here are all the CLI commands in one place. Replace YOUR_PROJECT_ID with your actual Google Cloud project ID.

# Step 1: Enable APIs
gcloud services enable analyticsadmin.googleapis.com analyticsdata.googleapis.com \ --project=YOUR_PROJECT_ID
# Step 2: Create service account
gcloud iam service-accounts create teamday-analytics-reader \ --display-name="TeamDay Analytics Reader" \ --project=YOUR_PROJECT_ID
# Step 3: Download JSON key
gcloud iam service-accounts keys create ~/ga-key.json \ --iam-account=teamday-analytics-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com \ --project=YOUR_PROJECT_ID
# Step 4: (Manual) Add this email to GA4 Property Access Management as Viewer:
teamday-analytics-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com
# Step 5: Paste contents of ~/ga-key.json into TeamDay MCP setup
cat ~/ga-key.json

Ready to Connect Your Analytics?

TeamDay gives your AI agent direct access to Google Analytics, Search Console, Ahrefs, and more. Set up once, query forever.

Try TeamDay Free

No credit card required. Includes Google Analytics MCP.