- docs/consent.md: compliance defaults, Global Privacy Control, withdrawal, consent log on by default and the SQL migration; no more "UODO requirement" or "GPC not needed". docs/analytics.md: what Consent Mode advanced sends. - docs/consent-behaviour-spec.md: the behaviour IAPL and IAWL share, with the 13-item test list. - CHANGELOG 1.17.0: the SQL migration first, a before → after table for an existing site. - AGENT.md, iapl-setup / iapl-upgrade / iapl-reference / iapl-consent-check, PROGRAMISTA item 78; reference skills copy. - iapl-consent-check: Global Privacy Control, equal prominence and withdrawal runs; Google asset warnings. - Reference site uses the new defaults; e2e for GPC, a stale grant, equal prominence, withdrawal; e2e:built runs every consent test in both bundlers. YouTubeEmbed warns in development without a poster. Co-Authored-By: Claude Opus 5.5 <[email protected]>
155 lines
10 KiB
Markdown
155 lines
10 KiB
Markdown
# Cookie consent: shared behaviour spec
|
||
|
||
Version 1, 2026-11-26. Product-neutral: IAPL (`@intecion/ipal-kit`, Payload CMS) implements it in 1.17.0, IAWL
|
||
(WordPress) follows it in its consent stage. A visitor's choice must read the same in both products, and both pass
|
||
the same tests (§7). Where the products differ is said in §8. Why each rule exists, and which rules are law,
|
||
regulator guidance or vendor policy: [dev/consent-compliance-proposal.md](./dev/consent-compliance-proposal.md).
|
||
|
||
"MUST" is a requirement of this spec; "SHOULD" a default a product may let a site change.
|
||
|
||
## 1. Page delivery
|
||
|
||
1. The public page HTML MUST be the same for every visitor: nothing in it depends on the consent cookie or on a
|
||
Global Privacy Control signal. Pages stay cacheable (static, ISR, page cache, CDN).
|
||
2. The banner is in that HTML, hidden (`hidden` attribute). A small inline script placed right after it decides
|
||
**before the first paint**: show it (no current choice) or keep it hidden (a current choice, or GPC honoured). The
|
||
script reads only the consent cookie and `navigator.globalPrivacyControl`, stores nothing, loads nothing.
|
||
3. A click on a banner button before the rest of the page's script is live MUST NOT be lost: the inline script notes
|
||
it and the full script carries it out.
|
||
4. No JavaScript, or a script refused by CSP: the banner stays hidden and nothing tracks (every tag is loaded by
|
||
script).
|
||
5. The server MUST NOT render differently for `Sec-GPC`. An endpoint whose response is per visitor anyway MAY read it.
|
||
A product that ever varies a cacheable response by it sends `Vary: Sec-GPC` or marks the response private.
|
||
|
||
## 2. Categories and the record
|
||
|
||
| Category | Meaning | Switchable |
|
||
|---|---|---|
|
||
| `necessary` | needed for the site to work (session, security, the consent cookie itself, a theme or language the visitor chose when declared necessary) | no, always on |
|
||
| `functional` | remembers the visitor's settings (e.g. language cookie) | yes, off by default |
|
||
| `analytics` | measurement (GA4, Clarity, a statistics visitor id) | yes, off by default |
|
||
| `marketing` | advertising and remarketing (Google Ads, Meta, LinkedIn, TikTok) | yes, off by default |
|
||
|
||
**Cookie:** name `cookie-consent`; value = the record as JSON, URI-encoded; `Path=/`; `SameSite=Lax`; `Secure` on
|
||
HTTPS; host-only (no `Domain`); not `HttpOnly` (the browser script reads it); `Max-Age` 15552000 (180 days) for a
|
||
grant and a refusal alike (SHOULD; a site may change the period).
|
||
|
||
**Record:**
|
||
|
||
```json
|
||
{ "gpc": false, "id": "a1b2c3d4e5f6a7b8c9d0e1f2", "state": { "necessary": true, "functional": false, "analytics": true, "marketing": false }, "timestamp": "2026-11-26T10:00:00.000Z", "version": 1 }
|
||
```
|
||
|
||
- `id`: 24 lowercase hex characters, random, no personal data; kept across changes of the same visitor's choice.
|
||
- `version`: the site's policy version (integer ≥ 1). A record with another version counts as **no choice**.
|
||
- `timestamp`: ISO 8601 UTC of the choice.
|
||
- `gpc`: was the browser sending Global Privacy Control when the choice was made. Absent in records written before
|
||
this spec (IAPL before 1.17.0).
|
||
- A reader takes the **first** cookie of that name, ignores unknown fields, treats a non-boolean category as off and
|
||
`necessary` as on, and treats an unreadable value as no choice.
|
||
|
||
**Consent log entry** (server side, SHOULD be on): `consentId` (= `id`), `version`, `choices` (the four booleans),
|
||
creation time. **No IP address, no user agent.** Posted after every choice, fire and forget: a failed post never
|
||
blocks or breaks the banner. Records are deleted after a retention period (IAPL: 1095 days).
|
||
|
||
## 3. Consent Mode and other tools
|
||
|
||
| Google signal | From |
|
||
|---|---|
|
||
| `ad_storage`, `ad_user_data`, `ad_personalization` | `marketing` |
|
||
| `analytics_storage` | `analytics` |
|
||
| `functionality_storage`, `personalization_storage` | `functional` |
|
||
| `security_storage` | always `granted` |
|
||
|
||
1. The Consent Mode `default` (the stored choice with GPC applied, else all `denied`; `wait_for_update: 500`) is the
|
||
first `dataLayer` entry, before any Google tag command; `ads_data_redaction: true` is set with it.
|
||
2. Every choice pushes `gtag('consent', 'update', …)` at once.
|
||
3. Consent Mode **advanced** (SHOULD be the default): the Google tag loads before a choice with every signal denied.
|
||
**basic** (option): no request to Google before analytics or marketing is granted. Under GPC (§4) advanced behaves
|
||
like basic.
|
||
4. Other tools load only after their category is granted: Clarity (analytics), Meta Pixel, LinkedIn Insight, TikTok
|
||
Pixel (marketing). Clarity gets `clarity('consentv2', { ad_Storage, analytics_Storage })` when it loads.
|
||
5. Withdrawal (a category on → off): delete that category's cookies on this host and every parent domain, and its
|
||
listed `localStorage` / `sessionStorage` keys; tell the running tools — `fbq('consent', 'revoke')`,
|
||
`ttq.revokeConsent()`, `clarity('consent', false)`; a later grant on the same page sends `grant` / `consentv2`.
|
||
Write the record and post it to the log.
|
||
|
||
## 4. Global Privacy Control
|
||
|
||
The signal: `Sec-GPC: 1` (only the exact value `1`) and `navigator.globalPrivacyControl === true`. It is read as a
|
||
refusal of **analytics and marketing** that the visitor did not have to click. `functional` and `necessary` are not
|
||
its business.
|
||
|
||
Modes (SHOULD default to `honour`): `honour`, `ask`, off.
|
||
|
||
| Stored choice | Signal | `honour` | `ask` |
|
||
|---|---|---|---|
|
||
| none | on | no banner (decided before first paint); the reopen button; analytics, marketing off; **no request to any tracker, Google included**; nothing stored | banner shown with the GPC line; nothing sent to any tracker until a choice |
|
||
| `gpc: true` (made with the signal) | on | stands, also a grant | stands |
|
||
| `gpc: false` (made without it) granting analytics or marketing | on | both switched off at once without asking: cookies and keys deleted, tools and Google told, record rewritten with `gpc: true`, posted to the log | same |
|
||
| no `gpc` field (older record) | on | stands until it expires or the visitor changes it | stands |
|
||
| any | off | stands — the absence of the signal is never consent | stands |
|
||
|
||
- A choice the visitor makes on the site while the signal is on (settings window, or the banner in `ask`) is
|
||
specific and wins; it is stored with `gpc: true`.
|
||
- The settings window (and the banner in `ask`) shows one line, e.g. "Your browser sends a Global Privacy Control
|
||
signal. Analytics and marketing are off. You can turn them on for this site here."
|
||
- Off: the signal is ignored entirely.
|
||
- A site MAY publish `/.well-known/gpc.json` = `{ "gpc": true, "lastUpdate": "YYYY-MM-DD" }`.
|
||
- Do Not Track is not read.
|
||
|
||
## 5. Equal prominence, in testable terms
|
||
|
||
On the banner's first layer, at 360×640 and at 1280×800:
|
||
|
||
1. "Accept all" and "Reject" are both `<button>` elements, both fully inside the viewport without scrolling the
|
||
banner; one click on either completes the choice.
|
||
2. Same computed `font-size`, `font-weight`, padding, `border-radius` and rendered height.
|
||
3. Same computed `background-color`, `color` and border — **or**, where a site styles them apart: the text of
|
||
"Reject" has a contrast of at least 4.5:1 against its background, and "Reject"'s background (or border) contrasts
|
||
with the banner surface at least as much as "Accept all"'s does.
|
||
4. "Reject" is not a link, not inside the text, not behind "Settings".
|
||
5. Nothing is pre-ticked in the settings view; "Save" there is as prominent as "Accept all".
|
||
6. A way to reopen the settings is always on the page after a choice (a floating button or a footer link).
|
||
|
||
## 6. Text shown
|
||
|
||
- First layer: what the cookies are for (one or two sentences), a link to the privacy policy, and: "You can change
|
||
your choice at any time with the cookie button, and set cookie rules in your browser too." (Polish law, PKE art.
|
||
399, asks for the browser-settings part.)
|
||
- Settings view: per category a title and description; per cookie (where the site lists them) name, provider,
|
||
purpose, duration, type (cookie / local storage / session storage).
|
||
- Every text in the page's language; the editor's text wins over the default.
|
||
|
||
## 7. Shared test list
|
||
|
||
Run in a real browser against a built site (IAPL: `reference/e2e`, `iapl-consent-check`; IAWL: its end-to-end
|
||
suite). Unit tests may cover the same with a simulated DOM.
|
||
|
||
1. First visit, no choice: no tracker request (Google allowed only in advanced, with `gcs=G100`), no non-necessary
|
||
cookie or storage key; banner visible at first paint, also with the application script blocked.
|
||
2. "Reject": the same as 1 after a reload; record written with all optional categories off.
|
||
3. "Accept all": Consent Mode `update` granted, configured tools start; record written; log entry created.
|
||
4. Settings, one category: only that category's tools start.
|
||
5. Reopen and switch a category off: its cookies and keys are gone, tools told, no further request from them.
|
||
6. Policy version raised: banner again at first paint; old record ignored.
|
||
7. Record unreadable or foreign: treated as no choice.
|
||
8. GPC on, no choice (`honour`): no banner in any frame, the reopen button, no tracker request including Google,
|
||
nothing stored; the GPC line in the settings window.
|
||
9. GPC on, a grant in the settings window: tools start; record has `gpc: true`; the next page keeps it.
|
||
10. Grant made with GPC off, then GPC on: analytics and marketing off, their cookies deleted, record rewritten with
|
||
`gpc: true`, posted to the log.
|
||
11. Equal prominence (§5) at both sizes.
|
||
12. The page HTML is identical with and without the cookie and the signal; cache headers unchanged; no `Vary` on
|
||
`Sec-GPC`.
|
||
13. No JavaScript: nothing tracks.
|
||
|
||
## 8. Where the products differ
|
||
|
||
| | IAPL | IAWL |
|
||
|---|---|---|
|
||
| Opt-outs | props and plugin options (`gpc`, `equalChoice`, `consentLog: false`, `maxAgeDays`) | code constants (no panel switch for protections) |
|
||
| Banner | React component, server-rendered | rendered by PHP, behaviour in a small plain script |
|
||
| Consent log storage | `consent-records` collection (MongoDB, or a table on Postgres / SQLite) | its own table |
|
||
| Site statement | `gpcWellKnown()` route handler | to be decided in its consent stage |
|