Skip to main content

HTML Reference

Script tag attributes

Where each part is documented

ReferencePage
Bundle files and every data-* attributeThis page
window.c15t methods and the call queuewindow.c15t API
Options for c15t.push(['config', …])Configuration
Events, c15t:* DOM events and callbacksEvents and callbacks

Script files

@c15t/browser publishes browser bundles. Inth and a self-hosted c15t backend serve c15t.js, c15t.headless.js and c15t.iab.js from the backend's URL, such as https://your-project.inth.app/c15t.js, with the backend URL already configured. Headless and IAB routes also inline the policy manifest. Load a file from https://cdn.jsdelivr.net/npm/@c15t/browser@<version>/dist/<file>, or the same path on unpkg, when no backend serves it, such as c15t.devtools.js or c15t.offline.js.

FileWhat it contains
c15t.jsThe default stock UI and client for hosted mode. Excludes offline policy presets, offline resolution and manifest transport code. Requires a backend URL or a queued hosted factory.
c15t.offline.jsThe stock UI and client for offline mode only. Includes policy presets and excludes hosted and manifest transport code.
c15t.headless.jsThe same runtime and window.c15t API with no banner, dialog or CSS. Your page renders the UI. See headless.
c15t.iab.jsReplaces c15t.js when your policy uses IAB TCF. See IAB TCF.
c15t.devtools.jsThe DevTools panel, loaded as a second tag. See DevTools.

Load one of c15t.js, c15t.offline.js, c15t.headless.js or c15t.iab.js on a page, never two. c15t.iab.js throws an error if another one loaded first. When c15t.js, c15t.offline.js or c15t.headless.js finds another c15t bundle already installed, it leaves the first one in place and does not start a second client.

dist/c15t.css and dist/c15t.iab.css are the stylesheets, for pages that render the UI with data-shadow="false" and load the CSS themselves.

Script tag attributes

The tag reads attributes once, when the script runs. The default c15t.js bundle uses hosted mode and requires data-backend-url unless a queued config supplies a backend URL or hosted factory.

c15t.js rejects offline or manifest mode, manifest options and data-policy-rules, because the attribute contains preset names. Authored PolicyRule objects can be passed in a queued config instead. c15t.offline.js rejects backend URLs, manifest options and modes other than offline. The headless and IAB bundles also accept manifest and custom transports. Every bundle keeps the call queue, data-manual and the page hooks described below.

AttributeWhat it does
data-backend-urlYour Inth or self-hosted backend URL. Selects hosted mode.
data-modeOptional hosted for c15t.js or offline for c15t.offline.js. Headless and IAB also accept manifest; without it, they pick manifest when a manifest URL is set, hosted when a backend URL is set, and offline otherwise. Headless and IAB ignore unknown values; hosted and offline reject them.
data-manifest-urlWhere headless or IAB fetches the policy manifest in manifest mode. See choose a mode.
data-policy-rulesComma-separated policy presets for offline mode, such as europeOptIn,usPrivacyStatesOptOut,worldNone. Any name exported by policyRulePresets works; an unknown name throws. Policies describes the presets.
data-categoriesComma-separated categories to offer in the preference dialog, such as measurement,marketing. Without it, the dialog offers the categories your gated scripts, iframes and rules use. This changes the dialog, not the policy.
data-country, data-regionThe visitor's location, when your host can print it into the page. Policy matching uses these instead of detection.
data-languageUse this language instead of the browser's. See translations.
data-privacy-policy-url, data-cookie-policy-url, data-terms-urlShow these legal links in the banner and the preference dialog.
data-color-schemelight, dark or system. Defaults to system.
data-triggerShow the floating trigger that reopens the preference dialog.
data-hide-brandingHide the "Secured by" tag in the banner and dialog. The IAB banner always keeps it.
data-shadow="false"Render the UI into the page instead of a shadow root, so your stylesheet applies. See customize.
data-no-uiStart the runtime without the stock UI. c15t.js still downloads the UI code and CSS; load c15t.headless.js to skip them. The UI attributes above are ignored.
data-manualDo not start. Your page calls c15t.init() later. See start c15t yourself.
data-nonceThe Content Security Policy nonce for the stock UI's <style> element and the scripts c15t loads. Without it, c15t uses the tag's own nonce attribute. See Content Security Policy.

Flag attributes such as data-trigger are on when present, unless their value is false. data-shadow is the exception. Only data-shadow="false" changes anything. data-backend is accepted as an older spelling of data-backend-url.

Everything the attributes set, and every option they cannot express, can also be passed in a queued config call. See configuration.

DevTools tag attributes

These go on the c15t.devtools.js tag:

AttributeWhat it does
data-openOpen the panel on load. data-open="false" keeps it closed.
data-tabThe first tab: consents, scripts, location, policy, iab, events or actions.
data-positionThe corner: bottom-right, bottom-left, top-right or top-left.

Attributes on your own markup

These work anywhere on the page, including markup added after load:

MarkupWhat it doesPage
data-c15t-action="accept", "reject", "customize", "dismiss", "banner" or "close"Runs the action on click.Action buttons
A link whose href ends in #c15t-preferencesOpens the preference dialog on click.Preferences link
<script type="text/plain" data-c15t-category="…">Runs the script once that category is allowed. data-c15t-vendor adds a vendor gate.Gated scripts
<iframe data-src="…" data-category="…">Sets the iframe's src once that category is allowed. data-vendor adds a vendor gate.Embeds

c15t sets these attributes itself. Read them in CSS or tests, but do not write them:

AttributeWhereMeaning
data-c15t-activatedGated <script>true once the tag ran, invalid when its category is unknown, untrusted when the page has a nonce and the tag lacks it.
data-c15t-pausedGated <iframe>c15t removed a src the iframe already had.
data-c15t-uiThe UI host <div>The element that holds the banner, dialog and trigger.
data-testidParts of the stock UIStable names for styling and tests. Each component page lists them.

Choose a mode

ModeSet it withWhat happens
Hostedc15t.js with data-backend-urlEach fresh visit asks the backend's /init endpoint for the visitor's policy. Choices are saved to the backend.
Manifestc15t.headless.js or c15t.iab.js with data-manifest-url, or mode: 'manifest' with an inline manifest in configThe browser resolves the policy from the backend's public, cacheable /manifest. Choices still go to the backend.
Offlinec15t.offline.js with no backend URLPolicy rules come from data-policy-rules or c15t's recommended rules. Choices stay in the browser. Not recommended for production environments.

A tag loaded from a backend's /c15t.js, such as https://your-project.inth.app/c15t.js, starts in hosted mode with the backend URL already configured, so it needs no data-backend-url.

In manifest mode, c15t can take the backend URL from a manifest URL that ends in /manifest. A manifest on another host, or an inline manifest, also needs data-backend-url so saves have somewhere to go. When a policy depends on the visitor's location and the page does not supply it, c15t falls back to the backend's /init. Data fetching compares the modes.

Use the default c15t.js for hosted mode and c15t.offline.js for offline mode. For manifest mode or custom transports with the stock UI, use the @c15t/browser ES module. The headless script supports those modes with your own UI, and the IAB script supports them for IAB policies. Loading c15t.js without a backend URL throws unless a hosted factory is supplied.

Offline mode cannot see the visitor's country. Without data-country, every visitor gets the strict opt-in fallback.