GA4 MCP Server
Provides 20 analysis tools for retrieving and analyzing Google Analytics 4 (GA4) data, including traffic summaries, page rankings, traffic sources, device breakdowns, geographic analysis, period comparisons, user journeys, conversion funnels, engagement metrics, and real-time reporting.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GA4 MCP Server 過去7日間のアクセス数が多いページTOP10を教えて"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GA4 MCP Server
Google Analytics 4 (GA4) のデータを Claude などの LLM から取得・分析できる MCP (Model Context Protocol) サーバーです。
特徴
20種類の分析ツール: 単純なデータ取得だけでなく、実用的な分析ツールを多数搭載
日本語対応: 出力結果は日本語でフォーマット(例: "2分34秒", "45.2%")
柔軟な期間指定: 相対日付(
7daysAgo,yesterday)と絶対日付の両方に対応即座にインサイト: LLMが直接解釈しやすい形式でデータを返却
Related MCP server: ga4-viz
必要要件
Node.js 18以上
GA4 プロパティへのアクセス権を持つ Google アカウント
インストール
cd ga4-mcp-server
npm install
npm run build認証設定
方法1: gcloud CLI を使う(推奨・簡単)
サービスアカウント不要で、自分の Google アカウントで認証できます。
1. gcloud CLI をインストール
# Windows (winget)
winget install Google.CloudSDK
# または https://cloud.google.com/sdk/docs/install からダウンロード2. 認証を実行
gcloud auth application-default login --scopes="https://www.googleapis.com/auth/analytics.readonly"ブラウザが開くので、GA4 にアクセス権のある Google アカウントでログインするだけ!
これだけで完了です。GOOGLE_APPLICATION_CREDENTIALS の設定は不要です。
方法2: サービスアカウントを使う(本番環境向け)
チーム共有や本番環境では、サービスアカウントを使用します。
1. Google Cloud Console でサービスアカウントを作成
Google Cloud Console にアクセス
プロジェクトを選択(または新規作成)
「IAM と管理」→「サービスアカウント」→「サービスアカウントを作成」
名前を入力して作成
「キー」タブ →「鍵を追加」→「新しい鍵を作成」→ JSON形式でダウンロード
2. API の有効化
「APIとサービス」→「ライブラリ」で以下を有効化:
Google Analytics Data API
Google Analytics Admin API
3. GA4 プロパティへのアクセス権付与
Google Analytics にアクセス
「管理」→「プロパティのアクセス管理」
サービスアカウントのメールアドレス(
xxx@xxx.iam.gserviceaccount.com)を「閲覧者」として追加
MCP 設定
gcloud CLI 認証を使う場合(推奨)
{
"mcpServers": {
"ga4": {
"command": "node",
"args": ["/path/to/ga4-mcp-server/dist/index.js"],
"env": {
"GA4_PROPERTY_ID": "123456789"
}
}
}
}サービスアカウントを使う場合
{
"mcpServers": {
"ga4": {
"command": "node",
"args": ["/path/to/ga4-mcp-server/dist/index.js"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}設定ファイルの場所
アプリ | 設定ファイル |
Claude Desktop (Mac) |
|
Claude Desktop (Windows) |
|
Cursor |
|
環境変数
変数名 | 必須 | 説明 |
| × | サービスアカウントJSONキーのパス(gcloud CLI使用時は不要) |
| △ | デフォルトのGA4プロパティID(ツール実行時に指定も可) |
利用可能なツール
基本ツール(5個)
ツール名 | 説明 |
| アカウント・プロパティ一覧取得 |
| プロパティ詳細情報 |
| 汎用レポート実行(メインツール) |
| リアルタイムレポート |
| 利用可能なディメンション・メトリクス一覧 |
分析ツール(15個)
ツール名 | 説明 |
| トラフィックサマリー(PV/UU/セッション等) |
| 人気ページランキング |
| 流入元分析 |
| デバイス別アクセス比率 |
| 地域別アクセス分析 |
| 期間比較(前週比、前月比など) |
| ランディングページ分析 |
| 離脱ページ分析 |
| ユーザージャーニー(ページ遷移) |
| コンバージョンファネル分析 |
| 時間帯別アクセス分析 |
| 日別トレンド |
| 新規 vs リピーター分析 |
| エンゲージメント指標 |
| サイト内検索キーワード |
使用例
基本的な質問
「今日のPV数を教えて」
→ get_traffic_summary (period: "today")
「今リアルタイムで何人見てる?」
→ run_realtime_reportランキング系
「過去7日間のアクセス数が多いページTOP10」
→ get_top_pages (period: "7days", limit: 10)
「どこからアクセスが来てる?」
→ get_traffic_sources (period: "7days", groupBy: "channel")比較・分析系
「先週と今週を比較して」
→ compare_periods (comparisonType: "previousPeriod", period: "7days")
「モバイルとPCの比率は?」
→ get_device_breakdown (period: "7days")深堀り分析
「何時頃にアクセスが多い?」
→ get_hourly_traffic (period: "7days")
「このページを見た人は次にどこに行く?」
→ get_user_journey (pagePath: "/product/123", direction: "next")開発
# 開発モード(ファイル変更を監視してリビルド)
npm run dev
# ビルド
npm run build
# 型チェック
npm run typecheck注意事項
レート制限: GA4 Data API には 1 プロジェクトあたり 1 日 50,000 リクエストの制限があります
データの遅延: GA4のデータは通常24-48時間の遅延があります(リアルタイムレポートを除く)
ファネル分析の制限: GA4 Data APIでは真のファネル分析に制限があります。より正確な分析にはBigQuery Exportが必要です
ライセンス
MIT
Available Tools
20 toolscompare_periodsC
2つの期間を比較します。前週比、前月比、前年同期比などの分析が可能です。
Inputs: comparisonType (required), propertyId, period, period1, +2 more.
get_conversion_funnelC
コンバージョンファネルの分析を行います。各ステップの通過率や離脱率を確認できます。
Inputs: period (required), steps (required), propertyId.
get_daily_trendC
日別のトレンドデータを取得します。グラフ作成やトレンド分析に使用できます。
Inputs: startDate (required), endDate (required), propertyId, metrics.
get_device_breakdownB
デバイス別(PC/モバイル/タブレット)のアクセス内訳を取得します。OS別、ブラウザ別の情報も含まれます。
Inputs: period (required), propertyId.
get_engagement_metricsC
エンゲージメント関連の詳細指標(エンゲージメント率、平均エンゲージメント時間など)を取得します。
Inputs: period (required), propertyId.
get_exit_pagesC
離脱ページ(ユーザーが最後に見たページ)の分析結果を取得します。
Inputs: period (required), propertyId, limit.
get_geo_breakdownC
地域別(国または市区町村)のアクセス分析結果を取得します。
Inputs: period (required), level (required), propertyId, limit.
get_hourly_trafficB
時間帯別のアクセス状況を分析します。投稿やキャンペーンのタイミング最適化に活用できます。
Inputs: period (required), propertyId.
get_landing_pagesC
ランディングページ(ユーザーが最初にアクセスしたページ)の分析結果を取得します。
Inputs: period (required), propertyId, limit.
get_metadataB
利用可能なディメンションとメトリクスの一覧を取得します。run_reportで使える項目を確認できます。
Inputs: propertyId.
get_new_vs_returningC
新規ユーザーとリピーターの比較分析を行います。それぞれのセッション数や滞在時間を確認できます。
Inputs: period (required), propertyId.
get_property_detailsC
指定したGA4プロパティの詳細情報(名前、タイムゾーン、通貨など)を取得します。
Inputs: propertyId (required).
get_search_termsB
サイト内検索キーワードを分析します。GA4でサイト内検索が設定されている場合のみ有効です。
Inputs: period (required), propertyId, limit.
get_top_pagesC
人気ページのランキングを取得します。PV数、滞在時間、直帰率などを確認できます。
Inputs: period (required), propertyId, limit, pathFilter.
get_traffic_sourcesC
流入元(チャネル、ソース、メディアなど)の分析結果を取得します。
Inputs: period (required), groupBy (required), propertyId.
get_traffic_summaryB
指定期間のトラフィック概要(PV数、ユーザー数、セッション数、直帰率など)を取得します。ダッシュボード的な使い方に最適です。
Inputs: period (required), propertyId.
get_user_journeyB
特定ページの前後に閲覧されるページを分析します。ユーザーの回遊パターンの把握に便利です。
Inputs: period (required), pagePath (required), direction (required), propertyId, +1 more.
list_accountsA
GA4のアカウントとプロパティの一覧を取得します。どのプロパティIDを使うべきか確認する際に便利です。
Inputs: no named parameters.
run_realtime_reportC
リアルタイムレポートを実行し、現在のアクティブユーザー数などを取得します。
Inputs: propertyId, dimensions, metrics.
run_reportC
GA4の汎用レポートを実行します。任意のディメンションとメトリクスを指定して柔軟にデータを取得できます。
Inputs: startDate (required), endDate (required), dimensions (required), metrics (required), +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 20 tools
Every tool has a clearly distinct purpose targeting specific GA4 analysis functions, such as comparing periods, analyzing funnels, getting device breakdowns, or running reports. No tools appear to overlap in functionality, making it easy for an agent to select the correct one based on the task.
All tools follow a consistent verb_noun pattern, primarily using 'get_' or 'run_' prefixes (e.g., get_daily_trend, run_report). Minor variations like 'compare_periods' and 'list_accounts' still adhere to a clear naming convention, ensuring predictability and readability throughout the set.
With 20 tools, the count is slightly high but reasonable for a comprehensive GA4 analytics server, covering diverse aspects like traffic, user behavior, and reporting. It avoids being overwhelming by maintaining clear scopes, though it borders on the upper limit for typical server purposes.
The tool set provides complete coverage for GA4 analytics, including data retrieval (e.g., get_traffic_summary), detailed analyses (e.g., get_conversion_funnel), property management (e.g., list_accounts), and flexible reporting (e.g., run_report). No obvious gaps exist, supporting full agent workflows from overview to deep dives.
Maintenance
Related MCP Connectors
GA4, Google Ads and Search Console in Claude. Read-only OAuth, multi-account for agencies.
SEO research, Search Console, GA4 and PPC tools for Claude and ChatGPT.
GA4 conversion analyst inside Claude — funnel drops, traffic anomalies, device gaps, with numbers.
Read-only Google Ads, GA4 and Search Console data for Claude, with no Google Cloud setup.
Related MCP Servers
- AlicenseAqualityBmaintenanceConnects Google Analytics 4 data to Claude, Cursor and other MCP clients, enabling natural language queries of website traffic, user behavior, and analytics data with access to 200+ GA4 dimensions and metrics.124,647 PyPI243MIT
- FlicenseNot gradedqualityDmaintenanceEnables interactive Google Analytics 4 visualizations inside Claude conversations, supporting ad-hoc queries with line, bar, pie charts and data tables.-
- FlicenseAqualityDmaintenanceEnables natural language querying of Google Analytics 4, Google Search Console, Meta Ads, and Google Ads data through Claude.23-
- FlicenseAqualityNot gradedmaintenanceConnects Claude to Google Analytics 4 for querying website analytics via natural language, enabling traffic summaries, top pages, traffic sources, and user engagement.4-