### Install google-analytics-mcp via pip Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Installs the `google-analytics-mcp` Python package using pip, the recommended method for quick setup. ```bash pip install google-analytics-mcp ``` -------------------------------- ### Install google-analytics-mcp via GitHub Clone Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Clones the `google-analytics-mcp` repository from GitHub, navigates into the directory, sets up a Python virtual environment, activates it, and installs required dependencies from `requirements.txt`. ```bash git clone https://github.com/surendranb/google-analytics-mcp.git cd google-analytics-mcp python3 -m venv venv source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### User-level installation for permission errors Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md This command demonstrates installing the `google-analytics-mcp` Python package using `pip` with the `--user` flag. This approach is recommended to circumvent system-wide permission errors by installing the package into the current user's home directory. ```bash pip install --user google-analytics-mcp ``` -------------------------------- ### Example Query: Content Performance Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Provides an example of a natural language query for content analysis, trend analysis, engagement metrics, and ranking/sorting. ```Query What are my top 10 pages by engagement rate, and how has their performance changed over the last 3 months? ``` -------------------------------- ### Install Google Analytics Data Library Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Installs the `google-analytics-data` Python library, which is necessary for interacting with the Google Analytics Data API. This step is a prerequisite for testing GA4 credentials. ```bash pip install google-analytics-data ``` -------------------------------- ### Example Query: User Behavior Analysis Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Illustrates a natural language query for multi-dimensional analysis, time series comparison, user engagement metrics, and technology segmentation. ```Query Compare average session duration and pages per session by device category and browser over the last 90 days ``` -------------------------------- ### Example Query: Traffic Source Performance Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Shows a query for marketing performance analysis, period-over-period comparison, conversion tracking, and revenue attribution using natural language. ```Query Show me conversion rates and revenue by traffic source and campaign, comparing last 30 days vs previous 30 days ``` -------------------------------- ### Install google-analytics-mcp to fix 'No module named' error Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md This command installs the `google-analytics-mcp` Python package using `pip3` with the `--user` flag. This resolves the 'No module named ga4_mcp_server' error by installing the package in the user's local environment, avoiding system-wide permission issues. ```bash pip3 install --user google-analytics-mcp ``` -------------------------------- ### MCP Server Configuration for GitHub Installation Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md JSON configuration for the MCP server when installed via GitHub, specifying the full path to the Python executable within the virtual environment and the server script, along with GA4 credentials and property ID. ```json { "mcpServers": { "ga4-analytics": { "command": "/full/path/to/ga4-mcp-server/venv/bin/python", "args": ["/full/path/to/ga4-mcp-server/ga4_mcp_server.py"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json", "GA4_PROPERTY_ID": "123456789" } } } } ``` -------------------------------- ### Check Python and pip versions Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Verifies the installed Python version (3.10+) and pip package manager. This is a crucial prerequisite for installing and running the Google Analytics MCP server. ```bash python --version python3 --version pip --version pip3 --version ``` -------------------------------- ### Example Query: Geographic Distribution Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Demonstrates how to query for geographic analysis, user segmentation, time-based filtering, and data visualization using natural language. ```Query Show me a map of visitors by city for the last 30 days, with a breakdown of new vs returning users ``` -------------------------------- ### GA4 Metric Categories Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Categorizes and lists common Google Analytics 4 metrics available for data analysis, providing examples for each category. ```APIDOC User Metrics: totalUsers, newUsers, activeUsers Session Metrics: sessions, bounceRate, engagementRate E-commerce: totalRevenue, transactions, conversions Events: eventCount, conversions, event values Advertising: adRevenue, returnOnAdSpend And more specialized metrics ``` -------------------------------- ### Test Google Analytics 4 Credentials Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md A Python script to verify the correct setup of Google Analytics 4 service account credentials. It attempts to initialize the BetaAnalyticsDataClient using the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Ensure the service account key JSON file path is correctly set before running. ```python import os from google.analytics.data_v1beta import BetaAnalyticsDataClient # Set credentials path os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/path/to/your/service-account-key.json" # Test connection client = BetaAnalyticsDataClient() print("✅ GA4 credentials working!") ``` -------------------------------- ### GA4 Dimension Categories Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Categorizes and lists common Google Analytics 4 dimensions available for data analysis, providing examples for each category. ```APIDOC Time: date, hour, month, year, etc. Geography: country, city, region Technology: browser, device, operating system Traffic Source: campaign, source, medium, channel groups Content: page paths, titles, content groups E-commerce: item details, transaction info User Demographics: age, gender, language Google Ads: campaign, ad group, keyword data And 10+ more categories ``` -------------------------------- ### Overview of google-analytics-mcp Project Structure Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md This section illustrates the hierarchical file and directory layout of the `google-analytics-mcp` project. It highlights key components such as the main server script, configuration files for GA4 dimensions and metrics, dependency lists, and documentation. ```plaintext google-analytics-mcp/ ├── ga4_mcp_server.py # Main MCP server ├── ga4_dimensions.json # All available GA4 dimensions ├── ga4_metrics.json # All available GA4 metrics ├── requirements.txt # Python dependencies ├── pyproject.toml # Package configuration ├── README.md # This file └── claude-config-template.json # MCP configuration template ``` -------------------------------- ### MCP Server Available Tools Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Lists the five main tools provided by the MCP server for interacting with Google Analytics 4 data, along with their primary functions. ```APIDOC get_ga4_data: Retrieve GA4 data with custom dimensions and metrics list_dimension_categories: Browse available dimension categories list_metric_categories: Browse available metric categories get_dimensions_by_category: Get dimensions for a specific category get_metrics_by_category: Get metrics for a specific category ``` -------------------------------- ### Run GA4 Credentials Test Script Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Executes the `test_ga4.py` Python script to confirm that the Google Analytics 4 credentials are correctly configured and accessible. A successful run will print '✅ GA4 credentials working!'. ```bash python test_ga4.py ``` -------------------------------- ### MCP Server Configuration for Python Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md JSON configuration for the MCP server, specifying `python` as the command, module arguments, and environment variables for Google Analytics 4 (GA4) credentials and property ID. Use this if `python --version` works. ```json { "mcpServers": { "ga4-analytics": { "command": "python", "args": ["-m", "ga4_mcp_server"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json", "GA4_PROPERTY_ID": "123456789" } } } } ``` -------------------------------- ### MCP Server Configuration for Python 3 Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md JSON configuration for the MCP server, specifying `python3` as the command, module arguments, and environment variables for Google Analytics 4 (GA4) credentials and property ID. Use this if `python3 --version` works. ```json { "mcpServers": { "ga4-analytics": { "command": "python3", "args": ["-m", "ga4_mcp_server"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json", "GA4_PROPERTY_ID": "123456789" } } } } ``` -------------------------------- ### Check Python Executable Version Source: https://github.com/surendranb/google-analytics-mcp/blob/main/README.md Verifies the available Python executable by checking both `python3` and `python` commands to determine which one is active on the system for subsequent configuration. ```bash python3 --version python --version ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.