# Explicit website consent mapping (controlled preview)

This adapter reads the explicit state supplied by your consent tool. It does not discover Google
Consent Mode state, install a CMP, change Google consent, or infer permission from a cookie.
The website owner must enable Tier B separately and connect/prove the website.

Place the bridge before the Kyloth counting script. Start with refusal while the CMP resolves
its stored choice. If your CMP can call back before the adapter loads, install this queue first:

```html
<script>
window.kylothConsent = window.kylothConsent || function(state) {
  (window.kylothConsent.q = window.kylothConsent.q || []).push(state);
};
kylothConsent({analytics_storage: 'denied'});
</script>
<script src="https://kyloth.com/integrations/kyloth-consent-1.js"></script>
<!-- Your existing Kyloth counting script follows here. -->
```

Use your actual approved Kyloth application host if it differs. Self-hosting the reviewed adapter
is also possible. Do not load the bridge asynchronously after counting starts. If Content-Security-
Policy blocks inline scripts, place the queue in an allowed first-party file or use your reviewed
nonce policy. If the adapter fails to load, block the counting tag until it is available: the
standalone counting script may read an identifier from an earlier permitted visit.

In the consent tool's initial-resolution callback AND every choice-change/withdrawal callback:

```javascript
// `choice` must be the CMP's explicit current analytics choice, not a Google fallback boolean.
const state = {analytics_storage: choice === true ? 'granted' : 'denied'};
window.kylothConsent(state);
// Continue your existing CMP integration with Google separately.
```

When your consent tool already returns Google's state shape, pass that explicit object directly.
Only the exact own-property string `analytics_storage: 'granted'` permits Kyloth visitor memory.
Missing, malformed and denied values revoke it. Advertising permissions never imply analytics.
Withdrawal must invoke the callback immediately, before navigation. The adapter does not retain
choice itself; your CMP owns choice persistence and must replay the current choice on every page.

For gtag-based integrations, keep the CMP's existing `gtag('consent', 'default', ...)` and
`gtag('consent', 'update', ...)` calls; call this adapter separately from the same authoritative
CMP callbacks. For GTM consent templates, use Google's `setDefaultConsentState` and
`updateConsentState` APIs. Connect the page callback through your CMP's documented page integration;
this adapter is not sandbox-template code and cannot be pasted directly into that sandbox.

Do not translate `isConsentGranted('analytics_storage')` directly into a grant: Google considers an
unset state granted. Do not infer explicit consent by reading or patching dataLayer or gtag.

Global Privacy Control and Do Not Track override grants. WordPress counts-only relay mode never
creates or sends visitor identity, even after this callback permits analytics. Refusal removes the
visitor identifier; source-only counts can continue under the existing preview policy. It does not
erase contact trails already attached to an enquiry; use the business's erasure process for that.
Kyloth's own website consent is separate. No real Google Tag Manager preview has been recorded.

Before use, verify: no choice produces no visitor ID; accept creates one only in direct Tier B;
reject/withdraw removes it; reload replays the current choice; GPC/DNT and relay create no ID;
adapter unavailable means the counting tag stays blocked. Check your actual CMP and GTM workspace
with the Kyloth team before any publication decision.
