ConsentLayer

Core Concepts

Project Key

Every site has a unique project key (e.g., cl_live_abc123). This key identifies your site in the banner script tag and SDK. It is safe to include in client-side code.

ConsentLayer organizes cookies into categories. Every site starts with three default categories:

CategorySlugRequiredDescription
EssentialessentialYesCookies required for the site to function
StatisticsstatisticsNoAnalytics and performance tracking
MarketingmarketingNoAdvertising and retargeting

You can create additional categories via the dashboard or API. Users give or withhold consent per category.

When a visitor interacts with the banner, ConsentLayer stores their consent in a cl_consent cookie:

{
  "v": 1,
  "ts": 1700000000000,
  "jur": "EU",
  "cat": { "essential": true, "statistics": false, "marketing": false },
  "gpc": false,
  "dns": false
}

The SDK reads this cookie to provide hasConsent(), getConsentState(), and reactive React hooks.

Services

Services represent third-party tracking tools (Google Analytics, Facebook Pixel, etc.). Each service belongs to a category and has associated cookies. The scanner detects services automatically.

Jurisdictions

ConsentLayer supports GDPR (opt-in) and CCPA (opt-out) compliance. Geo-detection determines which rules apply to each visitor. The banner behavior adapts accordingly.

Script Blocking

The banner automatically blocks tracking scripts until consent is given. It intercepts script tag creation via DOM proxies and holds execution until the relevant category is consented.

Tracker tags already in your HTML

A script that your code adds later is fully blocked: the banner stops it before the browser requests it. A <script src> tag that is already in the page HTML is different. The browser starts to download every script tag in the HTML before any script runs, banner.js included. The banner stops that script from running, but it cannot stop the download.

For most trackers the download does nothing. Some vendors set a cookie in the download's response, so the cookie is set before consent:

VendorScriptCookies set on download
TikTok Pixelanalytics.tiktok.com/…_ttp
YouTubeyoutube.com/iframe_apiYSC, VISITOR_INFO1_LIVE
Snap Pixelsc-static.net/scevent…X-AB

No consent tool can block this from the browser, because the download starts before any consent script runs. Other consent platforms have the same limit and ask for the same manual markup. So this is a manual step in your site's code: mark the tag with type="text/plain" and its category. The browser does not download a text/plain script. The banner runs it after the visitor consents to that category:

<!-- Before: downloads, and sets _ttp, before consent -->
<script async src="https://analytics.tiktok.com/i18n/pixel/events.js"></script>

<!-- After: nothing downloads until the visitor accepts Marketing -->
<script type="text/plain" data-cl-category="marketing" src="https://analytics.tiktok.com/i18n/pixel/events.js"></script>

The tag can stay where it is, above or below the ConsentLayer tag. Keep script blocking on (Site settings): the banner runs text/plain tags only when script blocking is on.

The install check (check_installation) and the scanner list each of these tags: the tag as found in your page and the tag to put in its place. The compliance score counts them as open until a new scan no longer finds them, so scan again after you deploy.

With an AI agent

If an agent edits your site through the ConsentLayer MCP server, it can make this change for you. check_installation, scan_site, get_scan and setup_site return a next_steps entry with the exact tag to find in the site's code and the tag to put in its place. Ask the agent to "fix the tracker tags that set cookies before consent".