説明
Analytics Head は、あえてシンプルにした WordPress 向け Google アナリティクスプラグインです。ダッシュボードも Google アカウント連携も機能の肥大化もなく、必要な場所にトラッキングコードを置くだけです。
このプラグインを使う理由
- 軽量 — 少数のオプション、最小限のオーバーヘッド、外部依存なし
- Easy — paste your GA4 Measurement ID (G-XXXXXXXXXX) and you are done
- デフォルトで head に配置 — アナリティクス経由の Google Search Console 確認に必要
- 柔軟 — フッター配置、権限ベースの非表示、同意モード v2、任意の Google 広告 ID
- 開発者フレンドリー — プラグインをフォークせずに出力をカスタマイズできるフィルターとアクション
多機能なアナリティクススイートとは異なり、このプラグインは一つのことをきちんと行います。標準の gtag.js スニペットをサイトに挿入します。
機能
- Google tag / GA4 Measurement ID support (GT-…, G-XXXXXXXXXX)
- Additional tracking IDs for separate destinations (e.g. Google Ads AW-)
- Legacy UA- ID acceptance (with admin notice to migrate)
- Code in
<head>by default (optional footer placement) - wp-admin ではトラッキングを挿入しない
- フロントエンドで管理者のトラッキングを非表示
- ユーザー権限ごとのトラッキング非表示
- Google Consent Mode v2 defaults (for GDPR / cookie plugins)
- Keep settings on uninstall (optional)
- 開発者向けフックとフィルター
外部サービス
This plugin connects to Google Analytics (via Google Tag Manager / gtag.js) to provide website analytics.
- When: on public front-end page views only (never in the WordPress admin area), unless tracking is hidden for the current visitor by plugin settings
- What is sent: standard Google Analytics measurement data (for example page URL, referrer, browser/device information, and IP-derived location), processed by Google
- 受信者: Google LLC / Google アナリティクス
- 利用規約: https://marketingplatform.google.com/about/analytics/terms/us/
- プライバシーポリシー: https://policies.google.com/privacy
You are responsible for informing visitors (for example in your privacy policy) and, where required, obtaining consent. Suggested privacy policy text is also offered under Settings Privacy when the plugin is active.
要件
- WordPress 6.3 or later (compatible with WordPress 7+)
- PHP 7.4 以降
例
トラッキング ID をフィルターする
add_filter( 'pp_google_analytics_head_tracking_ids', function( $ids ) {
// Add a separate destination only — not a second ID for the same Google tag.
$ids[] = 'AW-123456789';
return $ids;
} );
Change Consent Mode defaults (PHP)
add_filter( 'pp_google_analytics_head_consent_defaults', function( $defaults ) {
$defaults['wait_for_update'] = 2000;
$defaults['region'] = [ 'PL', 'DE', 'US-CA' ];
return $defaults;
} );
Grant consent after the user accepts cookies (JavaScript)
同意プラグインのコールバック、またはカスタムバナーの「同意する」ハンドラーから呼び出してください。このプラグインがデフォルトで denied に設定する 4 種類すべてを更新します:
gtag('consent', 'update', {
analytics_storage: 'granted',
ad_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted'
});
If you only want basic analytics (not ads), grant analytics and keep ads denied:
gtag('consent', 'update', {
analytics_storage: 'granted',
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied'
});
インラインの gtag 設定を変更する
add_filter( 'pp_google_analytics_head_inline_script', function( $script, $ids ) {
$script .= "gtag('event','page_view');";
return $script;
}, 10, 2 );
インストール
analytics-headディレクトリを/wp-content/plugins/にアップロード- WordPress のプラグインメニューからプラグインを有効化
- 設定 Analytics Head を開く
- Enter your GA4 Measurement ID (G-XXXXXXXXXX)
- 保存 — トラッキングがすぐに開始されます
FAQ
-
How do I get a Measurement ID?
-
Sign in to Google Analytics, create a GA4 property for your site, and copy the Measurement ID (format
G-XXXXXXXXXX) or Google tag ID (GT-…) from Admin Data Streams. Use only one ID per Google tag — do not enter both the GT- and G- IDs that belong to the same tag. -
Why place the code in the head section?
-
Google Search Console はアナリティクスタグでサイト所有権を確認できますが、タグが
<head>にある場合に限ります。プラグイン設定でいつでもフッターに移せます。 -
Do I need to connect my Google account?
-
いいえ。このプラグインはトラッキングスニペットを挿入するだけです。OAuth、API キー、Google ログインは不要です。
-
How does Consent Mode work?
-
プラグイン設定の「プライバシー」で同意モード v2を有効にしてください。gtag.js の読み込み前に、このプラグインは次を設定します:
analytics_storagedeniedad_storagedeniedad_user_datadeniedad_personalizationdeniedwait_for_update500 ミリ秒
The tracking script still loads (that is how Consent Mode works). Until consent is granted, Google receives only limited, cookieless signals.
When the visitor accepts cookies, your GDPR / cookie banner plugin (or custom JavaScript) should call
gtag('consent', 'update', …)and grant the same four storage types (see Examples). Granting onlyanalytics_storageandad_storagewould leave ad user data / personalization permanently denied.Google 同意モードに対応した最近の同意プラグインの多くは、すでにこれを行います。こちらで同意モードを有効にし、同意プラグイン側でも Google 同意モード / アナリティクス対応を有効にしてください。
-
Does this block the Analytics script until consent?
-
いいえ。同意モードはハードブロックではありません。スクリプトは常に挿入され、同意のデフォルトは denied から始まり、後で更新されます。オプトインまでスクリプトを遅延または削除したい場合は、タグをハードブロックする同意プラグインを使うか、同意が得られるまで空のリストを返すよう
pp_google_analytics_head_tracking_idsフィルターを使ってください。 -
Which GDPR plugins work with this?
-
Any plugin that can run
gtag('consent', 'update', …)after the user accepts — for example Complianz, CookieYes, Borlabs Cookie, Cookiebot (when Google Consent Mode is enabled in that plugin). There is no proprietary bridge to a single vendor; we stay lightweight and use the standard Google API. -
What if I know PHP?
-
Available hooks and filters (see the Examples section for code):
pp_google_analytics_head_before— アクション。スクリプトのエンキュー前pp_google_analytics_head_after— アクション。スクリプトのエンキュー後pp_google_analytics_head_inline_script— filter, modify the inline gtag config script ($script,$ids)pp_google_analytics_head_tracking_ids— filter, modify the list of Measurement / Ads IDs ($ids,$options)pp_google_analytics_head_consent_defaults— filter, modify Consent Mode defaults (analytics_storage,ad_storage,ad_user_data,ad_personalization,wait_for_update, optionalregionusing ISO 3166-2 region codes)pp_google_analytics_head_roles— フィルター。表示設定で利用可能な権限グループを変更
Note: The old
pp_google_analytics_head_outputHTML filter was removed in 1.7.0 (it was incompatible withwp_enqueue_script). Usepp_google_analytics_head_inline_scriptorpp_google_analytics_head_tracking_idsinstead. -
Is it free?
-
はい、GPLv2 以降です。寄付は歓迎しますが、必須ではありません。
貢献者と開発者
変更履歴
1.7.0
- リリース日: 2026-07-28
- Renamed display name to Analytics Head (WordPress.org naming guidelines)
- Google tag / GA4 ID support (GT-, G-) and Google Ads IDs (AW-)
- WordPress 6.3 以降および PHP 7.4 以降が必要。async スクリプト戦略。WordPress 7 以降でテスト済み
- Translations via WordPress Polyglots (removed bundled language files)
- Output via wp_enqueue_script with real async strategy (inline gtag queued as before)
- Tracking IDs resolved once during wp_enqueue_scripts (late filters / conditional tags work)
- Consent Mode v2 defaults for GDPR / cookie plugin integration (including optional region)
- wp-admin でのトラッキングなし。wp_roles() による権限ベースのフロントエンド表示制御
- Optional keep settings on uninstall (batched multisite cleanup)
- 外部サービスの説明とプライバシーポリシー用ヘルパー文言
- 無効な ID でも以前保存した値を消さないよう変更。フィルター検証を強化
1.6.7
- リリース日: 2018-11-21
- 互換性タグを設定

