Lean GA4 Tracker

Àpèjúwe

Lean GA4 Tracker is a lightweight, developer-friendly plugin that integrates Google Analytics 4 (GA4) with WordPress.
Unlike heavy analytics plugins, Lean GA4 Tracker focuses on performance, privacy, and simplicity, while still offering advanced features like WooCommerce eCommerce tracking, Consent Mode, and Google Tag Manager (GTM) support.

Perfect for WooCommerce Stores

Lean GA4 Tracker includes built-in GA4 eCommerce event tracking — no coding or add-ons required.
Track the full shopping journey:
– Product detail views (view_item)
– Add to cart actions (add_to_cart)
– Checkout steps (begin_checkout)
– Purchases (purchase)
– Includes product categories and brands for richer GA4 reports

Why Choose Lean GA4 Tracker?

  • Lightweight: No bloat, performance-first architecture
  • WooCommerce Ready: Track product views, carts, checkout, and purchases
  • Developer-Friendly: PSR-4 autoloading, hooks, and JSON event support
  • Flexible Script Loading: Standard, async, defer, or idle
  • Consent Mode Integration: Works with Complianz, CookieYes, and Cookiebot
  • Google Tag Manager (GTM): Inject GTM containers for Web, AMP, or custom
  • Custom Events: Dispatch your own GA4 events via JSON — no JavaScript required
  • Tabbed Settings UI: Clean, organized settings panel
  • Multisite Support: Network-wide GA4 settings with optional enforcement

Resources

Whether you’re a WooCommerce store owner or a developer building custom sites, Lean GA4 Tracker gives you exactly what you need — nothing more, nothing less.

Privacy

This plugin does not collect, store, or transmit any personal data by itself.
It integrates your site with Google Analytics 4 (GA4) and/or Google Tag Manager (GTM).
Please review and configure your GA4 and GTM accounts in accordance with your local privacy laws (such as GDPR, CCPA).

Consent Mode

If enabled, Lean GA4 Tracker respects user tracking preferences via Google Consent Mode.
You can also integrate with third-party cookie banner plugins (Complianz, CookieYes, Cookiebot) to ensure visitor choices are honored.

WooCommerce Data

When WooCommerce tracking is enabled, the plugin sends product and order information to GA4, such as product name, category, brand, price, and quantity.
No personally identifiable information (PII) such as customer names or emails is collected or transmitted.

Recommended

We recommend that site owners:
– Update their site’s Privacy Policy to mention Google Analytics 4 and data sharing with Google
– Provide clear information to visitors about analytics tracking
– Use a consent management plugin to comply with GDPR/CCPA and other regulations

Àwọn àwòrán ìbòjú

  • General tab: Configure GA4 Measurement ID, Script Load Mode, and optional GTM Container ID
  • Tag Manager tab: Configure GTM container injection, container type, debug mode, and user role exclusions
  • Authentication tab: Enter GA4 Property ID and Manual Access Token
  • Events tab: Define custom GA4 events using a JSON array
  • WooCommerce tab: Toggle GA4 eCommerce event tracking for product views, add to cart, checkout, and purchases
  • Forms tab: Enable automatic GA4 event tracking for Contact Form 7, WPForms, Gravity Forms, Ninja Forms, Formidable Forms, and Fluent Forms
  • Privacy & Consent tab: Enable Consent Mode and integrate with cookie banner plugins like Complianz, CookieYes, and Cookiebot
  • Debug tab: Enable Debug Mode to print event tracking output for admins

Ìgbéwọlẹ̀

  1. Upload the plugin files to /wp-content/plugins/lean-ga4-tracker
  2. Activate the plugin from your WordPress dashboard
  3. Go to Settings Lean GA4 Tracker to configure your Measurement ID, WooCommerce tracking, and GTM settings

FAQ

Does this plugin support WooCommerce eCommerce tracking?

Yes. Lean GA4 Tracker tracks product views, add to cart, checkout, and purchases using GA4’s official eCommerce schema — including product category and brand data.

Can I track custom GA4 events without writing code?

Yes. You can define a JSON array of custom events in the Events tab, and the plugin will dispatch them automatically.

Does the plugin support Consent Mode?

Yes. Enable it in the Privacy tab to integrate with cookie banner plugins like Complianz, CookieYes, and Cookiebot.

Can I use Google Tag Manager (GTM) instead of the GA4 script?

Yes. You can inject GTM containers (Web, AMP, or Custom) and even enable GTM Debug Mode for testing.

Does it work in multisite?

Yes. Network admins can enforce GA4 settings across all sites or allow site-level overrides.

Where is the GA4 script loaded?

You can load it as standard, async, defer, or idle (using requestIdleCallback) to optimize performance.

Does this plugin support product categories and brands in WooCommerce?

Yes. From version 1.1.5, WooCommerce eCommerce tracking automatically includes product category and brand attributes in GA4 event payloads.

Can I disable tracking for logged-in administrators or editors?

Yes. You can exclude specific user roles from tracking in the Tag Manager settings tab.

Does Lean GA4 Tracker slow down my website?

No. The plugin is designed to be lightweight and optimized for performance. You can choose async, defer, or idle script loading to minimize impact on page speed.

How is this plugin different from other GA4 plugins?

