Simple Consent Banner
a very simple consent banner plugin for wordpress
by Trân Nguyen Ngoc - Fruit du dragon · github.com/tran00/simple-consent-banner · website
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/tran00/simple-consent-banner/archive/refs/heads/main.zipA consent banner for managing user analytics preferences with localStorage persistence.
Description
Simple Consent Banner displays a GDPR-compliant consent banner on your WordPress site, allowing users to accept or reject analytics cookies. The plugin uses localStorage to persist user preferences and dispatches custom events for integrating with analytics solutions.
Features:
- Simple, elegant consent banner UI
- localStorage persistence of user preferences
- Custom event dispatching for analytics integration
- Automatic activation of deferred analytics scripts
- Full i18n support for translations
- Responsive design
Installation
- Upload the
simple-consent-bannerfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- The banner will appear at the bottom of your site
Usage
Once activated, the banner appears automatically on all pages.
Analytics Script Integration
To defer analytics scripts until user consent:
<script type="text/plain" data-consent-category="analytics" src="https://example.com/analytics.js"></script>
JavaScript API
// Check if user has accepted analytics
window.inplaceConsent.hasAnalyticsConsent();
// Programmatically accept/reject
window.inplaceConsent.acceptAnalytics();
window.inplaceConsent.rejectAnalytics();
// Listen for consent changes
window.addEventListener('inplace-consent-change', function(event) {
console.log('Analytics accepted:', event.detail.analytics);
});
Changelog
1.0.0
- Initial release
License
This plugin is licensed under the GPL v2 or later.