RoyalComply – Cookie Consent, GDPR & CCPA Compliance Banner

Descriere

RoyalComply is a cookie consent and privacy compliance plugin for WordPress. It blocks analytics and marketing scripts until consent is given, supports Google Consent Mode v2, and adapts banner behavior based on the visitor’s jurisdiction (GDPR, CCPA, and 19 US state privacy laws).

The plugin runs entirely on your server. It does not connect to any external services.

Works With Your Stack

RoyalComply integrates with the analytics, advertising, and tag management tools you already use — no per-vendor configuration required:

  • Analytics — Google Analytics 4 (GA4), Google Tag Manager, Hotjar, Microsoft Clarity, Matomo, Plausible, Fathom, Mixpanel, Amplitude, Heap.
  • Advertising pixels — Meta Pixel (Facebook / Instagram), Google Ads, LinkedIn Insight Tag, TikTok Pixel, Pinterest Tag, Twitter (X) Pixel, Snapchat Pixel, Reddit Pixel.
  • Themes and page builders — Elementor, Divi, Beaver Builder, Bricks, Gutenberg, Astra, GeneratePress, Kadence, Avada, OceanWP — works with any theme or builder.
  • eCommerce and memberships — WooCommerce, Easy Digital Downloads, MemberPress, Restrict Content Pro, LearnDash, LifterLMS. Cart and session cookies are auto-categorized as „Necessary” and never blocked.
  • Caching plugins — WP Rocket, W3 Total Cache, LiteSpeed Cache, WP Super Cache, FlyingPress, Cloudflare APO. Banner state is read client-side from localStorage so cached pages render correctly for every visitor.
  • Multilingual — Polylang, WPML, qTranslate, TranslatePress. Banner text supports per-language translation; the language-selection cookie is auto-categorized as „Preferences”.
  • CDN geo headers — Cloudflare (CF-IPCountry), Fastly, KeyCDN, Sucuri. Geo detection runs server-side from existing CDN headers with a browser-timezone fallback — no IP geolocation API is contacted.

RoyalComply is a free alternative to CookieYes, Complianz, Cookiebot, Iubenda, OneTrust, and Termly — without per-page-view billing, per-domain licensing, or external SaaS dependencies.

Features:

  • Script blocking — Uses the WordPress script_loader_tag filter to change the type attribute of analytics and marketing scripts to text/plain until consent is given, preventing execution.
  • Google Consent Mode v2 — Outputs the gtag('consent', 'default', {...}) call with a denied state before Google Tag Manager loads, and sends consent update events when the visitor makes a choice.
  • Regional banner behavior — Detects the visitor’s region from CDN request headers (Cloudflare CF-IPCountry etc.) with a browser-timezone fallback. Banner behavior switches between opt-in (GDPR), opt-out (CCPA), and other jurisdictions as configured.
  • Cookie scanner — Scans your site’s rendered HTML for known third-party script patterns (Google Analytics, Facebook Pixel, Hotjar, etc.) and matches them against a built-in database of 50+ cookie names. The scanner reads HTML your site already produces. No outbound HTTP requests are made.
  • Consent logging — Stores each consent choice with a SHA-256 hashed visitor identifier, timestamp, and category selections. Exportable to CSV. No IP addresses or personally identifiable information are stored.
  • Banner customization — 6 position options, bar or box layout, full color control. Combined CSS and JavaScript on the frontend is under 8KB.
  • Geo detection — Reads the CF-IPCountry and similar headers already present in the incoming request. Falls back to the browser’s timezone via JavaScript. No IP lookup service is called.

Cookie Categories:

  • Necessary — Always allowed. WordPress sessions, WooCommerce cart, PHP sessions.
  • Analytics — Google Analytics, Hotjar, Clarity, Matomo, Plausible.
  • Marketing — Facebook Pixel, Google Ads, LinkedIn, TikTok, Pinterest.
  • Preferences — Language selection (Polylang, WPML, qTranslate).

Compliance Coverage:

  • GDPR (EU/EEA) — Opt-in consent required
  • CCPA (California) — Opt-out with „Do Not Sell” link
  • VCDPA (Virginia), CPA (Colorado), CTDPA (Connecticut), UCPA (Utah), TIPA (Tennessee), ICDPA (Indiana), MTCDPA (Montana), TDPSA (Texas), OCPA (Oregon), DPDPA (Delaware), FDBR (Florida), NJDPA (New Jersey), NHDPA (New Hampshire), KCDPA (Kentucky), NEBDPA (Nebraska), ICDPA (Iowa), MCDPA (Maryland), MNDPA (Minnesota)

External services

RoyalComply does not connect to any third-party services. The plugin runs entirely on your own WordPress install and does not send data to any external server, API, or CDN.

