google-analytics-mcp-server
v1.1.1
Published
Model Context Protocol server for Google Analytics - query reports, manage properties, configure data filters, and analyze website performance
Maintainers
Readme
Google Analytics MCP Server
A Model Context Protocol (MCP) server that provides AI assistants with direct access to Google Analytics APIs. This server enables natural language interactions to query reports, manage properties, configure data filters, and analyze website performance.
🚀 Quick Install
NPX (Recommended - No Installation Required)
# Authenticate with Google
npx mcp-google-analytics auth
# Check authentication status
npx mcp-google-analytics status
# Setup Claude Desktop configuration
npx mcp-google-analytics initGlobal Installation
# Install globally for repeated use
npm install -g mcp-google-analytics
# Authenticate with Google
mcp-google-analytics auth
# Check status
mcp-google-analytics status
# Setup Claude Desktop
mcp-google-analytics initRestart Claude Desktop after setup.
✨ New: Use with NPX - no installation required! Just run npx mcp-google-analytics directly.
✨ Features
📊 Reporting Tools
run_report- Query historical Analytics data with custom dimensions, metrics, date ranges, and filtersrun_realtime_report- Get real-time Analytics data for active users, events, and current activityget_metadata- Discover available dimensions and metrics for a property (essential for report building)run_audience_export- Export audience data for analysis
🛠️ Admin Tools
get_account_summaries- List all Google Analytics accounts and propertiesget_property_details- Get detailed information about a specific propertyget_custom_dimensions_and_metrics- Retrieve custom dimensions and metrics for a propertylist_google_ads_links- List links between Analytics properties and Google Ads accounts
🔍 Data Filter Management
list_data_filters- List all data filters for a propertyget_data_filter- Get details of a specific data filtercreate_data_filter- Create new data filters (internal traffic, developer traffic)update_data_filter- Update existing data filtersdelete_data_filter- Delete data filters
📡 Data Streams Management
list_data_streams- List all data streams (web, iOS, Android) for a propertyget_data_stream- Get details of a specific data streamlist_measurement_protocol_secrets- List Measurement Protocol API secretscreate_measurement_protocol_secret- Create a new Measurement Protocol secretdelete_measurement_protocol_secret- Delete a Measurement Protocol secret
🎯 Conversion Events Management
list_conversion_events- List all conversion events for a propertyget_conversion_event- Get details of a specific conversion eventcreate_conversion_event- Create a new conversion event (track key actions)delete_conversion_event- Delete a conversion event
👥 Audiences Management
list_audiences- List all audiences (user segments) for a propertyget_audience- Get details of a specific audiencecreate_audience- Create a new audience based on filter expressionsarchive_audience- Archive (soft delete) an audience
📏 Custom Definitions Management
create_custom_dimension- Create a new custom dimensionupdate_custom_dimension- Update an existing custom dimensionarchive_custom_dimension- Archive a custom dimensioncreate_custom_metric- Create a new custom metricupdate_custom_metric- Update an existing custom metricarchive_custom_metric- Archive a custom metric
🔑 Authentication
The server supports two authentication methods:
Method 1: OAuth2 (Recommended for Personal Use)
- Get OAuth2 credentials from Google Cloud Console
- Set environment variables:
export GOOGLE_CLIENT_ID="your-client-id" export GOOGLE_CLIENT_SECRET="your-client-secret" - Run authentication:
npx mcp-google-analytics auth
Method 2: Application Default Credentials (ADC)
- Run gcloud authentication:
gcloud auth application-default login \ --scopes=https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/analytics.edit - Set quota project:
gcloud auth application-default set-quota-project YOUR_PROJECT_ID - Set environment variable (optional):
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json"
📖 Usage Examples
Query Analytics Reports
Get the top 10 pages by page views for the last 30 daysAnalyze User Behavior
Show me the most popular events in my Analytics property in the last 180 daysManage Data Filters
Create a data filter to exclude Playwright automation trafficDiscover Available Metrics
Get metadata for my property to see what dimensions and metrics are availableManage Conversion Events
List all conversion events for my property
Create a new conversion event for 'purchase' eventsManage Data Streams
List all data streams for my property
Create a Measurement Protocol secret for server-side trackingGet Property Information
Give me details about my Google Analytics property with 'Handi' in the name🛠️ Development
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run tests
npm test📄 License
MIT License - see LICENSE file for details.
🤝 Contributing
Contributions welcome! Please open an issue to discuss bugs or feature requests.
