WP Lite Consent Gate
WP Lite Consent Gate is a lightweight first-party consent layer for simple WordPress sites
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/r-/wp-lite-consent-gate/archive/refs/heads/main.zipLightweight first-party consent layer for simple WordPress sites.
WP Lite Consent Gate provides a cookie/browser-storage banner, basic consent storage, Google Consent Mode updates, optional analytics gating, and a small JavaScript API for first-party scripts.
It is a technical helper, not a legal compliance guarantee. It does not replace legal advice, a professional Consent Management Platform, cookie scanning, vendor management, IAB TCF, or a full privacy compliance workflow.
Why does this plugin exist?
WP Lite Consent Gate exists for simple WordPress sites that need a small first-party consent layer without adopting a full CMP too early.
Many small sites only need to handle necessary storage and optional analytics. In that case, a large CMP can be more complex than the site itself.
This plugin provides a simple consent banner, stores the visitor's choice, blocks optional analytics until consent, updates Google Consent Mode, and exposes a small JavaScript API that first-party scripts can use before running analytics-style behavior.
It is a practical middle step between having no consent system and adopting a full professional CMP.
What it does
- Shows a cookie and browser storage banner.
- Provides Accept all, Reject optional, and Manage choices controls.
- Stores the visitor choice in a first-party consent cookie.
- Keeps necessary storage always on.
- Keeps analytics optional and denied by default.
- Prints Google Consent Mode v2 defaults early.
- Updates Google Consent Mode after visitor choice.
- Optionally loads Google Analytics after analytics consent.
- Exposes a small JavaScript consent API.
- Dispatches a browser event when consent changes.
- Adds suggested privacy policy text through WordPress.
What it does not do
- It is not a full CMP.
- It is not an IAB TCF implementation.
- It is not a cookie scanner.
- It does not manage vendor-level consent.
- It does not keep proof-of-consent logs.
- It does not provide regional legal behavior.
- It does not automatically block arbitrary third-party plugins.
- It does not make compliance claims.
When should I use WP Lite Consent Gate?
Use WP Lite Consent Gate if:
- your site is small or medium-sized
- you control and understand the scripts loaded on the site
- you only need necessary storage plus optional analytics consent
- you want Google Consent Mode defaults and updates
- you want Google Analytics to wait until analytics consent
- you want first-party plugins to check consent before using browser storage
- you do not need a full CMP yet
Good examples:
- personal blogs
- indie studio sites
- portfolio sites
- documentation sites
- small product sites
- experimental sites
- educational sites
- first-party tool sites
- low-traffic content sites
When should I not use WP Lite Consent Gate?
Do not use WP Lite Consent Gate as your only consent solution if your site uses:
- advertising networks
- Google Ad Manager
- programmatic ads
- many third-party vendors
- IAB TCF
- Meta, TikTok, LinkedIn, Pinterest, or other marketing pixels
- affiliate tracking networks
- heatmaps or session recording
- complex third-party embeds
- regional consent rules
- consent logs or proof-of-consent requirements
- automatic cookie scanning requirements
For those cases, use a professional Consent Management Platform.
Configuration
Use the wp_lite_consent_gate_config filter.
add_filter( 'wp_lite_consent_gate_config', function ( $config ) {
$config['enable_google_analytics'] = true;
$config['ga_measurement_id'] = 'G-XXXXXXXXXX'; // Example only.
$config['privacy_url'] = home_url( '/privacy-policy/' );
$config['cookie_duration_days'] = 180;
return $config;
} );
Default config:
[
'enabled' => true,
'consent_version' => 1,
'cookie_name' => 'wp_lite_consent_gate',
'cookie_duration_days' => 180,
'enable_google_analytics' => false,
'ga_measurement_id' => '',
'enable_marketing' => false,
'enable_preferences' => false,
'privacy_url' => home_url( '/privacy-policy/' ),
]
JavaScript API
window.wpLiteConsentGate.has('analytics');
window.wpLiteConsentGate.get();
window.wpLiteConsentGate.set({ analytics: true });
window.wpLiteConsentGate.open();
window.wpLiteConsentGate.close();
window.wpLiteConsentGate.onUpdate((consent) => {});
Browser event:
wp-lite-consent-gate:update
Integration example:
if (window.wpLiteConsentGate && window.wpLiteConsentGate.has('analytics')) {
// Run analytics-dependent code here.
}
Update listener:
window.addEventListener('wp-lite-consent-gate:update', function (event) {
if (event.detail && event.detail.analytics) {
// Analytics consent granted.
}
});
Consent cookie
The visitor choice is stored in a first-party cookie.
Default cookie name:
wp_lite_consent_gate
Default duration:
180 days
The cookie uses:
SameSite=Lax
Secure on HTTPS
The consent cookie is treated as necessary because it remembers the visitor's privacy choice.
Google Consent Mode
The plugin prints this default state before optional analytics runs:
ad_storage: 'denied'
ad_user_data: 'denied'
ad_personalization: 'denied'
analytics_storage: 'denied'
functionality_storage: 'denied'
personalization_storage: 'denied'
security_storage: 'granted'
After visitor interaction, WP Lite Consent Gate updates Consent Mode based on the stored choice.
In the default configuration, Google Analytics is disabled. If enabled through the config filter, the Google tag is loaded only after analytics consent.
Development checks
php -l wp-lite-consent-gate.php
php -l includes/config.php
php -l includes/frontend.php
php -l includes/privacy.php
node --check assets/consent.js
License
GPL-2.0-or-later.