Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Ketch integration for the Krenalis JavaScript SDK

Official integration to handle consents with the Ketch consent management platform when using the Krenalis JavaScript SDK.

How it works

withKetch(krenalis) wraps the load method of the Krenalis SDK, so that:

  1. The SDK is loaded only once the user's choice is known. Until then, the calls to the SDK (page, track, ...) are queued, and the SDK neither stores data on the device nor sends events. The SDK is loaded when Ketch has communicated the user's consent and either:
    • the Ketch consent experience (the banner) is closed, because the user has made a choice or has closed it, or it is not shown at all, typically because the user has already made a choice in a previous visit;
    • no purpose of the user's jurisdiction requires the user's opt-in (for example, where the banner is just a notice), so there is no choice to wait for.
  2. Every event includes the user's consent choices in context.consents. This includes events queued before Ketch reported consent and events generated from the query string. The field records the user's choice for each Ketch purpose, for example { "analytics": true, "advertising": false }.
  3. Changes of the consent made by the user later are forwarded through setConsents and applied to the subsequent events.

The Ketch tag can be added to the page before or after the SDK: if it is not there yet, the integration waits for it.

The integration also handles initialization after Ketch has already resolved the consent or closed the banner. Ketch sends the current consent to new consent listeners as soon as it is available, even if resolved before registration, so no separate lookup is needed. A one-time hideExperienceReasonUpdated listener recovers the last known reason, including willNotShow when no banner is needed. The regular hideExperience listener handles subsequent closures, including repeated closures with the same reason.

Case When the SDK is loaded
New user, a purpose requires opt-in (e.g. GDPR) when the user makes a choice or closes the banner
New user, no purpose requires opt-in as soon as Ketch communicates the consent
Returning user as soon as Ketch communicates the stored consent
The user never interacts with the banner never
Ketch is never loaded (e.g. blocked by the browser) never

Usage

The integration works with the Krenalis snippet; installing the SDK as an npm package is not supported.

In the Krenalis admin, the page of the JavaScript connection generates the snippet with the integration when Consent management is set to Ketch.

To set it up manually:

  1. Add the Ketch Smart Tag to the page, as described in the Ketch documentation.

  2. Add this script before the Krenalis snippet:

    <script src="https://cdn.krenalis.com/krenalis-ketch.min.js"></script>
  3. In the Krenalis snippet, replace the load call:

    krenalis.load("<event write key>", "<endpoint>");

    with:

    withKetch(krenalis).load("<event write key>", "<endpoint>");

Warning

If the snippet still calls krenalis.load(...) directly, the SDK is loaded without waiting for the consent.

Development

You'll need Node.js (with npm). See engines.node in package.json for compatible versions; CI uses Node.js 24.

Install the development dependencies with:

npm ci

The project uses Prettier to format files. Run it with:

npm run format

The README and generated files are excluded from formatting.

Before committing, run:

npm ci            # install the dependencies from package-lock.json
npm run format    # format the files with Prettier
npm run build     # lint with ESLint and build dist/krenalis-ketch.min.js (ES5)

Or run the same sequence with a single command:

npm run commit

The build uses esbuild for bundling and minification, and SWC for transpilation to ES5.

License

This project is released under the MIT License. © 2026 Open2b

The script distributed in dist/krenalis-ketch.min.js keeps the license notice in its header; keep it when you copy or redistribute the script.

Ketch is a trademark of Ketch Kloud Inc. This integration is not affiliated with or endorsed by Ketch Kloud Inc.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages