Korzen
Bot Protection
In these docs

The tag

The script on your pages: where it goes, how it loads without holding the page, the cookie it leaves, its options and how it learns your domains.

The tag is one script. Put it in the <head> of every page a protected action starts from: the sign-up page, the sign-in page, the checkout.

<script src="https://eu.korzen.dev/v1/tag.js" data-site-key="YOUR_SITE_KEY" async></script>

Put it on your home page too: Bot Protection lists a domain only once it finds your tag on that domain's home page.

It loads asynchronously and never holds the page. It reads how the browser behaves (input, timing, what the browser says about itself), sends that to Bot Protection, and stores the answer as the _kz cookie on your domain. Your server reads that cookie and sends it with the decision.

Your domains

There is nothing to list: put the tag on your pages, and Bot Protection learns your domains from its beacons and your server's calls. A domain is added under Your domains, on the Set-up page, at your server's first decision on a visitor of one of its pages who is not a bot. Your first domain is protected at once; a later one waits on the Set-up page until you confirm it, as anyone can put your tag on a page of their own and name it to your server. A domain counts with every subdomain under it: shop.example, www.shop.example and app.shop.example are one domain on your plan. Pages on localhost, 127.0.0.1 or [::1] always work, for testing, and are never listed. Your plan sets how many domains are protected: the first ones seen, up to that number. Beacons from a page on any further domain are refused with 402 until you drop a domain on the Set-up page or choose a bigger plan; drop one there, too, when it is not yours, such as a copy of your site. On the free trial, each domain gets one free trial: beacons from a domain that already had its free trial in another account are refused with 402 until you choose a plan.

A domain that stays out of Your domains usually has no tag on its home page. A home page found without it is looked at again 10 minutes later, at your server's next decision on a visitor.

Before the action

Before every protected action, wait for the tag, then send the form:

if (typeof window.korzen?.ready === "function") await window.korzen.ready();

It reports what the visitor did since the tag last reported: a visitor who waits on the page, then lets the browser fill the form and presses Enter, did all of it after that report. It resolves within a few seconds even when Bot Protection is slow or blocked, so a form is never stuck. A form the browser sends without your JavaScript is reported as the page leaves, which usually, not always, reaches Bot Protection before your server asks.

While the visitor keeps using the page, the tag also reports on its own now and then, never while the tab is in the background, so the token usually carries their latest input even without ready(). ready() stays the sure way before an action.

Your API on another origin

The _kz cookie goes only with requests to your page's own site. When the protected action calls an API on another origin (api.example.net from a page on shop.example), or the visitor's browser refuses cookies, send the token yourself in the x-korzen-token header:

const token = typeof window.korzen?.ready === "function" ? await window.korzen.ready() : "";
await fetch("https://api.example.net/orders", {
  method: "POST",
  headers: { "content-type": "application/json", "x-korzen-token": token || "" },
  body: JSON.stringify(order),
});

Allow x-korzen-token in that API's CORS answer (Access-Control-Allow-Headers), and on its server every SDK reads the header itself, before the cookie, as widgets on other sites shows. The tag never changes your page's requests: what they send stays in your code. The guides whose code makes the call itself, without an SDK, read the cookie alone: there, send the header's value as the call's token.

Options

AttributeDefaultWhat it does
data-site-keyrequiredyour public site key
data-wait-ms2500how long the tag listens for input before it reports
data-ready-ms2000how much longer korzen.ready() may wait

Bot Protection notices the tag by itself, from the decisions that carry its token: there is nothing to turn on.

In some browsers the tag writes one entry to the console, at the debug level, which the developer tools hide by default. It is not an error, and there is nothing to do about it.

Content Security Policy

A page served with a Content-Security-Policy header must let the tag load, report and start its worker. Add these sources to the directives your policy already has:

script-src https://eu.korzen.dev; connect-src https://eu.korzen.dev; worker-src blob:

In first-party mode the tag comes from your own domain: script-src 'self'; connect-src 'self'; worker-src blob: is enough, with no Korzen host in the policy.

Without worker-src blob: the tag still works and every visitor goes through: Bot Protection only loses one signal. The browser then also reports the refused worker to your policy's report endpoint, once a page, as it does under require-trusted-types-for: the tag cannot tell beforehand, and those reports can be ignored. A page without the header needs nothing.

Leave out integrity on the tag's <script>: the tag changes every day and with every release of Korzen, so a hash pinned today refuses it tomorrow. A nonce on it works, with 'strict-dynamic' too.

Your privacy notice

You are the controller of what the tag reads on your pages, and Korzen is your processor, under the Data Processing Agreement, which lists the data and how long each is kept. A sentence your privacy notice can use:

“To protect sign-ups, logins and payments from bots and fraud, our pages use Korzen Bot Protection. It reads technical characteristics of your browser and how you use the page, never what you type, and keeps a random identifier of your browser so that a returning browser is recognised. We do this in our legitimate interest in preventing fraud (GDPR Recital 47).”

Under the EU ePrivacy rules, the _kz cookie and the tag's local storage may be strictly necessary for the action the visitor asked for; you make that call with your advisers, or ask for consent (the Cookie Policy lists each item).

From Spain during football matches

While LaLiga's football matches are on, a court order lets Spanish internet providers block IP addresses that pirate streams use. Cloudflare serves many sites from the same addresses, and korzen.dev is behind Cloudflare, so from some Spanish home and mobile connections the site, the dashboard and the tag may not load during a match. It is not an outage, and it ends with the match. Your site keeps working: a tag that does not load, or a call from your server that cannot reach Bot Protection, lets the visitor through, as on any error. Only on an action you mark protected_action is such a visitor refused, until the match ends. To reach the dashboard meanwhile, wait for the match to end, or use another network or a VPN. When your own site stays reachable, first-party mode serves the tag and its beacon from it, so such a visitor can pass.