Lean GA4 Tracker focuses on performance and WooCommerce support without unnecessary bloat. It is developer-friendly, privacy-focused, and provides just the right features for GA4 and GTM integration.

Àwọn àgbéyẹ̀wò

Kò sí àwọn àgbéyẹ̀wò fún plugin yìí.

Àwọn Olùkópa & Olùgbéejáde

“Lean GA4 Tracker” jẹ́ ètò ìṣàmúlò orísun ṣíṣí sílẹ̀. Àwọn ènìyàn wọ̀nyí ti ṣe ìkópa sí plugin yìí.

Àwọn Olùkópa

Túmọ̀ “Lean GA4 Tracker” sí èdè rẹ.

Ṣe o nífẹ̀ẹ́ sí ìdàgbàsókè?

Ṣàwárí koodu, ṣàyẹ̀wò ibi ìpamọ́ SVN, tàbí ṣe àgbékalẹ̀ sí àkọsílẹ̀ ìdàgbàsókè nípasẹ̀ RSS.

Àkọsílẹ̀ àwọn àyípadà

1.1.6

  • Added Recommended GA4 Events section in Events tab with toggles for generate_lead, sign_up, and purchase
  • Improved GA4 Property ID field with better placeholder, validation, and help text in Authentication tab
  • Added Manual GA4 Access Token support for dashboard charts
  • Added initial DashboardPage class with basic GA4 metrics and Chart.js visualization

1.1.5

  • Improved admin UI with modern toggle switch design for settings
  • Added scoped admin CSS file for cleaner styling
  • Enhanced WooCommerce tracking descriptions with GA4 event names
  • Updated settings header with Docs & Support and Upgrade to Pro buttons
  • Improved help texts and tooltips for better user guidance
  • Codebase refactored to use LEAN_GA4_TRACKER_URL constant for assets

1.1.4

  • Added new Script Load Mode option: “Idle (after page load)” using requestIdleCallback with fallback
  • Improved admin settings UI for script placement options
  • Enhanced sanitization to support new load mode
  • Minor code refactoring and documentation updates

1.1.3

  • Improved Consent Mode compatibility with WordPress and third-party consent plugins
  • Added listener for WordPress’s wp_consent_granted event
  • Confirmed WooCommerce support with product, cart, checkout, and order tracking
  • Enhanced leanGA4ConsentGranted()
  • Added WooCommerce tab for toggling GA4 event tracking
  • Supports product views, add to cart, begin checkout, and purchase events
  • Events dispatched using gtag() with product ID, name, price, and order data
  • Enhanced WooCommerce tracking security and GA4 payload accuracy — added JSON-encoded event payloads, quantity/currency support, duplicate purchase prevention, and front-end-only tracking hooks

1.1.1

  • Added Forms tab with toggles for form submission tracking
  • Supports Contact Form 7, WPForms, Gravity Forms, Ninja Forms, Formidable Forms, and Fluent Forms
  • GA4 events include form title and form ID using gtag()

1.1.0

  • Added toggle to enable/disable cookie plugin integration (Complianz, CookieYes, Cookiebot)
  • Integrated JS listeners for automatic consent handling via supported plugins
  • Improved ConsentManager logic with extensible update function
  • Added dynamic consent update helpers for developers and cookie plugins

1.0.9

  • Added “Exclude User Roles” option in Tag Manager settings
  • Added AMP-compatible container injection using tag
  • Added support for “Custom” container type to allow manual GTM handling
  • Ensured all Tag Manager settings are properly registered on admin_init
  • Improved container-type-specific GTM rendering logic
  • Fixed settings save behavior for checkboxes and radios with fallback handling

1.0.8

  • Added GTM Debug Mode toggle in Tag Manager settings
  • Enhanced container type support: Web, AMP, and Custom
  • Improved script injection logic and frontend behavior

1.0.7

  • Improved Multisite Compatibility for Custom Events
  • Added sample GA4 event JSON and live validation to both site-level and network-level settings
  • Enhanced admin UI guidance for defining custom events across installations

1.0.6

  • Added Privacy & Consent settings tab with support for Google Consent Mode
  • Added notice recommending cookie banner plugins for frontend consent control
  • Improved ConsentManager handling and script modularity

1.0.5

  • Introduced tab-based settings UI with General, Authentication, Events, and Debug sections
  • Added manual GA4 access token and property ID input for non-OAuth usage
  • Added GTM container injection option with <head> and <noscript> support
  • Improved internal structure for OAuth and manual mode support (future-ready)

1.0.4

  • Added async script loading via WordPress 6.3+ ‘strategy’ attribute
  • Replaced placeholder script with inline-only registration for GA4 config
  • Injected official gtag.js loader from Google using proper async method
  • Improved inline script structure using wp_json_encode and output validation

1.0.3

  • Improved GA4 inline script injection with reliable output structure
  • Replaced empty script handle with placeholder registration for consistent rendering
  • Verified compatibility with themes and ensured presence of GA4 tag in frontend

1.0.2

  • Refactored to a modular, class-based architecture using namespaces
  • Added support for multisite network settings with enforcement
  • Introduced debug mode and custom event JSON handling
  • Integrated script loading mode (default, async, defer)
  • Added error notices for invalid JSON input

1.0.1

  • Update code following PHPCS
  • escaped all code properly

1.0

  • Initial Release