The built-in cookie scanner makes a single loopback HTTP request to your own site’s homepage (home_url( '/' )) using the WordPress wp_remote_get() function, with a 10-second timeout. This request goes to the same WordPress install; no third-party service is contacted. The scanner then reads the returned Set-Cookie response headers and the HTML response body, and searches the body for known third-party script hostnames (for example google-analytics.com, connect.facebook.net, js.stripe.com, widget.intercom.io, cdnjs.cloudflare.com). These hostnames are stored as pattern strings inside the plugin and are compared against the response body using PHP’s stripos() function. The plugin does not make any network requests to the services the pattern strings refer to; it only reads HTML that your own site already generates.

The scanner runs only when the site administrator clicks the „Scan Site” button in the RoyalComply admin screen. It is not run on a schedule and is not triggered by visitors.

Geo detection reads HTTP headers that are already present in the incoming page request (for example Cloudflare’s CF-IPCountry header) and, as a JavaScript fallback, reads the visitor’s timezone from the browser using Intl.DateTimeFormat().resolvedOptions().timeZone. No IP geolocation API is contacted.

Google Consent Mode v2 outputs a gtag('consent', 'default', {...}) JavaScript call in the page. This call runs in the visitor’s browser and is consumed by Google Tag Manager or gtag.js if those are already installed on the site. RoyalComply itself does not load Google’s scripts; the integration only configures the consent state that the site’s existing Google scripts read.

Capturi ecran

  • Dashboard with compliance overview and consent statistics.
  • Cookie management with category badges and scanner.
  • Banner design with live preview and color customization.
  • Consent log with export and filtering.
  • Settings page with region detection and script blocking options.

Instalare

  1. Upload the royalcomply folder to /wp-content/plugins/.
  2. Activate the plugin through the Plugins menu.
  3. Go to RoyalComply > Dashboard to configure.
  4. Run the cookie scanner to detect existing cookies.
  5. Customize your banner appearance under Banner Design.

Întrebări frecvente

How does script blocking work?

RoyalComply uses WordPress’s script_loader_tag filter to change script types from text/javascript to text/plain until consent is given. This prevents scripts from executing. The approach does not require output buffering or DOM manipulation.

Does it work with Google Tag Manager?

Yes. When Google Consent Mode v2 is enabled, RoyalComply outputs the required gtag('consent', 'default', {...}) call before GTM loads, then updates consent state when the user makes a choice.

Is this plugin GDPR compliant?

RoyalComply is designed to help site owners meet GDPR’s consent requirements. It blocks analytics and marketing scripts until the visitor gives explicit opt-in consent, stores a record of each consent choice with a SHA-256 hashed identifier, and provides a „Reject All” button with the same prominence as „Accept All”. Whether a given site is fully GDPR compliant also depends on the rest of its privacy practices (privacy policy, data processing agreements, etc.), which are outside the scope of this plugin.

Does this work for CCPA?

Yes. When the visitor’s region is detected as California (or any configured opt-out jurisdiction), RoyalComply switches the banner to opt-out mode and displays a „Do Not Sell or Share My Personal Information” link that records the visitor’s opt-out choice.

Does it make external API calls?

No. Geo detection uses CDN headers (Cloudflare, etc.) that are already present in the request, plus browser timezone as a fallback. No third-party services are contacted.

Is the consent log GDPR-compliant?

Yes. Visitor identifiers are SHA-256 hashed with a site-specific salt. No IP addresses or personally identifiable information is stored.

Can I use this with WooCommerce?

Yes. WooCommerce session and cart cookies are automatically categorized as „necessary” and are never blocked.

How does RoyalComply compare to CookieYes, Complianz, Cookiebot, or Iubenda?

CookieYes, Complianz, Cookiebot, Iubenda, OneTrust, and Termly are commercial cookie consent solutions that typically charge $9–49/mo per site or per-page-view (Cookiebot’s pricing scales with monthly visitors and can reach hundreds of dollars per month for high-traffic sites). RoyalComply is free with no usage limits, no per-page-view billing, and no external SaaS dependency. Core features — script blocking, Google Consent Mode v2, GDPR opt-in, CCPA opt-out, regional auto-detection, consent logging, and the cookie scanner — are included.

Does RoyalComply work with Google Analytics 4 (GA4)?

Yes. Enable Google Consent Mode v2 in RoyalComply settings and the plugin outputs the required gtag('consent', 'default', { analytics_storage: 'denied', ad_storage: 'denied', ... }) call before GA4 or Google Tag Manager loads. When the visitor accepts, RoyalComply fires a gtag('consent', 'update', ...) event with their selections and GA4 begins receiving data. Without consent, GA4 still runs in cookieless mode and reports basic anonymized events (this is Google’s intended Consent Mode v2 behavior).

Does RoyalComply work with Meta Pixel (Facebook Pixel) or other advertising pixels?

Yes. Meta Pixel, Google Ads, LinkedIn Insight Tag, TikTok Pixel, Pinterest Tag, Twitter (X) Pixel, Snapchat Pixel, and Reddit Pixel are auto-categorized as „Marketing” cookies and blocked until the visitor accepts marketing consent. The script-blocking approach uses WordPress’s script_loader_tag filter to change each script’s type attribute to text/plain until consent is granted, so pixels never fire prematurely.

Will RoyalComply slow down my WordPress site?

