How to Set Up Google Analytics MCP with TeamDay (Complete Guide)
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 account — sign 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).
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:
Or if you have gcloud CLI installed, your TeamDay agent can run this command for you:
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.
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.
- Go to IAM & Admin > Service Accounts in Google Cloud Console
- Click Create Service Account
- Name it something descriptive:
teamday-analytics-reader - Skip the optional role assignment (permissions are set in Google Analytics, not here)
- Click Done
Or with gcloud:
--display-name="TeamDay Analytics Reader" \
--project=YOUR_PROJECT_ID
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.
- Click on your new service account in the list
- Go to the Keys tab
- Click Add Key > Create New Key
- Choose JSON format
- Click Create — the file downloads automatically
--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": "[email protected]",
...
}Keep this file safe. It contains a private key that grants access to your analytics data. Never commit it to a public repository.
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.
- Go to analytics.google.com
- Select your property (the website you want to analyze)
- Click Admin (gear icon, bottom left)
- Under your property, find Property Access Management
- Click the blue + button → Add users
- Paste the service account email:
teamday-analytics-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com - Set role to Viewer (read-only is sufficient)
- 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.
Add Credentials to TeamDay
Now connect everything in TeamDay:
- Open your Space in TeamDay
- Go to Integrations → Add MCP
- Select Google Analytics from the library
- Service Account JSON — paste the entire contents of the JSON key file you downloaded
- Google Cloud Project ID — enter your project ID (also visible as
project_idin the JSON file) - 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.
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 [email protected]
"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.
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 FreeNo credit card required. Includes Google Analytics MCP.
