Documentation
Module 4.6.0 What’s new
Modules and consent · Integrate into your module

Browser side and page cache

With a page cache, every visitor receives the same HTML: the decision is made in the browser. Kixell Tag gives your scripts the visitor's choice and can itself run a script after consent.

For: developer Checked with module 4.6.0 · updated Nov 29, 2026

Deciding in the right place #

Do Avoid
Decide in the page script (kixelltag_consent_state) or in a module front controller called by the page Deciding in displayHeader, displayFooter or the product and category page hooks of a cached page
Write HTML that is identical for all visitors: scripts for Kixell Tag to run, settings passed through Media::addJsDef() Writing HTML that depends on the visitor's consent: the next visitor would receive it
Call hasVendorConsent() in the requests that PrestaShop never caches Trusting a hasVendorConsent() answer written into cached HTML

The page script loads normally, without waiting for consent: it only listens.

Getting the API #

Get the API
window.kixelltagOnReady = window.kixelltagOnReady || [];
window.kixelltagOnReady.push(function (KixellTag) {
    // KixellTag.on(...) and KixellTag.hasConsent(...)
});
  • The function is called as soon as Kixell Tag is ready, whatever order the scripts load in. Added later, it is called at once.
  • If Kixell Tag is missing or its banner does not start, the function is never called. No call, no consent: the module starts nothing.
  • Always go through this queue. Do not read window.KixellTag, nor the Kixell Tag cookies (_kt_token) or local storage: their format is private, signed, and may change.
React to each state
window.kixelltagOnReady = window.kixelltagOnReady || [];
window.kixelltagOnReady.push(function (KixellTag) {
    KixellTag.on('kixelltag_consent_state', function (state) {
        if (!state || !state.chosen) {
            return; // No choice yet: no consent, start nothing.
        }
        if (KixellTag.hasConsent('mymodule')) {
            start(); // Must do nothing if the processing is already running.
        } else {
            stop();  // Stops the processing and deletes what was stored.
        }
    });
});

The event arrives:

  1. when the banner starts, on every page, whether a choice is recorded or not;
  2. after each choice recorded by the server (accept all, refuse all, save preferences, reopen the banner and change one's mind), without reloading the page.
Field Content
chosen true if the visitor has a recorded choice, false before
vendors_consent The identifiers of all accepted partners (kpv:12, iab:755…). Empty when chosen is false

A function added late immediately receives the last state, not the history. The state is a copy: changing it changes nothing. As the function can run several times on the same page, write start() and stop() so that a second call neither restarts nor deletes anything twice.

KixellTag.hasConsent() #

Examples
KixellTag.hasConsent('mymodule'); // a key declared by a module
KixellTag.hasConsent('kpv:12');   // any partner, by its identifier
KixellTag.hasConsent('iab:755');  // Google Advertising Products
  • Same answer as hasVendorConsent() on the server: same rules, same consent token.
  • false as long as the visitor has not chosen, for an unknown key and for a partner that is not ticked.
  • Call it in the kixelltag_consent_state function, or after its first call: before the first state, it returns false.

Letting Kixell Tag run a script #

Without writing any JavaScript, the module can print a script that the browser does not run, and let Kixell Tag run it at the right time:

HTML printed by the module
<!-- Run only after a choice that accepts the 'mymodule' partner -->
<script type="kixelltag/javascript" data-kt-vendor="mymodule">
    startMyFeature();
</script>

<!-- External file, same rule; ${GDPR_APPLIES} and ${GDPR_CONSENT} are replaced in src -->
<script type="kixelltag/javascript" data-kt-vendor="mymodule"
        src="https://cdn.example.com/tag.js?gdpr=${GDPR_APPLIES}&amp;gdpr_consent=${GDPR_CONSENT}"></script>
Rule Details
When it runs After a recorded choice, and if the data-kt-vendor partner is accepted. The attribute accepts a key or an identifier
Without data-kt-vendor The script runs after any choice, even "refuse all". Never put a partner's processing in it
Execution Kixell Tag inserts in its place a copy of type text/javascript, with all its other attributes
src ${GDPR_APPLIES} becomes 1 and ${GDPR_CONSENT} the visitor's TC String
Scripts added later Scripts inserted into the page after it has loaded are handled the same way
Refusal, then consent on the same page The script waits, then runs after consent, without reloading
Consent, then refusal on the same page Once run, a script cannot be taken back. If it must stop, it listens to kixelltag_consent_state itself, like views/js/kixconsentdemo-errors.js in the demo
Order External files run asynchronously: do not rely on their order, and do not use document.write

Keep these scripts for third-party tags you do not control, such as an SDK loaded from a CDN. For your own code, prefer a normal script that listens to kixelltag_consent_state: only such a script can stop.

Rules in the page #

  • Nothing on the device before a yes: no cookie, no localStorage, no sessionStorage, not even a trace of a refusal.
  • On a no, delete what the page stored.
  • A cookie the server needs is set by the server, after a check on the server: see Integration recipes.

Other events

KixellTag.on() also accepts kixelltag_consent_ready, kixelltag_consent_chose, kixelltag_consent_updated, kixelltag_page_view and popupVisible, described in JavaScript API. They replay their whole history and are meant for tag managers. For a module's consent, use only kixelltag_consent_state and hasConsent().

Missing or wrong information? Tell the support team