4
min read
Overview
The Google Analytics 4 (GA4) MCP (Model Context Protocol) tools provides seamless access to your website and app performance data. This server enables you to retrieve detailed insights about user behavior, traffic sources, conversions, and much more through Google Analytics 4's powerful reporting API.
Key Benefits:
Complete Analytics Access: Connect to all your GA4 properties and retrieve comprehensive performance data
Real-time Insights: Access up-to-date user behavior, traffic, and conversion metrics
Advanced Analysis: Perform funnel analysis, cohort studies, and custom reporting
Flexible Reporting: Create custom reports with any combination of dimensions and metrics
Multi-Property Management: Manage and analyze multiple GA4 properties from a single interface
Tool Reference
1. List Analytics Properties
Purpose: Discover and access all Google Analytics 4 properties available to your account.
What it does: Retrieves a complete hierarchical structure showing all your Google Analytics accounts and their associated GA4 properties, including property IDs needed for reporting.
Key Parameters:
account_id (optional): Specific GA account to list properties for
Property Information Retrieved:
Property ID (required for all other tools)
Display name and type
Time zone and currency settings
Industry category
Creation date
Sample Use Cases:
Initial setup to discover available properties
Property access verification
Multi-account management
Example Request:
Example Output:
2. Get Active Users
Purpose: Monitor current user engagement and activity levels on your website or app.
What it does: Retrieves active user metrics and new user counts for any specified date range, helping you understand your audience growth and engagement patterns.
Key Parameters:
property_id (required): GA4 property ID (e.g., "987654321")
start_date (required): Start date in YYYY-MM-DD format
end_date (required): End date in YYYY-MM-DD format
Metrics Retrieved:
Active Users: Users who had an engaged session or event
New Users: First-time visitors to your site/app
Sample Use Cases:
Daily user activity monitoring
Growth tracking and trend analysis
User acquisition performance
Audience engagement assessment
Example Request:
Example Output:
3. Get Page Views
Purpose: Analyze which pages are most popular and how users navigate through your website.
What it does: Retrieves detailed page view metrics, allowing you to understand content performance and user navigation patterns across your website.
Key Parameters:
property_id (required): GA4 property ID
start_date (required): Start date in YYYY-MM-DD format
end_date (required): End date in YYYY-MM-DD format
dimensions (optional): Additional dimensions for grouping (defaults to pagePath)
Available Dimensions:
pagePath
: URL path of the pagepageTitle
: Title of the pagecountry
: User's countrydeviceCategory
: Desktop, mobile, tablet
Sample Use Cases:
Content performance analysis
Popular page identification
Navigation pattern analysis
Geographic content preferences
Example Request:
Example Output:
4. Get Traffic Sources
Purpose: Understand how users discover and arrive at your website.
What it does: Provides comprehensive traffic source analysis showing which channels, sources, and mediums drive the most valuable traffic to your site.
Key Parameters:
property_id (required): GA4 property ID
start_date (required): Start date in YYYY-MM-DD format
end_date (required): End date in YYYY-MM-DD format
Traffic Data Retrieved:
Session Source: Specific source (google, facebook, newsletter)
Session Medium: Traffic medium (organic, cpc, email, social)
Sessions: Number of sessions from each source
Total Users: Unique users from each source
Page Views: Total page views generated
Sample Use Cases:
Marketing channel effectiveness
Traffic source optimization
Campaign performance analysis
Budget allocation decisions
Example Request:
Example Output:
5. Get Device Metrics
Purpose: Analyze user device preferences and optimize experiences for different platforms.
What it does: Provides detailed insights into the devices and browsers your users prefer, helping you prioritize development and design efforts.
Key Parameters:
property_id (required): GA4 property ID
start_date (required): Start date in YYYY-MM-DD format
end_date (required): End date in YYYY-MM-DD format
Device Data Retrieved:
Device Category: Desktop, mobile, tablet
Browser: Chrome, Safari, Firefox, etc.
Sessions: Sessions per device/browser combination
Total Users: Unique users per device type
Page Views: Total page views per device
Sample Use Cases:
Mobile optimization prioritization
Browser compatibility planning
User experience optimization
Technical requirements planning
Example Request:
Example Output:
6. Get User Behavior
Purpose: Understand how users interact with your website and identify engagement patterns.
What it does: Retrieves key behavioral metrics that help you understand user engagement quality, session depth, and overall site stickiness.
Key Parameters:
property_id (required): GA4 property ID
start_date (required): Start date in YYYY-MM-DD format
end_date (required): End date in YYYY-MM-DD format
Behavior Metrics Retrieved:
Average Session Duration: How long users spend on your site
Bounce Rate: Percentage of single-page sessions
Sessions Per User: How frequently users return
Sample Use Cases:
Content engagement analysis
User experience optimization
Site stickiness assessment
Content strategy development
Example Request:
Example Output:
7. Get Events
Purpose: Track and analyze specific user actions and interactions on your website or app.
What it does: Provides detailed event tracking data, allowing you to measure user engagement with specific features, content, or conversion points.
Key Parameters:
property_id (required): GA4 property ID
start_date (required): Start date in YYYY-MM-DD format
end_date (required): End date in YYYY-MM-DD format
event_name (optional): Filter for specific events
Event Data Retrieved:
Event Name: Name of the tracked event
Event Count: Number of times the event occurred
Date: When events occurred
Common GA4 Events:
page_view
: Page viewsclick
: Button/link clicksscroll
: Page scrollingfile_download
: File downloadsform_start
: Form interactionspurchase
: E-commerce transactionssign_up
: User registrations
Sample Use Cases:
Conversion tracking
Feature usage analysis
User engagement measurement
A/B testing analysis
Example Request:
Example Output:
8. Run Custom Report
Purpose: Create fully customized analytics reports with any combination of metrics and dimensions.
What it does: Provides maximum flexibility for creating tailored reports that meet your specific analysis needs, supporting all GA4 metrics and dimensions.
Key Parameters:
property_id (required): GA4 property ID
start_date (required): Start date in YYYY-MM-DD format
end_date (required): End date in YYYY-MM-DD format
metrics (required): Array of metric names
dimensions (optional): Array of dimension names
limit (optional): Maximum rows to return
order_bys (optional): Sorting configuration
Popular Metrics:
sessions
,totalUsers
,activeUsers
,newUsers
screenPageViews
,bounceRate
,engagementRate
averageSessionDuration
,userEngagementDuration
conversions
,totalRevenue
,purchaseRevenue
eventCount
,eventsPerSession
Popular Dimensions:
country
,city
,region
,continent
deviceCategory
,operatingSystem
,browser
source
,medium
,campaignName
,sessionDefaultChannelGroup
pagePath
,pageTitle
,landingPage
date
,month
,year
,hour
,dayOfWeek
Sample Use Cases:
Executive dashboard creation
Custom KPI tracking
Advanced segmentation analysis
Performance benchmarking
Example Request:
Example Output:
9. Run Funnel Analysis
Purpose: Analyze user progression through multi-step processes to identify conversion bottlenecks.
What it does: Provides advanced funnel analysis showing how users move through defined steps (like a purchase process), revealing drop-off points and conversion rates between each step.
Key Parameters:
property_id (required): GA4 property ID
start_date (required): Start date in YYYY-MM-DD format
end_date (required): End date in YYYY-MM-DD format
funnel_steps (required): Array of funnel step definitions (minimum 2 steps)
breakdown_dimension (optional): Segment funnel by dimension
Funnel Step Types:
Event-based: Filter by specific events (recommended)
Field-based: Filter by dimension values
Mixed: Combine both approaches
Common Funnel Examples:
E-commerce: Product view → Add to cart → Checkout → Purchase
Lead Generation: Landing page → Form start → Form submit → Thank you
Content: Article view → Scroll 50% → Newsletter signup
SaaS: Signup → Onboarding → First feature use → Upgrade
Sample Use Cases:
Conversion optimization
User journey analysis
A/B testing impact measurement
Process improvement identification
Example Request:
Example Output:
Getting Started
Prerequisites
Active Google Analytics 4 property
Google Cloud Console project with Analytics API enabled
Valid OAuth2 credentials with appropriate scopes
Admin access to GA4 properties you want to analyze
Google Analytics MCP Tools
Basic Workflow
Discovery: Start with "List Analytics Properties" to find your property IDs
Overview Analysis: Use "Get Active Users" for high-level traffic trends
Traffic Analysis: Examine sources with "Get Traffic Sources"
Content Analysis: Review page performance with "Get Page Views"
Behavior Analysis: Understand engagement with "Get User Behavior"
Advanced Analysis: Create custom reports or funnel analysis
Event Tracking: Monitor specific actions with "Get Events"
Common Analysis Workflows
Daily Monitoring Dashboard:
Get Active Users for daily traffic trends
Get Traffic Sources for channel performance
Get User Behavior for engagement quality
Get Events for conversion tracking
Content Performance Analysis:
Get Page Views by page path
Get User Behavior for engagement metrics
Run Custom Report with content dimensions
Get Device Metrics for optimization priorities
Conversion Optimization:
Run Funnel Analysis for process optimization
Get Events for specific conversion actions
Run Custom Report with conversion metrics
Get Traffic Sources for channel attribution
Best Practices
Data Retrieval
Use appropriate date ranges: GA4 data is typically available with a 24-48 hour delay
Start with standard reports: Use predefined tools before creating custom reports
Limit data scope: Use date ranges and filters to focus on relevant data
Understand GA4 metrics: Some metrics differ from Universal Analytics
Performance Optimization
Batch related requests: Group similar analysis into single custom reports
Use appropriate limits: Set reasonable row limits for large datasets
Cache frequently used data: Store commonly accessed metrics locally
Monitor API quotas: Be aware of GA4 API rate limits
Analysis Strategy
Start with questions: Define what you want to learn before choosing tools
Use funnel analysis: Understand user journeys and conversion paths
Segment your data: Use dimensions to understand different user groups
Compare time periods: Look at trends rather than single points in time
Common Pitfalls to Avoid
Metric confusion: Ensure you're using GA4 metrics (not Universal Analytics)
Property ID errors: Double-check property IDs are correct
Date format issues: Always use YYYY-MM-DD format for dates
Dimension limitations: Some dimensions can't be combined in reports
Troubleshooting
Common Error Messages
"No data found for property"
Verify property ID is correct and accessible
Check date range (data may not be available for recent dates)
Ensure property has tracking data for the specified period
"Google Analytics API error: 403"
Check OAuth2 credentials and scopes
Verify access to the specified property
Ensure Analytics API is enabled in Google Cloud Console
"Invalid metric/dimension name"
Use GA4 metric names (not Universal Analytics)
Check spelling and formatting of metric/dimension names
Refer to GA4 API documentation for valid names
Data Quality Issues
Missing Recent Data:
GA4 data typically has 24-48 hour processing delay
Use earlier date ranges for complete data
Unexpected Metric Values:
Understand GA4 vs Universal Analytics metric differences
Check for data filters or sampling
Verify property configuration and tracking setup
Empty Results:
Check if property has data for the specified time period
Verify tracking implementation
Review any applied filters or segments
Performance Issues
Slow Response Times:
Reduce date range scope
Limit number of dimensions
Use appropriate row limits
Consider breaking large requests into smaller chunks
API Rate Limits:
Implement request spacing
Use caching for frequently accessed data
Optimize query efficiency