Consent management

Connect Clakta to your cookie banner so it only saves an id in the visitor's browser after they agree.

In full attribution projects, the script saves an id in the visitor's browser, and in most countries that needs the visitor's consent. Clakta has a consent switch for this, so you can respect the visitor's choice without turning tracking off. In privacy-friendly projects nothing is saved, so there is nothing to switch.

While consent is off, the script:

  • Doesn't save or read any id in the browser
  • Doesn't save the landing page
  • Ignores clakta.identify()
  • Still records page views and events, with anonymous same-day sessions

So without consent, the project behaves like a privacy-friendly one: you keep the traffic and same-day attribution, and only lose memory across visits.

Set the starting value

Pass consent to init() with what your banner already knows:

It is true by default. If your visitors have to opt in, set it to false and turn it on when they accept.

Change it when the visitor decides

Call this from your banner's accept and reject buttons:

Refusing immediately deletes every id Clakta saved in the browser. You can check the current state at any time:

A complete example

Tracking starts right away either way: anonymous until the visitor accepts, identified after. You don't lose the visitors who never click the banner.

Some legal advice says nothing at all can be sent before consent. In that case, remove data-auto-init from the script code and only start Clakta after the visitor accepts:

Related articles