Google Analytics MCP Server
Google Analytics MCP
Google Analytics 4向けのローカルMCPサーバー。SEOおよび有料広告レポートに焦点を当てたツールでGA4 Data APIをラップします。
ツール
ツール | 目的 |
| SEO: ランディングページ、ソース、国、またはデバイス別のオーガニック検索セッション/ユーザー/エンゲージメント/コンバージョン |
| 有料広告: キャンペーン、ランディングページ、キーワード、またはソース別の有料検索セッション/コンバージョン/コスト/CPC |
| 有料広告: コストとROASを含むすべての有料チャネル(検索 + ソーシャル + 動画 + ディスプレイ) |
| 有料広告: Google広告のキャンペーン × 広告グループ × キーワード(GA4とGoogle広告のリンクが必要) |
| セッション/エンゲージメント/コンバージョン別のトップランディングページ(チャネルフィルタはオプション) |
| デフォルトチャネルグループのロールアップ |
| キャンペーン × ソース × メディアの内訳 |
| ソース/メディア/チャネル別のコンバージョンおよび主要イベント |
| 過去30分間のアクティブユーザー |
| 柔軟なエスケープハッチ — 任意のディメンション + 指標 |
セットアップ
git clone https://github.com/ZLeventer/google-analytics-mcp-server.git
cd google-analytics-mcp-server
npm install
npm run build認証情報
.env.example を .env にコピーし、以下を入力します:
GA4_PROPERTY_ID— GA4管理画面 → プロパティ設定から取得できる数値のプロパティID(例:123456789)。測定ID(G-XXXXXXX)ではありません。GOOGLE_APPLICATION_CREDENTIALS— サービスアカウントJSONキーファイルへの絶対パス。
サービスアカウントの作成
console.cloud.google.com にアクセス → プロジェクトを選択/作成
APIとサービス → ライブラリ → Google Analytics Data API を有効化
IAMと管理 → サービスアカウント → サービスアカウントを作成(名前を
ga4-mcpなどにする)作成したアカウントで → キー → 鍵を追加 → 新しい鍵を作成 → JSON → ダウンロード
このディレクトリにJSONを
service-account.jsonとして保存(.gitignoreに追加済み)GA4 → 管理 → プロパティのアクセス管理 で + をクリック → サービスアカウントのメールアドレス(
ga4-mcp@project-id.iam.gserviceaccount.com)を貼り付け → 閲覧者 を割り当て
Google SDKは GOOGLE_APPLICATION_CREDENTIALS を自動的に読み込むため、コードの変更は不要です。
Claude Codeへのインストール
claude mcp add google-analytics \
--env-file "/absolute/path/to/google-analytics-mcp-server/.env" \
-- node "/absolute/path/to/google-analytics-mcp-server/dist/index.js"または、~/.claude.json に手動で追加します:
{
"mcpServers": {
"google-analytics": {
"command": "node",
"args": ["/absolute/path/to/google-analytics-mcp-server/dist/index.js"],
"env": {
"GA4_PROPERTY_ID": "123456789",
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/google-analytics-mcp-server/service-account.json"
}
}
}
}インストール後、Claude Codeを再起動してください。
日付形式
すべての日付引数はGA4形式を受け付けます:
YYYY-MM-DD(例:2026-04-01)NdaysAgo(例:28daysAgo,90daysAgo)yesterday,today
デフォルト: 28daysAgo → yesterday。
検証
認証情報の設定後:
node -e '
import("./dist/tools/reports.js").then(m =>
m.channelPerformance({ start_date: "7daysAgo", end_date: "yesterday", limit: 10 })
).then(r => console.log(JSON.stringify(r, null, 2)))
'行が返されれば、すべて正常に動作しています。想定されるエラー:
GA4_PROPERTY_ID is not set—.envを確認してくださいPERMISSION_DENIED— サービスアカウントにプロパティの閲覧者権限が付与されていません403 Google Analytics Data API has not been used— GCPプロジェクトでAPIを有効にしてください
ロードマップ
[ ] 必要に応じて管理APIツール(カスタムディメンション、コンバージョンイベント、オーディエンスの一覧表示)
[ ] ランキング/インプレッション/CTRデータ用の兄弟サーバーとしてのSearch Console MCP(本サーバーを補完)
[ ] Demandbase MCPと組み合わせて、GA4のトラフィックと企業属性(アカウントレベルの属性)を結合
Available Tools
10 toolsga4_all_paid_performanceA
Paid: all paid channels (Search + Social + Video + Display + Other) broken down by channel × campaign × source × medium, with cost and ROAS.
Inputs: start_date, end_date, property_id, limit.
ga4_campaign_performanceB
Campaign × source × medium breakdown with sessions/conversions/revenue. Optional channel filter.
Inputs: start_date, end_date, property_id, limit, +1 more.
ga4_channel_performanceB
Default channel group rollup: sessions/users/conversions/revenue for Organic Search, Paid Search, Email, Direct, Referral, etc.
Inputs: start_date, end_date, property_id, limit.
ga4_conversions_by_sourceB
Conversions and key events broken down by session source × medium × channel group. Sorted by key events desc.
Inputs: start_date, end_date, property_id, limit.
ga4_google_ads_performanceA
Paid: Google Ads campaign × ad group × keyword performance (impressions, clicks, cost, CPC, conversions, ROAS). Requires Google Ads ↔ GA4 link.
Inputs: start_date, end_date, property_id, limit.
ga4_landing_page_performanceA
Top landing pages by sessions/engagement/conversions. Optional channel filter (e.g. 'Organic Search', 'Paid Search').
Inputs: start_date, end_date, property_id, limit, +1 more.
ga4_organic_search_performanceA
SEO: sessions/users/engagement/conversions for Organic Search traffic, broken down by landing page (default), source, country, or device.
Inputs: start_date, end_date, property_id, limit, +1 more.
ga4_paid_search_performanceB
Paid: sessions/conversions/cost/CPC for Paid Search traffic, broken down by campaign (default), landing page, keyword, or source.
Inputs: start_date, end_date, property_id, limit, +1 more.
ga4_realtime_active_usersB
Current active users (last 30 min) broken down by screen/page, country, device, or audience.
Inputs: property_id, breakdown, limit.
ga4_run_reportA
Flexible GA4 Data API runReport. Pass any dimensions + metrics. Use for custom reports the preset tools don't cover.
Inputs: dimensions (required), metrics (required), start_date, end_date, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a distinct area of GA4 data: all paid, specific channels, campaigns, conversions, landing pages, organic/paid search, realtime, and a generic report. No two tools have overlapping purposes that would cause confusion.
All tool names consistently follow the 'ga4_<descriptive_name>' format using snake_case. The naming pattern is predictable and uniform across the entire set.
10 tools is well within the ideal 3-15 range for a focused analytics server. Each tool serves a clear purpose, and the count feels neither excessive nor insufficient for covering core GA4 queries.
The set covers acquisition, behavior, conversions, and realtime analytics well. Minor gaps exist (e.g., user demographics, event details), but the flexible ga4_run_report tool allows agents to fill these gaps for custom reports.
Related MCP Connectors
Hosted MCP server for GA4, Google Ads and Search Console. Google OAuth, nothing to install.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
SEO MCP server for keyword research, SERP analysis, audits, and Search Console workflows.
SEO platform MCP server: GSC, Bing, Yandex, technical audits, local rank grids, and AI visibility.