Linux 软件免费装
Banner图

Lightweight Google Analytics

开发者 someguy9
更新时间 2026年9月10日 05:58
捐献地址: 去捐款
PHP版本: 7.0 及以上
WordPress版本: 7.1
版权: GPLv3
版权网址: 版权信息

标签

Google Analytics GA4 Analytics GDPR Consent Mode

下载

1.4.0 1.4.2 1.4.1 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.0.0 1.3.0 1.4.3 1.5.0 1.6.0

详情介绍:

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 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' ); } );

安装:

  1. Upload the plugin to the wp-content/plugins directory, or install it from the Plugins screen.
  2. Activate it from the Plugins screen.
  3. Go to Settings > Lightweight Google Analytics, enter your Measurement ID and save.

常见问题:

How do I find my Google Analytics 4 Measurement ID?

In Google Analytics go to Admin > Data Streams, open your web stream and copy the Measurement ID. It starts with G-.

Tracking is enabled but I don't see my own visits

By default the tracking code is not loaded for logged-in administrators, editors and authors, so your own browsing does not pollute your reports. The status message at the top of the settings page tells you whether this applies to your account. Change the Tracking Level setting to "Track all users" if you want to be counted.

What is Consent Mode and do I need it?

Google Consent Mode v2 tells Google that analytics and advertising storage are denied until the visitor consents. Enable it if you use a cookie consent plugin that updates the consent state through gtag("consent", "update", ...) and you need to comply with GDPR or similar rules. It only applies to Google's gtag.js code.

What is the Minimal Analytics 4 option?

It replaces Google's gtag.js with Minimal Analytics 4 by Dariusz Wieckiewicz (MIT), a small inline script that talks to Google Analytics directly. It sends page views, session start and engagement events, 90% scrolls, file downloads, outbound link clicks and site searches, plus UTM campaign attribution. It does not support Consent Mode or Google's enhanced measurement, and it stores its client and session IDs in localStorage, so check your privacy requirements before using it.

How do I test if tracking is working?

Enable Debug Mode in the plugin settings, then in Google Analytics go to Admin > DebugView to watch hits arrive in real time. Turn Debug Mode off when you are done.

Is Universal Analytics (UA-) still supported?

No. Google stopped processing Universal Analytics data in July 2023 and deleted the properties in 2024, so version 1.6.0 removed the UA code. Enter a GA4 Measurement ID instead.

更新日志:

1.6.0 1.5.0 1.4.3 1.4.2 1.4.1 1.4 1.3 1.2.2 1.2.1 1.2.0 1.1.1 1.1.0 1.0.0