Consentl for Magento 2 / Adobe Commerce

The Consentl module for Magento and Adobe Commerce 2.4.6 to 2.4.8: the loader right after <meta charset>, a Cookie Restriction Mode bridge and CMS widgets. Luma and Hyvä.

Loader first in <head>
Yes
Download
consentl-module-consent-1.1.0.zip · Version 1.1.0 · 201 KB · SHA-256

The module consentl/module-consent connects your Magento store to Consentl. It stores the site key per website or store view, inserts the loader directly after <meta charset>, bridges each choice to Magento's Cookie Restriction Mode and provides CMS widgets. Banner design, texts in 34 languages, region rules and blocking rules are managed in the Consentl dashboard.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.6, 2.4.7 or 2.4.8; PHP 8.1 to 8.4 as supported by your Magento version.
  • Luma or Hyvä themes; built-in Full Page Cache and Varnish are supported.
  • A Consentl account (Free plan available).

Install

From the zip (Downloads): unzip it into app/code/Consentl/Consent/, so that composer.json is at the top of that folder, then run:

bin/magento module:enable Consentl_Consent
bin/magento setup:upgrade
bin/magento setup:di:compile              # production mode
bin/magento setup:static-content:deploy   # production mode
bin/magento cache:flush

With Composer: composer require consentl/module-consent once the package is published, then the same commands.

Connect your site

Go to Stores → Configuration → Consentl → Cookie Consent and select the scope first (the key and language can differ per website or store view).

  • Connect to Consentl signs you in or creates a free account, lets you pick or create the site for this store's domain and brings you back with the Site key saved and Consentl enabled. The return link is only valid in the same admin session.
  • Or paste the key (sk_ + 24 characters) and set Enable Consentl to Yes.

Flush the Full Page Cache after saving if your setup does not do it automatically.

Configure

  • Banner language: Automatic maps the store view locale to the closest Consentl language (de_AT → de, pt_BR → pt-BR, nb_NO → nb). You can also force a language.
  • Cookie Restriction Mode bridge (recommended if you use Magento's Google Analytics or Google Tag modules):
    1. Set Stores → Configuration → General → Web → Default Cookie Settings → Cookie Restriction Mode to Yes.
    2. Set Sync Consentl decisions to Cookie Restriction Mode to Yes.
    3. Set Hide Magento's native cookie notice to Yes.
    4. Optional: Reload the page after the first opt-in, so Luma's Google modules start on the same page view instead of the next one.
  • Advanced: keep the loader position First element in <head>.

CMS widgets (Content → Pages / Blocks → Insert Widget):

Widget Directive
Cookie declaration {{widget type="Consentl\Consent\Block\Widget\CookieDeclaration"}}
Privacy request form {{widget type="Consentl\Consent\Block\Widget\PrivacyRequest"}}
EU withdrawal form {{widget type="Consentl\Consent\Block\Widget\Withdrawal"}}
Cookie settings link {{widget type="Consentl\Consent\Block\Widget\PreferencesLink" label="Cookie settings"}}

Any <a href="#consentl">…</a> in a CMS block re-opens the preferences too.

Check that it works

  1. View the page source: the loader comes directly after <meta charset>. On Luma, Magento's inline RequireJS configuration is above it; it loads nothing.
  2. With the bridge on: before any choice in an opt-in region, the cookie user_allowed_save_cookie is not set; after accepting a category it is set for your website.
  3. Pages stay cacheable: the output contains no visitor-specific data.

Content Security Policy

The module allows https://api.consentl.com in Magento's CSP whitelist and prints no inline JavaScript, so it works with the restrict-mode checkout CSP of 2.4.7+ and with Hyvä CSP themes.

For developers

Consentl\Consent\ViewModel\Consent::allows('marketing') reads the consentl cookie, for uncached contexts only (checkout, customer account, AJAX). On cached pages, gate tags in HTML with <script type="text/plain" data-consentl="marketing">…</script>.

Limitations

  • Scripts that another extension prints above <meta charset>, or inline scripts a theme places before the head content, run before Consentl.
  • Adobe Commerce's Magento_GoogleTagManager (closed source) has not been verified with the bridge. Use Consent Mode (Pro and higher, switched on in the dashboard): Consentl sets defaults and updates, and GTM tags respect them.
  • Magento has a single opt-in flag, so the bridge sets it when any optional category is granted.
  • On Hyvä, if Hyvä's own cookie notice still appears, remove it in your theme with <referenceBlock name="cookie_notices" remove="true"/> in Magento_Cookie/layout/default.xml.
  • Uninstalling leaves the configuration values under consentl/* in core_config_data; delete them with bin/magento config:delete if needed.

Stuck? Write to [email protected] — we answer in English on business days.