Skip to content

Make code components wait for cookie consent

On a site that asks for cookie consent, choose which category each code component belongs to, so it runs only once visitors accept it.

2 min readENFRNLDE
On this page 3 sections

Where

Site menuCookies and consent…Open in the editor

On a site that asks visitors for consent, custom code and embeds wait until the visitor accepts their category. Code components and code overrides can wait the same way.

Choose a category

  1. In the site menu, choose Cookies and consent….
  2. Make sure Ask visitors for consent is on.
  3. Under Code components, every code component of the site is listed by name. Pick its category in the select: Necessary, Preferences, Analytics or Marketing.
  4. Select Save.

What happens

  • A component starts as Marketing, as embeds and snippets do. Until a visitor accepts marketing cookies, its code doesn't run. The page's content is still there.
  • A component set to Necessary always runs. Choose it only for code that sets no cookies and tracks no one.
  • Any other category runs once the visitor accepts it, and not before.
  • The cookie policy lists each code component by name, under its category.
  • On a site that doesn't ask for consent, nothing waits.

The code the AI writes can't use the network or storage, so the AI saves its components as Necessary. You can change that in the same dialog.

After a downgrade

Code components and code overrides need a plan with custom code: Starter, Pro or Business. When a site moves to the free plan, they stay in the site but stop being published from the next publish: each code component is published empty, and a layer with an override is published without it. The review before the plan change lists the components by name, with how many times each is placed, and the overrides. Move the site to a plan with custom code and publish again, and they are published again.