Skip to content
Québec Studio

Craft CMS extension

Cookie Consent Kit

Cookie consent, done right: no third-party cookie before the visitor agrees, and pages that stay cached. Built for Quebec’s Law 25.

Craft CMS 5
v5.0.8
Craft CMS 6
v6.0.10
Editions
Lite (free), Pro
Also for
Statamic, Laravel

JavaScript API

window.qsmConsentKit

window.qsmConsentKit.get()                    // {v, ts, cat:{…}} | null
window.qsmConsentKit.granted('statistics')    // bool
window.qsmConsentKit.on('statistics', fn)     // runs now if already granted, otherwise on the next change
window.qsmConsentKit.set({ statistics: true })
window.qsmConsentKit.acceptAll()
window.qsmConsentKit.refuseAll()
window.qsmConsentKit.open()
window.qsmConsentKit.close()
window.qsmConsentKit.ready                     // true once the script has run

document.addEventListener('qsm-consent-kit:change', e => e.detail);

open() reopens the banner. Call it from the site's own link when reopenButton is off.

get() returns null until a decision is made. Under Global Privacy Control it returns a refusal carrying gpc: true, with no category granted — a state the browser signals and the plugin never writes to a cookie.

The <head> bootstrap leaves window.qsmConsentKitBootstrap = { state } behind, which is what lets a video facade lift before the main script has loaded.

Conditional tags

A tag marked with a category is activated once that category is granted:

<script type="text/plain" data-consent="marketing" data-consent-src="https://…"></script>
<script type="text/plain" data-consent="statistics">/* inline code */</script>
<iframe data-consent="marketing" data-consent-src="https://…"></iframe>
  • A script is recreated with a runnable type; an iframe gets its src.
  • Tags are activated one category at a time, in inventory order, and in document order within a category.
  • Activated elements carry data-consent-done.

A vendor's <noscript> fallback is fetched by the browser regardless of consent. Leave it out.

{ "v": 1, "ts": 1787598237, "cat": { "statistics": false, "marketing": false } }
PropertyValue
EncodingURI-encoded JSON
Scopehost-only, path=/
AttributesSameSite=Lax; Secure over HTTPS
vthe version setting when the decision was made
tsUnix time of the decision
catone boolean per optional category

A cookie whose v differs from version, or that cannot be read, is treated as absent: the banner is shown.

A Craft CMS extension that doesn’t exist yet?

If Craft CMS doesn’t do what you need yet, we can build it for you.

Let’s talk

We use cookies

This site uses cookies that are required for it to work. With your consent, we also use cookies to measure traffic. You can change your mind at any time. Privacy policy

Your cookie preferences

Always on

Required for the site to work and for form security. These cannot be turned off.

Necessary
Cookie Set by Purpose Retention
CraftSessionId This site Keeps your browsing session. Session
CRAFT_CSRF_TOKEN This site Protects forms against cross-site request forgery. Session
cookie_consent This site Remembers your cookie choices. 6 months

Help us understand how the site is used so we can improve it. Measured with Matomo.

Statistics
Cookie Set by Purpose Retention
_pk_id.* This site Recognizes the browser from one visit to the next, without identifying you. 13 months
_pk_ses.* This site Groups the pages viewed during a single visit. 30 minutes