Google Official MCP Setup Link
▶Set Up Guide Using Claude Code
This guide will walk you through setting up the Google Analytics 4 MCP server in Claude Desktop using the Smithery approach.
Time Required: 15-20 minutes Prerequisites: All verified ✅
Step 1: Set Up Google Cloud Service Account
1.1 Access Google Cloud Console
1.2 Create or Select a Project
1.3 Enable Google Analytics Data API
1.4 Create Service Account
- Service account name: Claude-GA4-MCP
- Service account ID: (auto-filled, leave as is)
- Description: Service account for Claude to access GA4 data
1.5 Download Credentials JSON
/Users/ellen/Desktop/agent/GA4_MCP/IMPORTANT: Copy the service account email - you'll need it in the next step!
The email looks like: claude-ga4-mcp@your-project-id.iam.gserviceaccount.com
Step 2: Grant GA4 Access to Service Account
2.1 Access Google Analytics
2.2 Find Your Property ID
2.3 Add Service Account Access
Note: It may take a few minutes for access to propagate.
Step 3: Install MCP Server via Smithery
Now we'll install the MCP server using a single command:
cd /Users/ellen/Desktop/agent/GA4_MCP
npx -y @smithery/cli install mcp-server-google-analytics --client claude
Step 4: Configure Claude Desktop
4.1 Extract Credentials from JSON File
ga4-credentials.json file you downloadedclient_email: This is your GOOGLE_CLIENT_EMAILprivate_key: This is your GOOGLE_PRIVATE_KEY (includes the -----BEGIN PRIVATE KEY----- part)
4.2 Edit Claude Desktop Config
This will open a JSON file in your default text editor.
4.3 Add MCP Server Configuration
Add this configuration to the mcpServers section:
{
"mcpServers": {
"google-analytics": {
"command": "npx",
"args": ["-y", "mcp-server-google-analytics"],
"env": {
"GOOGLE_CLIENT_EMAIL": "paste-your-service-account-email-here",
"GOOGLE_PRIVATE_KEY": "paste-your-private-key-here-including-begin-and-end-lines",
"GA_PROPERTY_ID": "paste-your-property-id-here"
}
}
}
}
IMPORTANT NOTES:
GOOGLE_PRIVATE_KEY should include ----BEGIN PRIVATE KEY----- and ----END PRIVATE KEY-----\\n characters in the private key as they are4.4 Save and Restart
Step 5: Test Your Setup
Once Claude Desktop reopens, try these test queries:
Basic Test:
Show me page views for the last 7 days
Traffic Analysis:
What are my top 10 pages by traffic this month?
Device Comparison:
Compare mobile vs desktop traffic for the last 30 days
If you see Claude accessing the Google Analytics tools and returning data, congratulations! Your setup is complete!
Troubleshooting
Claude doesn't show the MCP server
node --version to verify Node.js is installedAuthentication errors
\\n for line breaksNo data returned
Example Queries to Try
Once everything is working, try these queries:
Basic Metrics:
Custom Analysis:
Event Analysis:
Additional Resources
While the guide appears complex, Claude Code performs the implementation. Your only task is providing the credentials.