# spec-advertising — Ad Platforms and Consent Frameworks

Advertising consent is the single category `ads` ([categories](spec-consent.md#categories-and-decisions)). This document
specifies how that one decision drives ad-platform destinations, and how it reconciles with an external CMP where
programmatic advertising requires one.

## Ad destinations

An ad destination consumes the same `{ ads, analytics }` decision as every other destination, through the
[destination interface](spec-destinations.md#the-destination-interface):

- Its `consentRequirement` is always `"required"` — an ad sink is never exempt.
- Its `isPermittedBy` is the [transmission rule](#transmission-and-limited-data-use), so an `analytics` grant alone
  never opens it.
- It maps consent and hands the mapped payload to a transport the integrator supplies; tag ids, credentials and the
  platform SDK are the integrator's.
- Its `onErasure` stops sending for the rest of the session and clears the platform's cookies through the `clearCookies`
  hook the integrator supplies; without that hook, no cookie is cleared. Meta Pixel/Conversions API, TikTok and
  Microsoft UET expose no per-visitor deletion API, so erasure MUST NOT call one.

## Transmission and Limited Data Use

An ad destination transmits only when `ads` is granted. The one exception is an opt-out regime (a US "do not sell or
share" opt-out, `ads = false` via GPC or GPP), where delivery under Limited Data Use (LDU) substitutes for the `ads`
grant: there, `analytics` granted is enough, and the event carries LDU. A visitor who denied both `ads` and `analytics`
has refused every purpose the delivery could serve, so the platform receives nothing
([why](../DECISIONS.md#limited-data-use-substitutes-for-ads-only-under-an-opt-out-regime)).

- The integrator enables the substitution per evaluation, wired to the resolved mode being `opt-out`. Under opt-in it
  MUST stay off: an ad platform without `ads` consent receives nothing.
- LDU follows the decision `send` receives: on whenever `ads` is denied. With no decision, the destination MUST apply
  it.
- The opt-out MUST NOT withdraw first-party `analytics` ([GPC rule](spec-consent.md#effective-consent)).

## Platform mapping

| Platform                      | Transmission gate                                                                            | `ads` denied → restriction                                                                                                            |
| ----------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **Meta Pixel / CAPI**         | `fbq('consent','revoke'\|'grant')` (Pixel); at the send boundary (CAPI has no consent field) | `fbq('dataProcessingOptions',['LDU'],0,0)` (Pixel), `data_processing_options` (CAPI); `0,0` lets Meta geolocate                       |
| **TikTok Pixel / Events API** | `ttq.holdConsent()` before load, then `ttq.grantConsent()` / `ttq.revokeConsent()`           | the single boolean `limited_data_use: true`, at load or per event; server-side it requires the IP in the payload                      |
| **Microsoft UET**             | —                                                                                            | `ad_storage: denied` via `uetq.push('consent','default'\|'update',{...})` — UET's only enforced signal; it has no `analytics_storage` |

## When a CMP is required

| Scenario                                                | Region      | Required consent layer                                                                             |
| ------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------- |
| Measurement only (first-party analytics, no ad serving) | anywhere    | native `{ ads, analytics }` + Consent Mode v2                                                      |
| Programmatic ads (AdSense / Ad Manager / RTB)           | EEA, UK, CH | a certified CMP + TCF TC String + Consent Mode v2 + Google Additional Consent, read via `__tcfapi` |
| Ads to a US opt-out state                               | US          | GPP `usnat` / `us…` sections read via `__gpp`; GPC already covers the opt-out                      |
| Ads elsewhere                                           | other       | native `{ ads, analytics }` + Consent Mode v2                                                      |

The system reads a CMP; it never becomes one, and it never mints a TC or GPP string
([why](../DECISIONS.md#read-a-cmp-rather-than-become-one)). Without a CMP, the native decision maps directly to the
[Consent Mode signals](spec-destinations.md#consent-signal-mapping) and no Additional Consent string is synthesized.

## Reading a CMP

The integrator derives a CMP signal — the categories the CMP governs, its status, and its per-category grant — from the
CMP's own API. The purpose set and the Google vendor id are ad-ops policy the integrator supplies, never hard-coded.

- **Detection.** TCF: `__tcfapi` is a function, confirmed live by `__tcfapi("ping", 2, cb)` returning
  `cmpStatus === "loaded"`. GPP: `__gpp` is a function, confirmed by `__gpp("ping", cb)` returning
  `signalStatus === "ready"`. Either may be iframe-proxied (`__tcfapiLocator` / `__gppLocator`). An implementation MUST
  use the API and MUST NOT scrape the raw string from a cookie.
- **TCF.** Register `__tcfapi("addEventListener", 2, cb)` and act on `eventStatus` `tcloaded` or `useractioncomplete`.
  `gdprApplies === false` → the CMP is out of scope for this visitor. Otherwise derive `ads` from the ads purposes and
  the Google vendor, `analytics` from the measurement purposes, and forward `tcString` and `addtlConsent` verbatim to
  Google tags.
- **GPP.** Read `usnat` plus any applicable `us…` state section. Any sale, share or targeted-advertising opt-out →
  `ads = false`.

## Reconciliation

The reconciler sits above [effective consent](spec-consent.md#effective-consent) and takes the native decision, the CMP
signal, and the GPC signal:

1. A CMP that governs a category in scope → the **CMP value wins** for that category; a governed category the signal
   omits is denied.
2. No CMP, or a CMP out of scope (`gdprApplies === false`, no applicable GPP section) → the native decision stands.
3. **Fail closed:** a CMP detected but not yet ready → its governed categories are denied until it resolves.
4. GPC applies last and can only tighten `ads`, never loosen a CMP grant.
5. Every CMP `addEventListener` fire re-runs the reconciliation, because the visitor can change consent mid-session.

[Withdrawal side effects](spec-consent.md#withdrawal-side-effects) fire whenever the **reconciled** `analytics` flips
false, regardless of source.

## Conformance vectors

**V1 — no CMP present.** No `__tcfapi`/`__gpp` on the page → the reconciler is inert; native effective consent governs
unchanged.

**V2 — TCF grants ads.** `gdprApplies === true`, ads purposes + Google vendor consented → reconciled `ads = true`;
`tcString` + `addtlConsent` captured for forwarding.

**V3 — CMP not ready.** `__tcfapi` present, `cmpStatus !== "loaded"` → governed categories denied until it resolves.

**V4 — GPP US opt-out.** `usca` section signals a sale/share opt-out → reconciled `ads = false`, `analytics` unaffected.

**V5 — GPC tightens a CMP grant.** CMP grants `ads` but GPC is present → reconciled `ads = false`.

**V6 — out of scope.** `gdprApplies === false` → defer to native consent, do not force-deny.

**V7 — mid-session change.** A second `addEventListener` fire with a changed decision → the reconciled decision updates
and withdrawal side effects fire if `analytics` flipped false.

The ad-transmission vector is [V6 in spec-destinations](spec-destinations.md#conformance-vectors); the ad-erasure vector
is [DSR-V4](spec-data-subject-rights.md#conformance-vectors).
