[WordPress] 外掛分享: Lightweight Google Analytics

首頁外掛目錄 › Lightweight Google Analytics
WordPress 外掛 Lightweight Google Analytics 的封面圖片
400+
安裝啟用
★★★★★
5/5 分(2 則評價)
6 天前
最後更新
問題解決
WordPress 5.7+ PHP 7.0+ v1.6.0 上架:2020-09-23

內容簡介

Lightweight Google Analytics 外掛可輕鬆將 Google Analytics 4 (GA4) 整合至您的 WordPress 網站,僅需提供測量 ID。此外掛專注於效能,無額外負擔,並提供多項隱私選項。

【主要功能】
• 僅需 GA4 測量 ID (G-XXXXXXXX)
• 可選擇在頁首或頁尾載入追蹤碼
• 預設排除已登入用戶的追蹤
• 支援 Google 同意模式 v2
• 提供除錯模式以測試 GA4
• 可選擇最小化分析模式,無需載入 gtag.js

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.6.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Lightweight Google Analytics」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This simple plugin adds Google Analytics 4 (GA4) to your WordPress site using your Measurement ID. It prints Google’s standard gtag.js snippet, nothing more, with a few options for where it loads, who gets tracked, privacy and testing.
Features

Performance focused with no bloat and never any upsells
Only needs your GA4 Measurement ID (G-XXXXXXXX)
Load the tracking code in the header or footer
Exclude logged-in users by role (admins, editors and authors are excluded by default)
Post previews and the Customizer are never tracked
Option to disable Google’s advertising features (Google signals)
Google Consent Mode v2 support for GDPR/CCPA compliance with cookie consent plugins
Debug Mode for testing in GA4 DebugView
Optional Minimal Analytics 4 mode: a 3.5 KB inline script that reports page views, scrolls, downloads, outbound clicks and site searches without loading gtag.js at all
The settings page tells you whether tracking is live and why your own visits may not show up
Works with WP Rocket’s local Google Analytics feature
Filters for developers to change the gtag config, the consent defaults or when tracking is skipped

The plugin does not include any reporting. To see your statistics, open Google Analytics.
Note: Universal Analytics (UA-) was shut down by Google in 2023 and is no longer supported. If you still have a UA- ID saved, the plugin outputs nothing until you enter a GA4 Measurement ID.
For developers
Change the options passed to gtag("config", ...), for example to disable the automatic page view or set cookie flags:
add_filter( 'lightweight_ga_gtag_config', function ( $config, $measurement_id ) {
$config['send_page_view'] = false;
$config['cookie_flags'] = 'SameSite=None;Secure';
return $config;
}, 10, 2 );

Change the Consent Mode defaults, for example to only deny storage for EU visitors:
add_filter( 'lightweight_ga_consent_defaults', function ( $defaults ) {
$defaults['region'] = array( 'AT', 'BE', 'DE', 'FR', 'IE', 'NL' );
return $defaults;
} );

Skip the tracking code for any request:
add_filter( 'lightweight_ga_disable_tracking', function ( $disabled ) {
return $disabled || is_page( 'internal-dashboard' );
} );

延伸相關外掛

文章
Filter
Mastodon