Cookie Consent

Cookie Consent

Cookie consent lets a theme show a small choices popup and delay optional scripts until the visitor allows them.

The popup markup belongs to your theme. TemplateX only adds the consent behavior when the view is compiled.

Smallest Setup#

Create the starter partial from TemplateX > Settings > Tweaks > Cookie Consent.

Then insert it near the end of your layout body:

phpresources/views/layouts/default.php
<body>  <Header />  <main id="page">    {{ slot }}  </main>  <CookiesPopup /></body>

The generated partial is plain TemplateX markup. It has no PHP, no required classes, and no visible behavior attributes.

What It Does#

On a first visit, the popup appears.

When a visitor chooses:

  • Reject optional keeps optional categories off.
  • Accept all enables optional categories.
  • Manage choices opens category checkboxes.

Choices are saved in localStorage under cookie-consent:v1 by default.