Live Demo: Try this and other plugins live — no installation, no risk: demo.markus-michalski.net
If "Activate Cookie Consent" is on, the storefront loads the Klaro library and hands it the configuration built from the module settings and your shop's cookie services.
The module ships the extension layout/base.html.twig for the Apex theme. It outputs in the storefront:
window.klaroConfig,defer.Everything appears only when "Activate Cookie Consent" is on.
The module ships no template extension for other themes. There, no banner appears until you create your own extension of the base layout that outputs the same elements.
The link is not added to the footer automatically. You include the bundled widget where the link should appear, for example in the footer's service menu:
{% include "@mmd_klaroconsent/widget/klaro_settings_link.html.twig" %}
Optionally pass a CSS class and an icon:
{% include "@mmd_klaroconsent/widget/klaro_settings_link.html.twig" with {
linkClass: 'my-custom-class',
showIcon: true
} %}
| Parameter | Default | Description |
|---|---|---|
linkClass |
footer-link |
CSS class of the link, mmd-klaro-settings-link is always added |
showIcon |
false |
Shows the icon fa fa-cookie-bite before the text |
The link reads "Cookie Settings" (German "Cookie-Einstellungen") and reopens the dialog, so visitors can change their decision at any time. If the module is deactivated, the widget outputs nothing.
The module does not change any scripts in your templates. For a service to run only after consent, you mark its script or embed using the Klaro method. data-name must match the service's Technical Name.
Script with src:
<script type="text/plain"
data-type="text/javascript"
data-name="google-analytics"
data-src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
Inline script:
<script type="text/plain" data-type="text/javascript" data-name="google-analytics">
// your code
</script>
Embed (iframe):
<iframe data-name="youtube" data-src="https://www.youtube-nocookie.com/embed/VIDEO_ID"></iframe>
With the option "Contextual consent only" on a service, "Accept All" does not include that service. It is then released through the placeholder on the embed.
If "Enable Google Consent Mode v2" is on, the template writes this snippet into the page before the Klaro configuration:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied',
'functionality_storage': 'denied',
'personalization_storage': 'denied',
'security_storage': 'granted'
});
The module only sets these default values. After consent it sends no
gtag('consent', 'update', ...)call and does not map Klaro services to Google consent types. You have to trigger updating the values yourself, for example through your Google tag setup. The help texts in the admin ("Automatically sync consent") describe more than the module does.
The snippet does not load any Google script. You include the Google scripts yourself with their own service, as described above.