No. The combined frontend CSS and JavaScript is under 8KB. Banner state is checked from localStorage, which is faster than a server round-trip. The cookie scanner runs only when an admin clicks „Scan Site” — never on a visitor request.

Does RoyalComply work with caching plugins like WP Rocket, W3 Total Cache, or LiteSpeed Cache?

Yes. The banner is rendered with the same HTML for every visitor and the show/hide decision is made client-side by reading localStorage. Page caches serve the same HTML to all visitors and the banner correctly hides for returning visitors who already gave consent. No cache exclusion rules required.

How do I show a „Do Not Sell My Personal Information” link for California (CCPA) visitors?

In RoyalComply settings, enable CCPA mode and set California as an opt-out jurisdiction. When a visitor’s request arrives with a CDN header indicating California (or matches a California timezone fallback), the banner automatically switches from opt-in to opt-out mode and displays the „Do Not Sell or Share My Personal Information” link. Clicking the link records the visitor’s opt-out in the consent log.

Can I export my consent log for DPO or compliance audits?

Yes. Go to RoyalComply > Consent Log and click „Export CSV”. The export includes hashed visitor IDs, timestamps, region, banner version, and category selections — sufficient for demonstrating consent under GDPR Article 7 and CCPA record-keeping requirements. No IP addresses are exported.

Recenzii

Nu există nicio verificare pentru acest modul.

Contributori și dezvoltatori

„RoyalComply – Cookie Consent, GDPR & CCPA Compliance Banner” este un software open-source. La acest modul au contribuit următoarele persoane.

Contributori

Istoric modificări

1.0.6

  • Hardening: All $wpdb queries that referenced custom tables now use the %i identifier placeholder (WordPress 6.2+) instead of interpolating the table name into the SQL string. The previous interpolations were not exploitable — the table name was always $wpdb->prefix . 'rcomply_*' (hardcoded literal, no user input) — but they caused 27 PCP / WPCS warnings and made the code harder to audit. Requires at least raised from 5.9 to 6.2 because %i is a 6.2+ feature.

1.0.5

  • Fix: Per-request data (CSRF nonce + geo-detected region) was inlined as a var rcomplyConfig script in the rendered HTML, so when a full-page cache (ForgeCache, WP Rocket, W3TC, or any host CDN) captured the response the FIRST visitor’s values were baked in and served to everyone afterwards. Two consequences: the nonce eventually expired past WordPress’s nonce TTL (~24h), causing every visitor’s consent-log AJAX to return „Security check failed” once the cache outlived the token; and the geo result froze on the first visitor’s country, so a UK visitor landing on a cache populated by a US visitor would display banner state derived from the wrong region. Both values are now fetched on demand via a new rcomply_init AJAX endpoint at admin-ajax.php — uncached by every cache plugin — and returned per request. Cached HTML now contains only static config (categories, expiry days, GCM toggle, etc.) which is identical for all visitors.
  • Internal: Added the rcomply_init AJAX action (public, no nonce required since its purpose is to issue one). Returns {nonce, region, country} for the current request. banner.js calls it lazily — only the first time a consent action needs to POST.

1.0.4

  • New: WordPress Playground live preview — click „Live Preview” on the plugin listing to try the cookie consent banner in a browser sandbox with sample content pre-loaded.
  • New: Video walkthrough embedded on the plugin listing page.

1.0.3

  • Fix: All boolean settings checkboxes (Hide for Admins, Enable Banner, Auto-Detect Location, Script Blocking, Reload on Consent, Google Consent Mode, Consent Logging, CCPA, and the Is Regex flag on cookie rules) now correctly persist when unchecked. Previously, unchecking and saving had no effect because the AJAX handler used isset() to detect the checkbox state, but the JavaScript always sends every checkbox as 1 or 0 (so the key was always present, making isset() always return true). Switched to ! empty() which correctly treats „0” as false.

1.0.2

  • Compliance: Renamed text domain from royal-comply to royalcomply so it matches the plugin slug, as required by WordPress.org internationalization guidelines.
  • Readme: Rewrote the plugin description in a neutral, factual tone, removing promotional and comparative phrasing.
  • Readme: Added an „External services” section that documents how the cookie scanner and geo-detection work, and clarifies that the plugin makes no outbound HTTP requests.
  • Code: Added file-level documentation to the scanner and script-blocker classes explaining that the hostname strings inside them are local pattern-matching dictionaries, not URLs that the plugin contacts.

1.0.1

  • Security: Removed unnecessary sslverify bypass on cookie scanner
  • Compatibility: Tested up to WordPress 6.9.3

1.0.0

  • Initial release
  • Cookie consent banner with 6 position options
  • Script blocking via the script_loader_tag filter
  • Google Consent Mode v2 support
  • Built-in database of 50+ known cookies
  • Cookie scanner for site analysis
  • GDPR-compliant consent logging with CSV export
  • Geo detection via CDN request headers and browser timezone (no third-party IP lookup)
  • CCPA „Do Not Sell” support
  • Customizable banner colors, text, and layout
  • Privacy and cookie policy text generator