mcp-server-google-analytics

by ruchernchong

Integrations

  • Provides access to Google Analytics 4 (GA4) data, allowing retrieval of page view metrics, active and new user tracking, event analysis, and user behavior metrics (session duration, bounce rate) with customizable dimensions and date ranges.

Google Analytics MCP Server

An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.

Features

  • Get page view metrics with customizable dimensions
  • Track active and new users over time
  • Analyze specific events and their metrics
  • Monitor user behavior metrics (session duration, bounce rate)
  • Flexible date range selection for all queries

Prerequisites

  • Node.js 20 or higher
  • Google Analytics 4 property
  • Google Cloud project with Analytics Data API enabled
  • Service account credentials with appropriate permissions

Setup

  1. Create a Google Cloud project and enable the Analytics Data API
  2. Create a service account and download the credentials JSON file
  3. Grant the service account appropriate access to your GA4 property
  4. Set up environment variables:
export GOOGLE_CLIENT_EMAIL="your-service-account@project.iam.gserviceaccount.com" export GOOGLE_PRIVATE_KEY="your-private-key" export GA_PROPERTY_ID="your-ga4-property-id"

Installation

Installing via Smithery

To install Google Analytics Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install mcp-server-google-analytics --client claude

Manual Installation

pnpm install mcp-server-google-analytics

Usage

Starting the Server

pnpm start

Configuration in Claude Desktop

Add this to your Claude Desktop configuration:

{ "mcpServers": { "google-analytics": { "command": "npx", "args": ["-y", "mcp-server-google-analytics"], "env": { "GOOGLE_CLIENT_EMAIL": "your-service-account@project.iam.gserviceaccount.com", "GOOGLE_PRIVATE_KEY": "your-private-key", "GA_PROPERTY_ID": "your-ga4-property-id" } } } }

Available Functions

getPageViews

Get page view metrics for a specific date range:

{ "startDate": "2024-01-01", "endDate": "2024-01-31", "dimensions": ["page", "country"] // Optional }

getActiveUsers

Get active users metrics:

{ "startDate": "2024-01-01", "endDate": "2024-01-31" }

getEvents

Get event metrics:

{ "startDate": "2024-01-01", "endDate": "2024-01-31", "eventName": "purchase" // Optional }

getUserBehavior

Get user behavior metrics:

{ "startDate": "2024-01-01", "endDate": "2024-01-31" }

Security Considerations

  • Always use environment variables for sensitive credentials
  • Implement appropriate CORS settings
  • Follow the principle of least privilege when setting up service account permissions
  • Regularly rotate service account credentials
  • Monitor API usage and implement rate limiting if needed

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.

  1. Features
    1. Prerequisites
      1. Setup
        1. Installation
          1. Installing via Smithery
          2. Manual Installation
        2. Usage
          1. Starting the Server
          2. Configuration in Claude Desktop
        3. Available Functions
          1. getPageViews
          2. getActiveUsers
          3. getEvents
          4. getUserBehavior
        4. Security Considerations
          1. Contributing
            1. License

              Related MCP Servers

              • -
                security
                F
                license
                -
                quality
                A specialized Model Context Protocol (MCP) server that integrates Google services (Gmail, Calendar, etc.) into your AI workflows. This server enables seamless access to Google services through MCP, allowing AI agents to interact with Gmail, Google Calendar, and other Google services.
                Last updated -
                10
                3
                TypeScript
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that connects to Google Cloud services, allowing users to query logs, interact with Spanner databases, and analyze Cloud Monitoring metrics through natural language interaction.
                Last updated -
                16
                2
                TypeScript
              • -
                security
                F
                license
                -
                quality
                A TypeScript framework for building Model Context Protocol (MCP) servers with automatic discovery and loading of tools, resources, and prompts.
                Last updated -
                67
                TypeScript
                • Apple
              • -
                security
                F
                license
                -
                quality
                Provides an interface to access Google Analytics Data API through Model Context Protocol (MCP), allowing users to retrieve reports and realtime data from Google Analytics 4 properties.
                Last updated -
                JavaScript

              View all related MCP servers

              ID: tx0ccdzxeh