PHPackages                             magebitcom/magento2-mcp-google-analytics-tools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. magebitcom/magento2-mcp-google-analytics-tools

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

magebitcom/magento2-mcp-google-analytics-tools
==============================================

Google Analytics 4 MCP tools for Magebit\_Mcp — wraps the GA Data and Admin APIs as MCP tools so AI clients can query property metadata, run reports, run realtime reports, and run funnel reports against your store's analytics property.

v0.0.1(1w ago)00MITPHPPHP &gt;=8.1

Since May 29Pushed 1w agoCompare

[ Source](https://github.com/magebitcom/magento2-mcp-google-analytics-tools)[ Packagist](https://packagist.org/packages/magebitcom/magento2-mcp-google-analytics-tools)[ RSS](/packages/magebitcom-magento2-mcp-google-analytics-tools/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Magento2 MCP - Google Analytics Tools
=====================================

[](#magento2-mcp---google-analytics-tools)

Google Analytics 4 tools for the [Magebit MCP server](https://github.com/magebitcom/magento2-mcp-module). Exposes the Google Analytics Data API and Admin API as MCP tools so AI clients (Claude Desktop, ChatGPT, Gemini, Claude Code, MCP Inspector, …) can discover properties, run reports, and inspect schema metadata against your store's analytics property.

Mirrors the official [`google-analytics-mcp`](https://github.com/googleanalytics/google-analytics-mcp) server, but configured through the Magento admin and authenticated with a connected Google account (OAuth) whose refresh token is stored encrypted in `core_config_data`.

Tools
-----

[](#tools)

All tools are **read-only**. Every tool accepts an optional `property_id` argument; when omitted, the *Default GA4 Property ID* from admin config is used.

ToolDescription`google_analytics.account.summaries`List every account + property visible to the connected Google account. Use this first to discover property IDs.`google_analytics.property.get`Return the GA4 Property resource (display name, currency, time zone, industry, service level, …) for the given property.`google_analytics.property.google_ads_links`List the Google Ads accounts linked to a GA4 property.`google_analytics.property.custom_dimensions_and_metrics`List the custom dimensions and custom metrics defined on a property. Use before running a report to discover what custom fields are available.`google_analytics.report.run`Run a GA4 Data API Core Report (`runReport`). Supports `date_ranges`, `dimensions`, `metrics`, filters, order-bys, aggregations, currency conversion.`google_analytics.report.run_realtime`Run a GA4 Realtime Report (`runRealtimeReport`) — events in the last 30 minutes.`google_analytics.report.run_funnel`Run a GA4 Funnel Report (`runFunnelReport`, Data API v1alpha).Every tool surfaces errors as a soft error (`isError: true` in the MCP response) with a human-readable message, leaving the `tools/call` JSON-RPC response status as success. Common error cases:

- Not connected → "Google Analytics is not connected. Connect a Google account…"
- Property id absent and no default → "Google Analytics property\_id is required."
- API quota / permission errors → "Google Analytics API error: &lt;original gRPC status&gt;."

Installation
------------

[](#installation)

```
composer require magebitcom/magento2-mcp-google-analytics-tools
bin/magento module:enable Magebit_McpGoogleAnalyticsTools
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
```

The module depends on `magebitcom/magento2-mcp-module` and the official Google PHP SDKs (`google/analytics-data`, `google/analytics-admin`, `google/auth`). Composer resolves them automatically.

Connect a Google account
------------------------

[](#connect-a-google-account)

The tools act as a real Google user who already has access to your GA4 property.

1. **Enable the APIs** in a Google Cloud project:
    - [Google Analytics Data API](https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com)
    - [Google Analytics Admin API](https://console.cloud.google.com/apis/library/analyticsadmin.googleapis.com)
2. **Create an OAuth client.** In [*APIs &amp; Services → Credentials*](https://console.cloud.google.com/apis/credentials), choose *Create credentials → OAuth client ID → Web application*.
3. **Register the redirect URI.** Copy the *Authorized redirect URI* shown in the Magento admin (*Stores → Configuration → Magebit → Google Analytics MCP → Google Connection*) into the OAuth client's *Authorized redirect URIs*. It looks like `https:////magebit_mcp_ga/oauth/callback`. Google only accepts public HTTPS hosts (or `localhost`); if your store runs on a non-public host, set **Redirect Base URL** to a public tunnel host (ngrok / cloudflared) — the displayed redirect URI updates to match.
4. **Configure the consent screen — for internal use only.** Set the *User type* to **Internal** so the OAuth client is restricted to your own Google Workspace organization.
5. **Paste client ID + secret** into the admin config and click *Save Config*.
6. **Click *Connect with Google*** and approve the consent screen with an account that has at least **Viewer** access to the GA4 property. The status flips to "Connected as ".
7. *(Optional)* Set a *Default GA4 Property ID* — the numeric id (e.g. `123456789`) used when a tool call doesn't specify one. Discover IDs at runtime via `google_analytics.account.summaries`.

The refresh token is stored encrypted at rest. Use *Disconnect* to revoke it from the store.

Granting tool access
--------------------

[](#granting-tool-access)

Tool calls go through the standard Magebit MCP token + ACL flow:

1. Edit (or create) the admin role that owns your MCP token under *System → Permissions → User Roles*.
2. Under *Role Resources*, scroll to *Stores → Settings → Configuration → Magebit → MCP → MCP Tools* and tick the tool ACLs you want this token to use (each tool has its own resource, e.g. *Tool: Run Google Analytics Report*).
3. Save. The next tool call from that token will see the tools in `tools/list` and be allowed to call them.

The admin *Google Analytics MCP Configuration* permission gates access to the connection settings — keep it scoped to people who should manage the Google connection.

Quick example
-------------

[](#quick-example)

```
// JSON-RPC body for POST /mcp
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "google_analytics.report.run",
    "arguments": {
      "date_ranges": [{ "start_date": "7daysAgo", "end_date": "today" }],
      "dimensions": [{ "name": "country" }],
      "metrics": [{ "name": "activeUsers" }, { "name": "sessions" }],
      "order_bys": [{ "metric": { "metric_name": "activeUsers" }, "desc": true }],
      "limit": 10
    }
  }
}
```

License
-------

[](#license)

MIT — see [`LICENSE`](LICENSE).

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance98

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

11d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10514036?v=4)[magebit](/maintainers/magebit)[@Magebit](https://github.com/Magebit)

---

Top Contributors

[![KristofersOzolinsMagebit](https://avatars.githubusercontent.com/u/58505474?v=4)](https://github.com/KristofersOzolinsMagebit "KristofersOzolinsMagebit (2 commits)")

---

Tags

adobeadobe-commerceaimagento2magento2-extensionmagento2-modulemcp-server

### Embed Badge

![Health badge](/badges/magebitcom-magento2-mcp-google-analytics-tools/health.svg)

```
[![Health](https://phpackages.com/badges/magebitcom-magento2-mcp-google-analytics-tools/health.svg)](https://phpackages.com/packages/magebitcom-magento2-mcp-google-analytics-tools)
```

###  Alternatives

[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343128.8M101](/packages/google-cloud-core)[elgentos/regenerate-catalog-urls

Regenerate Catalog URL Rewrites (products, categories, cms pages)

2852.6M](/packages/elgentos-regenerate-catalog-urls)[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

68353.9k](/packages/run-as-root-magento2-prometheus-exporter)[myparcelnl/magento

A Magento 2 module that creates MyParcel labels

1859.0k](/packages/myparcelnl-magento)[loki/magento2-components

Core module for defining Alpine.js components with advanced AJAX features

1010.0k22](/packages/loki-magento2-components)[magepal/magento2-form-field-manager

Customer and Address Form Fields Manager for Magento2

293.9k](/packages/magepal-magento2-form-field-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
