Prerequisites
- A domain added in Katla
- At least one completed scan
Installation
Copy the tag from Install → Widget in your dashboard and paste it before</head>:
<head>, which is what gets the Google
Consent Mode default declared before your Google tag can initialise. It then fetches the
engine, which carries your cookie inventory and the banner.
You can also get it from the CLI with katla install example.com.
If you would rather link it, {siteId}.js serves the same loader:
<head> and leave out async and defer. With either one the browser runs the
loader later, usually after your Google tag has started, and Google records the Consent Mode
default as late. Without them the browser waits for the loader before it reads on, which keeps
the default ahead of your Google tag but costs a connection to another origin before the page
can render. Everything else behaves identically.
The loader
theme or debug parameter you put on it is
carried across. Resolution happens on our side: an exact match, then the language, then
English, so an unrecognised tag never fails.
Add locale to skip detection and pin one language:
async or defer. The single-language script
declares one too, but from inside a much larger deferred file that gtag.js routinely beats -
see Google Consent Mode.
Winning that race matters only if your Google tag loads before consent at all. In
basic consent mode
it does not: the tag is held back until the visitor allows analytics, so no data is sent to
Google before they consent. Read that section to choose between basic and advanced mode; the
loader advice above applies either way.
Linked, the loader needs a request of its own before the cookie guard exists. Inline it
(below) and that request disappears - the loader is already on the page, and the only fetch
left is the engine.
Inlining the loader
The loader is small enough to paste into the page instead of linking to it. Copy it from the Install page in your dashboard, under Widget → Inline, and put it in<head>:
<head>, so the Google Consent Mode default is declared before your Google
tag can initialise and nothing is held up. If you have ever seen _ga appear before the banner
did, a Katla tag with async or defer is the usual cause, and this is the fix.
Pinning a language makes the snippet smaller still, because locale handling drops out of it
entirely:
Self-hosting
Download{siteId}.consent.js and serve it from your own origin. It carries every language,
so there is nothing else to fetch and nothing to keep in sync.
If you use Google Consent Mode, take {siteId}.js - the loader - as well, and serve the pair
side by side under matching names:
.js - so as long as the
two names match it will find your copy rather than reaching back to our CDN. Re-download both
when you change your cookie inventory or widget settings.
Inlining and self-hosting compose, and together they mean no request to us at all. An inlined
loader has no URL of its own, so it cannot resolve a sibling and has to be told where the engine
is: enter its address in Install → Widget → Inline → Self-hosted engine URL and it is baked
into the snippet. The file can be called anything.
Script parameters
You can customize the script behavior with query parameters:Content Security Policy
If your site sends aContent-Security-Policy header, script-src must allow
https://cdn.katla.app, and connect-src must allow https://consent.katla.app so
consent records can be stored. On the free plan, img-src must also allow
https://cdn.katla.app for the Katla logo in the banner.
script-src treats it as one. Under a nonce-based policy,
put your nonce on the tag:
script-src, and re-hash it
whenever you re-copy the snippet. If neither fits your policy, link the loader instead: the
{siteId}.js tag needs no inline allowance at all.
How it works
- The script installs a cookie guard that intercepts
document.cookiewrites. - If the visitor hasn’t given consent yet, the widget appears.
- The visitor chooses their preferences (accept all, reject all, or select categories).
- A
_katla_consentcookie is stored for 365 days with their choice. - Known analytics, marketing and personalization cookies are blocked until their category is allowed, and the ones on your cookie list are removed if they are already there.
Functional cookies are always allowed and cannot be rejected.
Which cookies Katla acts on
A scan cannot find every cookie a site sets, so Katla never blocks or removes one it does not know.
Uncategorized cookies are shown in the preferences panel without a switch. Give them a category on the site’s Cookies page and they follow the table. If you file a well-known tracker as functional or security, Katla leaves it alone. This applies from guard script version
7 (KatlaConsent.version).
Blocking scripts and pixels
The cookie guard stops cookies from being written. It does not stop a tracker from loading, and a pixel such as the Meta Pixel reports the visit whether or not it can set a cookie. To hold a tag back until the visitor allows its category, mark it up:data-katla-category is one of analytics, marketing, personalization or security. When the page loads with that category already allowed, or as soon as the visitor allows it, Katla runs each held-back script in document order. It waits for an external script to load before running the next tag, so a vendor’s inline setup can call the library loaded above it.
A tag that has run stays running. If the visitor later narrows their consent, the cookie guard enforces the new choice straight away and the tags stay held back from the next page load.
If your site adds held-back tags after the page has loaded, for example on a client-side route change, call KatlaConsent.activateBlocked() to pick them up.
On WordPress, the Katla plugin writes this markup for you and runs it itself.
Customization
You can customize the widget appearance in your site settings. Available options:
Both light and dark mode colors can be configured independently.
Colors are your site’s branding rather than a banner setting: they live on the site’s
Appearance page in the dashboard, and the accessibility widget
uses the same ones. After your site’s first scan, Katla suggests a palette read from your
homepage there, adjusted so text and buttons stay readable. Nothing changes on your site
until you save it.
What each color paints
Everything else - the border, the row divider, the panel behind an open cookie table, the
hover wash, the off state of a switch, and the label color on each button - is derived from
those six. The border in particular has no setting of its own: it is the background and the
text mixed, so a colored card gets a border that belongs to it. The text on a button is
computed from its fill, so a pale secondary gets dark text rather than becoming unreadable.
Border radius is a single dial rather than a pixel value. The dashboard shows it as the
corner of the card itself, at twice the stored value, and the widget fans the dial out into
five radii in proportion: the card at 2×, a centered card at 2.25×, a category card at 1.5×,
a button at 1.25× and the small ghost controls at 1×. A dial of 8 - 16px - is the redesign’s
own geometry; 0 gives square corners throughout.
Equal buttons
Reject and Accept all always occupy one row of two equal columns, at the same height, radius and font weight, in every layout and every language - that is what prominence is assessed on, and no setting changes it. Equal buttons removes the remaining difference by painting Reject in the primary color too. Turning on DMA Compliant implies it. It applies to that pair only. “Save preferences” in the preference center keeps the secondary color either way: it commits whatever the visitor set above rather than being the “no” half of a choice, so painting it primary alongside “Accept all” would leave two equally loud buttons doing different things. When Regulation is set toauto, the widget detects the visitor’s region at runtime using timezone and GPC signals. See the CCPA guide and DMA guide for details.
When Google Consent Mode is enabled, the widget script automatically signals consent state to Google Analytics and Google Ads tags. See the Google Consent Mode guide for details.
Custom styling
The dashboard settings cover colors, layout, position and corners. To go further, style the banner from your own stylesheet: it renders in your page rather than in an iframe, so your CSS reaches it. Build on these hooks only:
Start every selector with
#katla-widget-root. Katla adds its styles to the end of <head>
when the script runs, after your stylesheet, so a rule that is only as specific as Katla’s
own loses.
Fonts, corners and shadows
The banner and the preferences dialog both read these variables, so set them on both:
The Border radius setting sets all five radii. A variable you set replaces the one it
would have given.
Set colors on the Appearance page, or in your team’s Brand kit, rather than in CSS.
Katla derives the borders, hover states and button text from them, and the
accessibility widget uses the same ones.
The cookie icon
Once a visitor has made a choice, the banner is replaced by the cookie icon: a round button that reopens the preferences. It is the only button directly inside.katla-widget, so
.katla-widget > button selects it.
Make it smaller and move it up, for example to clear a chat button in the same corner:
:has(> button) matches only while the icon is showing, so the banner itself stays where it
was.
Use your own image instead of the built-in one:
prefers-reduced-motion: no-preference does the same, so those visitors
get a still icon.
To remove the icon, turn off Cookie icon on the Cookie banner page and give visitors
a link that calls katla.open() instead.
Don’t use custom CSS to hide Reject, or to make it smaller, fainter or harder to find than
Accept all. European data protection authorities have repeatedly objected to banners that
make refusing harder than accepting.
Other embed formats
Besides the JavaScript widget, Katla provides additional endpoints for your site:Example
Widget example
A Vite multipage example that loads the hosted widget and embeds the policy page.