Consent adapters
A consent adapter keeps ConsentLayer’s consent in sync with another consent system: it reads the visitor’s choice from a TCF CMP, syncs it with Shopify, or sends it to Google tags as Consent Mode signals.
Adapters are passed to createAnalytics({ consent: { adapters } }), not to
providers:
import { googleConsentMode } from 'consentlayer/adapters/google-consent-mode'import { tcf } from 'consentlayer/adapters/tcf'
createAnalytics({ providers, consent: { adapters: [tcf(), googleConsentMode()] },})Available adapters
Section titled “Available adapters”Each adapter is a named export of its own entry point,
consentlayer/adapters/<name>.
| Adapter | Factory | Reads the choice | Writes the choice |
|---|---|---|---|
| IAB TCF | tcf() |
From the TCF CMP | No |
| Shopify Customer Privacy | shopifyCustomerPrivacy() |
From Shopify | To Shopify |
| Google Consent Mode | googleConsentMode() |
No | To Google tags, as Consent Mode signals |
A choice stored by ConsentLayer wins. Without one, the adapters that read a choice are asked in the order you pass them, and the first that has one provides it. Later changes made in an adapter’s system flow back into ConsentLayer, and every choice made through ConsentLayer is written to the adapters that write. Consent describes each step, and how to write your own adapter.