Version: 1.5.1
WordPress Compatibility: 5.0+
PHP Version: 7.4+
License: GPL v2 or later
A GDPR-compliant WordPress plugin that provides cookie consent management with Google Analytics 4 integration, YouTube video blocking, multilingual support, and full customization options.
- GDPR Compliant: Full cookie consent management with granular controls
- Privacy-First Design: Users can decline analytics while maintaining essential functionality
- YouTube Cookie Control: Block YouTube videos until user consent is given
- Cookie Categorization: Technical (required), Analytical (optional), and YouTube (optional) cookie types
- 7-Day Cookie Duration: Reasonable expiration period with secure cookie flags
- Close Button: Non-persistent close option - popup reappears until consent is given
- Smooth Animations: jQuery-powered slide animations with reduced motion support
- Mobile Optimized: Responsive design that centers on mobile devices
- Keyboard Navigation: Full accessibility support with focus management
- Success Feedback: Customizable confirmation messages after saving preferences
- Complete Color Control: Professional default palette with full customization
- Custom Content: All popup text editable through admin interface
- HTML Support: Rich text formatting in descriptions with safe HTML tags
- Multiple Positions: Bottom-right, bottom-left, or bottom-center placement
- Typography Settings: Configurable font sizes (12-24px)
- Google Analytics 4: Privacy-focused GA4 loading with consent-based activation
- Google Tag Manager: Full GTM support with Consent Mode v2 compliance
- Consent Mode v2: All four required Google consent signals automatically managed (
ad_storage,analytics_storage,ad_user_data,ad_personalization) - YouTube Video Blocking: Blocks YouTube embeds until user consent (optional feature)
- Conflict Detection: Built-in scanner for other analytics implementations
- Shortcode Support:
[easylytics-btn]for reopening consent popup - Event System: JavaScript events for third-party integrations
- Multi-tab Sync: Consent status synchronized across browser tabs
easylytics/
├── easylytics.php # Main bootstrap file
├── uninstall.php # Clean uninstall script
├── README.md # This documentation
├── README.html # Documentation in HTML format
│
├── includes/ # Plugin core classes
│ ├── class-easylytics-core.php # Core orchestration class
│ ├── class-easylytics-admin.php # Admin interface & settings
│ ├── class-easylytics-assets.php # Scripts & styles management
│ ├── class-easylytics-frontend.php # Frontend popup display
│ ├── class-easylytics-youtube.php # YouTube blocking functionality
│ ├── admin-page-template.php # Admin page HTML template
│ │
│ └── admin-tabs/ # Admin interface tabs
│ ├── tab-general.php # General settings
│ ├── tab-content.php # Content customization
│ ├── tab-appearance.php # Color & styling options
│ ├── tab-tools.php # Tools & utilities
│ └── tab-description.php # Documentation display
│
├── assets/ # Frontend & admin assets
│ ├── css/
│ │ ├── easylytics.css # Frontend styles
│ │ └── easylytics-admin.css # Admin interface styles
│ │
│ └── js/
│ ├── easylytics.js # Frontend functionality
│ └── easylytics-admin.js # Admin interface scripts
│
└── languages/ # Translation files
├── easylytics.pot # Translation template
├── easylytics-en_US.po # English translation
├── easylytics-en_US.mo # English compiled
├── easylytics-sk_SK.po # Slovak translation
└── easylytics-sk_SK.mo # Slovak compiled
The plugin follows a modern, modular architecture with separated concerns:
EasyLytics_Core - Main orchestrator
- Initializes all plugin components
- Registers WordPress hooks
- Manages plugin lifecycle
- Provides default settings
EasyLytics_Admin - Admin interface
- Settings page rendering
- AJAX request handling
- Conflict scanner
- Settings save/reset logic
EasyLytics_Assets - Asset management
- Frontend script/style enqueuing
- Admin script/style enqueuing
- Dynamic CSS generation
- File versioning
EasyLytics_Frontend - Frontend display
- Cookie popup rendering
- Shortcode handling
- User consent interface
EasyLytics_YouTube - YouTube blocking
- Content filtering
- Bot detection for SEO
- Video placeholder creation
- Consent verification
✅ Maintainability - Each class has a single responsibility
✅ Scalability - Easy to add new features without modifying core
✅ Testability - Components can be tested independently
✅ Performance - Autoloader only loads needed classes
✅ Code Organization - Logical separation makes debugging easier
- Download the plugin ZIP file
- Go to Plugins → Add New → Upload Plugin
- Choose the ZIP file and click Install Now
- Click Activate Plugin
- Upload the
easylyticsfolder to/wp-content/plugins/ - Go to Plugins in WordPress admin
- Click Activate for EasyLytics
cd /path/to/wp-content/plugins/
git clone https://github.com/wiliak16/easylytics.gitThen activate via WordPress admin.
- Install & Activate the plugin
- Go to Settings → EasyLytics
- Enter your GA4 Measurement ID (G-XXXXXXXXXX)
- Optionally enable YouTube video blocking
- Customize appearance and content as needed
- GA4 Measurement ID: Your Google Analytics 4 tracking code (G-XXXXXXXXXX)
- GTM Container ID: Your Google Tag Manager container ID (GTM-XXXXXXX) — optional
- Popup Position: Choose from bottom-right, left, or center
- YouTube Video Blocking: Enable to block YouTube videos until user consent
- Cookie Information: Optional link to detailed cookie policy page
- Popup Title & Description: Main consent message with HTML support
- Button Labels: Customize all button text including "Hide Settings"
- Cookie Categories: Descriptions for technical, analytical, and YouTube cookies
- YouTube Blocking Messages: Customize title, message, and button text for blocked videos
- Success Message: Confirmation text after saving preferences
- Reset Function: Restore all texts to English defaults
- Color Palette: Background, text, button, and border colors
- Typography: Font size configuration (12-24px)
- Reset Options: Restore default professional color scheme
- Conflict Scanner: Detect other Google Analytics implementations
- Export/Import: Backup and restore plugin settings
- Advanced Options: Future feature placeholders
- Built-in Documentation: Complete plugin information and usage guide
| Element | Color | Hex Code |
|---|---|---|
| Background | White | #ffffff |
| Text | Dark Gray | #374151 |
| Primary Button (Accept All) | Blue | #3b82f6 |
| Secondary Button (Settings) | Black | #000000 |
| Tertiary Button (Reject All) | Red | #dc2626 |
| Border | Light Gray | #d1d5db |
All colors are fully customizable through the Appearance tab.
| User Action | Technical Cookies | Analytical Cookies | YouTube Cookies | GA4 Loading | Popup Behavior |
|---|---|---|---|---|---|
| Close (✖) | No cookies saved | No cookies saved | No cookies saved | No | Reappears on reload |
| Accept All | Enabled | Enabled | Enabled* | Yes | Hidden permanently |
| Reject All | Enabled | Disabled | Disabled | No | Hidden permanently |
| Custom Settings | Enabled | User Choice | User Choice* | Conditional | Hidden permanently |
*Only when YouTube blocking is enabled in admin
- Duration: 7 days
- Cookie Names:
eslt-cookies-consent(main consent)eslt-tech-cookies-consent(technical - always true)eslt-analytical-cookies(GA4 tracking)eslt-youtube-cookies(YouTube embeds)
- Security: Secure, SameSite=Lax flags
- Scope: Site-wide, path=/
When enabled in admin settings, YouTube videos are blocked until users give explicit consent:
- Admin enables blocking: Check "Disable YouTube Cookies" in General settings
- Videos are blocked: YouTube embeds show a consent overlay instead of playing
- User consent: Users can accept YouTube cookies from the popup or directly on blocked videos
- Videos unblock: After consent, all YouTube videos load normally
- WordPress auto-embeds (
[embed]https://youtube.com/watch?v=...) - Manual iframe embeds
- Gutenberg block embeds
- Widget embeds
All blocking messages are customizable in the Content tab:
- YouTube Blocked Title
- YouTube Blocked Message
- YouTube Accept Button text
[easylytics-btn][easylytics-btn text="Manage Cookies" class="my-class" style="background: #ff6b35;"]Parameters:
text- Button text (default: "Cookie Settings")class- Custom CSS classstyle- Inline CSS styles
Features:
- Shows current cookie settings when reopened
- Fully accessible with keyboard navigation
- Customizable text, CSS class, and inline styles
// Listen for consent events
$(document).on('easylytics:consentGiven', function(e, data) {
console.log('Consent given:', data.technical, data.analytical, data.youtube);
});
// Listen for YouTube consent
$(document).on('easylytics:youtubeConsentGiven', function(e, data) {
console.log('YouTube consent for video:', data.videoId);
});// Check consent status
if (window.EasyLyticsAPI.hasConsent()) {
console.log('User has given consent');
}
// Check YouTube consent
if (window.EasyLyticsAPI.getYouTubePreference()) {
console.log('YouTube cookies accepted');
}
// Show popup programmatically
window.EasyLyticsAPI.showPopup();
// Get detailed debug information
window.EasyLyticsAPI.debug();// Modify popup content
add_filter('easylytics_popup_content', function($content) {
return $content . '<p>Custom message</p>';
});
// Override default colors
add_filter('easylytics_default_colors', function($colors) {
$colors['eslt_primary_btn_bg'] = '#ff6b35';
return $colors;
});EasyLytics automatically detects search engine bots and shows them unblocked content for optimal SEO performance.
Detected Bots:
- Googlebot (Google)
- Bingbot (Microsoft Bing)
- Slurp (Yahoo)
- DuckDuckBot (DuckDuckGo)
- Baiduspider (Baidu)
- YandexBot (Yandex)
- FacebookExternalHit (Facebook)
When YouTube blocking is enabled:
- Users see: Consent overlay and blocked videos (GDPR compliant)
- Bots see: Normal YouTube embeds with full functionality
- Result: Full video indexing without compromising user privacy
What This Means:
✅ Video rich snippets appear in search results
✅ Videos indexed in Google Video Search
✅ Schema.org VideoObject data accessible
✅ Video sitemaps work correctly
✅ No negative SEO impact from blocking
How It Works:
- Plugin detects request from search bot via User-Agent
- Bot requests bypass YouTube blocking entirely
- Bots receive original HTML with proper iframe src attributes
- Regular users continue to see consent flow
Important: This is NOT cloaking - it's adaptive content delivery based on client capabilities (bots cannot execute JavaScript or provide consent).
When a GTM Container ID is configured, GTM is loaded in the <head> via a server-side injected snippet. Consent Mode v2 default signals are set before GTM fires, ensuring full compliance from the first page load.
EasyLytics implements Google's Consent Mode v2 specification. On every page load, all four required consent signals are set to denied by default before any Google tags fire:
ad_storage, analytics_storage, ad_user_data, ad_personalization
When the user accepts analytical cookies (or if consent was previously given), all four signals are updated to granted. When rejected, they remain denied. All signals map to the single Analytical Cookies category — no additional cookie categories are required.
This applies to both GA4-only and GTM configurations.
When users accept analytical cookies, GA4 is loaded with privacy-enhanced settings:
- ✅ IP anonymization enabled
- ✅ 7-day cookie expiration
- ✅ Consent Mode v2 signals sent before GA4 fires
- English (en_US): Complete translation
- Slovak (sk_SK): Complete translation
- Translation Template:
.potfile for additional languages
- Copy
easylytics.pottoeasylytics-{locale}.po - Translate strings using Poedit or similar tool
- Compile to
.mofile usingmsgfmt - Place in
/languages/directory
# Example: Creating German translation
cd languages/
cp easylytics.pot easylytics-de_DE.po
# Edit in Poedit
msgfmt easylytics-de_DE.po -o easylytics-de_DE.mo- Lightweight: < 50KB total plugin size
- Optimized Loading: Scripts load only when needed
- Cache Friendly: Compatible with WordPress caching plugins
- Mobile Optimized: Responsive design for all devices
- Reduced Motion: Respects user accessibility preferences
- Chrome 70+
- Firefox 65+
- Safari 12+
- Edge 79+
- Mobile browsers with ES6 support
- Verify plugin is activated
- Check if consent cookie already exists
- Clear browser cache and test in incognito mode
// Open browser console:
EasyLyticsAPI.debug();
// Verify GA4 ID format: G-XXXXXXXXXX
// Check analytical cookies accepted:
EasyLyticsAPI.getAnalyticalPreference();- Verify "Disable YouTube Cookies" is checked in admin
- Check browser console for JavaScript errors
- Confirm videos are standard WordPress embeds or iframes
// Open browser console:
EasyLyticsAPI.getYouTubePreference();
// Clear browser cookies and test again
// Check if page reload is required// Full debug information
EasyLyticsAPI.debug();
// Check popup state
EasyLyticsAPI.checkSettingsState();
// Check YouTube consent
EasyLyticsAPI.getYouTubePreference();
// Manual GA4 loading
EasyLyticsAPI.checkAndLoadGA4();
// Rebind all events
EasyLyticsAPI.rebindEvents();- PHP: 7.4 or higher
- WordPress: 5.0 or higher
- MySQL: 5.6 or higher
- JavaScript: ES6 support required
- jQuery: Included with WordPress
- CSS: Modern browser support for CSS variables
- Nonce Verification: All AJAX requests protected
- Capability Checks: Admin functions require proper permissions
- Input Sanitization: All user inputs properly sanitized
- XSS Prevention: Safe HTML rendering with
wp_kses() - CSRF Protection: WordPress nonce system implementation
- Direct Access Prevention: All PHP files check for
ABSPATH - Prefixed Classes: All CSS/JS classes use
eslt-prefix to avoid conflicts
- 🐛 Fixed GA4 not loading on page load when consent was already stored (early return guard conflict with server-side dataLayer initialization)
- ✨ Google Tag Manager support — added GTM Container ID field in General Settings
- ✨ Consent Mode v2 — all four required signals (
ad_storage,analytics_storage,ad_user_data,ad_personalization) set server-side in<head>before any tags fire - ✨ GTM snippet injected via
wp_headat priority 1 for correct load order - ✨ Consent signals automatically updated to
granted/deniedbased on analytical cookie choice - ✨ Works with GA4-only, GTM-only, or both simultaneously
- ⚡ Backward compatible — existing GA4-only installations unaffected
- ✨ Added YouTube video blocking feature
- ✨ Added customizable YouTube blocking messages
- ✨ Added bot detection for SEO optimization
- ✨ Improved JavaScript logic for conditional feature handling
- ✨ Enhanced admin interface with YouTube options
- ✨ Added
.eslt-prefix to all notice classes to avoid WordPress conflicts - 🐛 Fixed CSS class conflicts with WordPress core
- 🐛 Fixed button layout issues in cookie popup
- 📝 Updated translations for YouTube features
- ⚡ Performance improvements and code optimization
- Added tertiary button (Reject All)
- Enhanced color customization
- Improved accessibility features
- Added multilingual support
- Improved mobile responsiveness
- Added shortcode support
- Initial public release
- GDPR compliance features
- GA4 integration
We welcome contributions! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Follow WordPress coding standards
- Add translations for new strings
- Test thoroughly across browsers
- Submit a pull request
# Clone repository
git clone https://github.com/wiliak16/easylytics.git
cd easylytics
# Install development dependencies (if any)
npm install
# Compile translations
msgfmt languages/easylytics-en_US.po -o languages/easylytics-en_US.moThis plugin is licensed under the GPL v2 or later.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- Documentation: This README file
- Issues: Report bugs via GitHub
- WordPress Forum: Plugin support forum
- Website: wiliak.sk
wiliak.sk
Website: https://wiliak.sk
EasyLytics - Simple, compliant, effective cookie consent management for WordPress.
Made with ❤️ for the WordPress community.