@c15t/react 2.0.0-rc.7 → 2.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/components/consent-banner/consent-banner.cjs +1 -1
- package/dist/components/consent-banner/consent-banner.js +1 -1
- package/dist/components/consent-banner/index.cjs +1 -1
- package/dist/components/consent-banner/index.js +1 -1
- package/dist/components/consent-banner/policy-actions.cjs +1 -0
- package/dist/components/consent-banner/policy-actions.js +1 -0
- package/dist/components/consent-dialog/atoms/card.cjs +1 -1
- package/dist/components/consent-dialog/atoms/card.js +1 -1
- package/dist/components/consent-dialog-trigger/atoms/icon.cjs +1 -1
- package/dist/components/consent-dialog-trigger/atoms/icon.js +1 -1
- package/dist/components/consent-widget/atoms/footer.cjs +1 -1
- package/dist/components/consent-widget/atoms/footer.js +1 -1
- package/dist/components/consent-widget/consent-widget.cjs +1 -1
- package/dist/components/consent-widget/consent-widget.js +1 -1
- package/dist/components/consent-widget/index.cjs +1 -1
- package/dist/components/consent-widget/index.js +1 -1
- package/dist/components/consent-widget/policy-actions.cjs +1 -0
- package/dist/components/consent-widget/policy-actions.js +1 -0
- package/dist/components/iab-consent-banner/iab-consent-banner.cjs +1 -1
- package/dist/components/iab-consent-banner/iab-consent-banner.js +1 -1
- package/dist/components/iab-consent-dialog/iab-consent-dialog.cjs +1 -1
- package/dist/components/iab-consent-dialog/iab-consent-dialog.js +1 -1
- package/dist/components/shared/policy-actions.cjs +1 -0
- package/dist/components/shared/policy-actions.js +1 -0
- package/dist/components/shared/ui/branding.cjs +1 -0
- package/dist/components/shared/ui/branding.js +1 -0
- package/dist/components/shared/ui/logo.cjs +1 -1
- package/dist/components/shared/ui/logo.js +1 -1
- package/dist/components/shared/ui/switch/index.cjs +1 -1
- package/dist/components/shared/ui/switch/index.js +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/use-consent-manager.cjs +1 -1
- package/dist/hooks/use-consent-manager.js +1 -1
- package/dist/hooks/use-headless-consent-ui.cjs +1 -1
- package/dist/hooks/use-headless-consent-ui.js +1 -1
- package/dist/iab/styles.css +11 -1
- package/dist/iab/styles.tw3.css +14 -1
- package/dist/index.cjs +1 -1
- package/dist/providers/consent-manager-provider.cjs +1 -1
- package/dist/providers/consent-manager-provider.js +1 -1
- package/dist/server/fetch-ssr-data.cjs +1 -1
- package/dist/server/fetch-ssr-data.js +1 -1
- package/dist/styles.css +10 -1
- package/dist/styles.tw3.css +13 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist-types/components/consent-banner/atoms/root.d.ts +1 -1
- package/dist-types/components/consent-banner/consent-banner.d.ts +7 -2
- package/dist-types/components/consent-banner/index.d.ts +3 -0
- package/dist-types/components/consent-banner/policy-actions.d.ts +11 -0
- package/dist-types/components/consent-dialog/atoms/card.d.ts +7 -2
- package/dist-types/components/consent-dialog/atoms/root.d.ts +1 -1
- package/dist-types/components/consent-dialog/consent-dialog.d.ts +1 -1
- package/dist-types/components/consent-dialog-trigger/atoms/icon.d.ts +1 -1
- package/dist-types/components/consent-dialog-trigger/types.d.ts +1 -1
- package/dist-types/components/consent-widget/index.d.ts +3 -0
- package/dist-types/components/consent-widget/policy-actions.d.ts +11 -0
- package/dist-types/components/frame/atoms.d.ts +1 -1
- package/dist-types/components/frame/types.d.ts +1 -1
- package/dist-types/components/iab-consent-banner/atoms/root.d.ts +1 -1
- package/dist-types/components/iab-consent-banner/iab-consent-banner.d.ts +1 -1
- package/dist-types/components/iab-consent-dialog/atoms/root.d.ts +1 -1
- package/dist-types/components/iab-consent-dialog/atoms/vendor-list.d.ts +1 -1
- package/dist-types/components/iab-consent-dialog/iab-consent-dialog.d.ts +1 -1
- package/dist-types/components/shared/policy-actions.d.ts +29 -0
- package/dist-types/components/shared/primitives/button.d.ts +1 -1
- package/dist-types/components/shared/primitives/button.types.d.ts +1 -1
- package/dist-types/components/shared/primitives/legal-links/index.d.ts +1 -1
- package/dist-types/components/shared/ui/accordion/accordion.d.ts +2 -2
- package/dist-types/components/shared/ui/accordion/accordion.types.d.ts +1 -1
- package/dist-types/components/shared/ui/branding.d.ts +23 -0
- package/dist-types/components/shared/ui/button/button.d.ts +1 -1
- package/dist-types/components/shared/ui/logo.d.ts +8 -0
- package/dist-types/components/shared/ui/preference-item/preference-item.d.ts +1 -1
- package/dist-types/components/shared/ui/switch/index.d.ts +1 -1
- package/dist-types/components/shared/ui/switch/switch.d.ts +1 -1
- package/dist-types/components/shared/ui/switch/switch.types.d.ts +1 -1
- package/dist-types/components/shared/ui/tabs/tabs.d.ts +1 -1
- package/dist-types/context/consent-manager-context.d.ts +1 -1
- package/dist-types/headless.d.ts +1 -1
- package/dist-types/hooks/use-component-config.d.ts +1 -1
- package/dist-types/hooks/use-consent-manager.d.ts +1 -1
- package/dist-types/hooks/use-headless-consent-ui.d.ts +1 -1
- package/dist-types/hooks/use-ssr-status.d.ts +2 -1
- package/dist-types/hooks/use-translations.d.ts +1 -1
- package/dist-types/index.d.ts +2 -2
- package/dist-types/server/fetch-ssr-data.d.ts +1 -1
- package/dist-types/server/init-cache-key.d.ts +1 -1
- package/dist-types/server/types.d.ts +1 -1
- package/dist-types/types/consent-manager.d.ts +1 -1
- package/dist-types/types/theme/style-keys.d.ts +1 -1
- package/dist-types/types/theme/style-types.d.ts +2 -2
- package/dist-types/utils/cn.d.ts +1 -1
- package/dist-types/utils/theme-utils.d.ts +1 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/building-headless-components.md +40 -22
- package/docs/callbacks.md +76 -9
- package/docs/components/consent-banner.md +83 -9
- package/docs/components/consent-dialog.md +12 -2
- package/docs/components/consent-manager-provider.md +3 -1
- package/docs/components/consent-widget.md +61 -8
- package/docs/concepts/client-modes.md +16 -4
- package/docs/concepts/initialization-flow.md +9 -2
- package/docs/concepts/policy-packs.md +2 -2
- package/docs/hooks/use-consent-manager/overview.md +17 -3
- package/docs/hooks/use-ssr-status.md +1 -1
- package/docs/hooks/use-translations.md +1 -0
- package/docs/iab/consent-banner.md +2 -5
- package/docs/iab/consent-dialog.md +3 -6
- package/docs/iab/overview.md +11 -5
- package/docs/integrations/building-integrations.md +405 -0
- package/docs/integrations/databuddy.md +22 -5
- package/docs/integrations/google-tag-manager.md +2 -2
- package/docs/integrations/google-tag.md +2 -29
- package/docs/integrations/linkedin-insights.md +1 -1
- package/docs/integrations/meta-pixel.md +1 -1
- package/docs/integrations/microsoft-uet.md +1 -1
- package/docs/integrations/overview.md +18 -2
- package/docs/integrations/posthog.md +39 -17
- package/docs/integrations/tiktok-pixel.md +1 -1
- package/docs/integrations/x-pixel.md +1 -1
- package/docs/optimization.md +2 -6
- package/docs/policy-packs.md +7 -7
- package/docs/quickstart.md +11 -5
- package/docs/script-loader.md +22 -1
- package/docs/styling/tailwind.md +23 -17
- package/iab/styles.css +1 -0
- package/package.json +13 -11
- package/readme.json +6 -0
- package/src/iab/styles.css +11 -0
- package/src/iab/styles.tw3.css +8 -4
- package/src/styles.css +10 -0
- package/src/styles.tw3.css +7 -4
- package/styles.css +1 -0
- package/dist/components/shared/libs/policy-actions.cjs +0 -1
- package/dist/components/shared/libs/policy-actions.js +0 -1
- package/dist-types/components/shared/libs/policy-actions.d.ts +0 -26
|
@@ -27,7 +27,7 @@ function MyComponent() {
|
|
|
27
27
|
|
|
28
28
|
|Property|Type|Description|Default|Required|
|
|
29
29
|
|:--|:--|:--|:--|:--:|
|
|
30
|
-
|branding|"c15t" \|"consent" \|"none"|Whether to show the branding
|
|
30
|
+
|branding|"c15t" \|"inth" \|"consent" \|"none"|Whether to show the branding. "consent" is a deprecated alias for "inth".|-|✅ Required|
|
|
31
31
|
|consents|ConsentState|Current consent states for all consent types|-|✅ Required|
|
|
32
32
|
|selectedConsents|ConsentState|Selected consents (Not Saved) - use saveConsents to save|-|✅ Required|
|
|
33
33
|
|consentInfo|ConsentInfo \|null|Information about when and how consent was given|-|✅ Required|
|
|
@@ -53,7 +53,7 @@ function MyComponent() {
|
|
|
53
53
|
|iab|IABManager \|null|IAB TCF 2.3 state and actions (null when not configured or not in IAB mode).|-|✅ Required|
|
|
54
54
|
|reloadOnConsentRevoked|boolean|Whether to reload the page when consent is revoked.|-|✅ Required|
|
|
55
55
|
|ssrDataUsed|boolean|Whether SSR data was successfully used for initialization.|-|✅ Required|
|
|
56
|
-
|ssrSkippedReason|
|
|
56
|
+
|ssrSkippedReason|SSRSkippedReason|Reason SSR data was skipped, if applicable.|-|✅ Required|
|
|
57
57
|
|
|
58
58
|
#### `consents` ConsentState
|
|
59
59
|
|
|
@@ -87,7 +87,7 @@ Information about when and how consent was given
|
|
|
87
87
|
|:--|:--|:--|:--|:--:|
|
|
88
88
|
|time|number|The epoch timestamp of when the consent was recorded|-|✅ Required|
|
|
89
89
|
|subjectId|string \|undefined|The client-generated subject ID in sub\_xxx format|-|Optional|
|
|
90
|
-
|id|string \|undefined
|
|
90
|
+
|id|string \|undefined|Configuration for the legal links @remarks Legal links can display across different parts of the consent manager such as the consent banner & dialog.|-|Optional|
|
|
91
91
|
|externalId|string \|undefined|The external user ID linked to this subject|-|Optional|
|
|
92
92
|
|materialPolicyFingerprint|string \|undefined|Material fingerprint of the active policy when this consent was accepted.|-|Optional|
|
|
93
93
|
|identityProvider|string \|undefined|The identity provider that provided the external ID|-|Optional|
|
|
@@ -196,6 +196,7 @@ IAB TCF 2.3 state and actions (null when not configured or not in IAB mode).
|
|
|
196
196
|
|setActiveUI|(ui: ActiveUI, options?: \{ force?: boolean \|undefined; } \|undefined) => void|Sets the active consent UI component.|-|✅ Required|
|
|
197
197
|
|setConsentCategories|(types: AllConsentNames\[]) => void|Updates the active GDPR consent types.|-|✅ Required|
|
|
198
198
|
|setCallback|Object \|undefined|Sets a callback for a specific consent event.|-|✅ Required|
|
|
199
|
+
|subscribeToConsentChanges|Object|Subscribes to change-only consent saves.|-|✅ Required|
|
|
199
200
|
|setLocationInfo|Object \|null|Updates the user's location information.|-|✅ Required|
|
|
200
201
|
|initConsentManager|Object \|undefined \|null|Initializes the consent manager by fetching jurisdiction, location, translations, and branding information.|-|✅ Required|
|
|
201
202
|
|getDisplayedConsents|ConsentType|Retrieves the list of consent types that should be displayed|-|✅ Required|
|
|
@@ -245,6 +246,19 @@ Identifies the user by setting the external ID.
|
|
|
245
246
|
|id|string|Usually your own internal ID for the user from your auth provider|-|✅ Required|
|
|
246
247
|
|identityProvider|string \|undefined|The identity provider of the user. Usually the name of the identity provider e.g. 'clerk', 'auth0', 'custom', etc.|-|Optional|
|
|
247
248
|
|
|
249
|
+
#### `subscribeToConsentChanges`
|
|
250
|
+
|
|
251
|
+
Subscribes to change-only consent saves.
|
|
252
|
+
|
|
253
|
+
|Property|Type|Description|Default|Required|
|
|
254
|
+
|:--|:--|:--|:--|:--:|
|
|
255
|
+
|preferences|ConsentState|-|-|✅ Required|
|
|
256
|
+
|previousPreferences|ConsentState|-|-|✅ Required|
|
|
257
|
+
|allowedCategories|AllConsentNames|-|-|✅ Required|
|
|
258
|
+
|deniedCategories|AllConsentNames|-|-|✅ Required|
|
|
259
|
+
|previousAllowedCategories|AllConsentNames|-|-|✅ Required|
|
|
260
|
+
|previousDeniedCategories|AllConsentNames|-|-|✅ Required|
|
|
261
|
+
|
|
248
262
|
#### `setLocationInfo`
|
|
249
263
|
|
|
250
264
|
Updates the user's location information.
|
|
@@ -25,7 +25,7 @@ function DebugSSR() {
|
|
|
25
25
|
|Property|Type|Description|Default|Required|
|
|
26
26
|
|:--|:--|:--|:--|:--:|
|
|
27
27
|
|ssrDataUsed|boolean|Whether SSR data was used for initialization. \`true\` if SSR data was provided and successfully consumed, \`false\` otherwise.|-|✅ Required|
|
|
28
|
-
|ssrSkippedReason|"no\_data" \|"fetch\_failed" \|null|Reason SSR data was skipped, or \`null\` if used successfully.|-|✅ Required|
|
|
28
|
+
|ssrSkippedReason|"no\_data" \|"fetch\_failed" \|"context\_mismatch" \|null|Reason SSR data was skipped, or \`null\` if used successfully.|-|✅ Required|
|
|
29
29
|
|
|
30
30
|
> ℹ️ **Info:**
|
|
31
31
|
> Must be used within a ConsentManagerProvider. Throws if used outside the provider context.
|
|
@@ -46,6 +46,7 @@ The returned `Translations` object has these sections:
|
|
|
46
46
|
|customize|string \|undefined|-|-|✅ Required|
|
|
47
47
|
|save|string \|undefined|-|-|✅ Required|
|
|
48
48
|
|close|string \|undefined|-|-|✅ Required|
|
|
49
|
+
|securedBy|string \|undefined|-|-|✅ Required|
|
|
49
50
|
|
|
50
51
|
#### `cookieBanner` CookieBannerTranslations
|
|
51
52
|
|
|
@@ -19,11 +19,8 @@ Use this component instead of `ConsentBanner` when you need IAB TCF compliance f
|
|
|
19
19
|
|
|
20
20
|
```tsx
|
|
21
21
|
import { type ReactNode } from 'react';
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
IABConsentBanner,
|
|
25
|
-
IABConsentDialog,
|
|
26
|
-
} from '@c15t/react';
|
|
22
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
23
|
+
import { IABConsentBanner, IABConsentDialog } from '@c15t/react/iab';
|
|
27
24
|
|
|
28
25
|
export default function ConsentManager({ children }: { children: ReactNode }) {
|
|
29
26
|
return (
|
|
@@ -13,11 +13,8 @@ Pair it with `IABConsentBanner` inside the provider:
|
|
|
13
13
|
|
|
14
14
|
```tsx
|
|
15
15
|
import { type ReactNode } from 'react';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
IABConsentBanner,
|
|
19
|
-
IABConsentDialog,
|
|
20
|
-
} from '@c15t/react';
|
|
16
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
17
|
+
import { IABConsentBanner, IABConsentDialog } from '@c15t/react/iab';
|
|
21
18
|
|
|
22
19
|
export default function ConsentManager({ children }: { children: ReactNode }) {
|
|
23
20
|
return (
|
|
@@ -76,7 +73,7 @@ By default, the dialog follows `activeUI === 'dialog'` from the consent store. U
|
|
|
76
73
|
|
|
77
74
|
```tsx
|
|
78
75
|
import { useState } from 'react';
|
|
79
|
-
import { IABConsentDialog } from '@c15t/react';
|
|
76
|
+
import { IABConsentDialog } from '@c15t/react/iab';
|
|
80
77
|
|
|
81
78
|
function SettingsPage() {
|
|
82
79
|
const [open, setOpen] = useState(false);
|
package/docs/iab/overview.md
CHANGED
|
@@ -32,15 +32,21 @@ c15t provides a complete IAB TCF 2.3 CMP (Consent Management Platform) implement
|
|
|
32
32
|
4. **TC String generation** — Consent choices are encoded into the standard TC String format.
|
|
33
33
|
5. **`__tcfapi` stub** — The standard CMP API is exposed on `window` so vendor scripts can query consent.
|
|
34
34
|
|
|
35
|
+
If you use the prebuilt styled IAB UI, add your framework's `iab/styles.css` entrypoint alongside the base c15t stylesheet. IAB CSS is published separately so apps that do not render IAB surfaces do not ship those component rules.
|
|
36
|
+
|
|
35
37
|
## Quick Setup
|
|
36
38
|
|
|
39
|
+
If you use the prebuilt styled IAB UI, import the IAB stylesheet alongside the base stylesheet in your global CSS entrypoint:
|
|
40
|
+
|
|
41
|
+
```css title="src/index.css"
|
|
42
|
+
@import "@c15t/react/styles.css";
|
|
43
|
+
@import "@c15t/react/iab/styles.css";
|
|
44
|
+
```
|
|
45
|
+
|
|
37
46
|
```tsx
|
|
38
47
|
import { type ReactNode } from 'react';
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
IABConsentBanner,
|
|
42
|
-
IABConsentDialog,
|
|
43
|
-
} from '@c15t/react';
|
|
48
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
49
|
+
import { IABConsentBanner, IABConsentDialog } from '@c15t/react/iab';
|
|
44
50
|
|
|
45
51
|
export default function ConsentManager({ children }: { children: ReactNode }) {
|
|
46
52
|
return (
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Build a Custom Script Integration
|
|
3
|
+
description: Learn when to use a raw Script, when to build a reusable manifest-backed integration, and how to debug and test custom consent-aware scripts in c15t.
|
|
4
|
+
lastModified: 2026-04-10
|
|
5
|
+
---
|
|
6
|
+
If you cannot find a prebuilt integration in [`@c15t/scripts`](/docs/integrations), you have two good options:
|
|
7
|
+
|
|
8
|
+
1. Build a one-off `Script` object directly in your app.
|
|
9
|
+
2. Build a reusable manifest-backed integration helper.
|
|
10
|
+
|
|
11
|
+
Use the first option for app-specific scripts. Use the second option when you want something reusable, testable, and aligned with c15t's manifest system.
|
|
12
|
+
|
|
13
|
+
## Choose the Right Level
|
|
14
|
+
|
|
15
|
+
### One-off app script
|
|
16
|
+
|
|
17
|
+
Use a raw `Script` when:
|
|
18
|
+
|
|
19
|
+
* the integration is only used in one app
|
|
20
|
+
* the vendor setup is small
|
|
21
|
+
* you do not need to publish or share the helper
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import type { Script } from 'c15t';
|
|
25
|
+
|
|
26
|
+
export function acmeAnalytics(siteId: string): Script {
|
|
27
|
+
return {
|
|
28
|
+
id: 'acme-analytics',
|
|
29
|
+
src: `https://cdn.acme.com/analytics.js?site=${siteId}`,
|
|
30
|
+
category: 'measurement',
|
|
31
|
+
onBeforeLoad: () => {
|
|
32
|
+
window.acmeQueue = window.acmeQueue || [];
|
|
33
|
+
},
|
|
34
|
+
onConsentChange: ({ hasConsent }) => {
|
|
35
|
+
window.acme?.setConsent(hasConsent);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Reusable manifest-backed integration
|
|
42
|
+
|
|
43
|
+
Use a manifest-backed helper when:
|
|
44
|
+
|
|
45
|
+
* you want to contribute to `@c15t/scripts`
|
|
46
|
+
* you want the integration to be reusable across apps
|
|
47
|
+
* you need structured startup/setup phases
|
|
48
|
+
* you want compatibility with c15t's server-side support for script loading
|
|
49
|
+
|
|
50
|
+
Manifest integrations should be declarative, serializable, and built from structured steps rather than raw inline JavaScript strings.
|
|
51
|
+
|
|
52
|
+
## Manifest Contract
|
|
53
|
+
|
|
54
|
+
Every reusable manifest carries two contract fields:
|
|
55
|
+
|
|
56
|
+
* `kind`: identifies the payload as a c15t vendor manifest
|
|
57
|
+
* `schemaVersion`: identifies which manifest schema the runtime should compile
|
|
58
|
+
|
|
59
|
+
Use `vendorManifestContract` so helpers stay aligned with the runtime's current contract:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const acmeManifest = {
|
|
63
|
+
...vendorManifestContract,
|
|
64
|
+
vendor: 'acme-analytics',
|
|
65
|
+
// ...
|
|
66
|
+
} as const satisfies VendorManifest;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
If manifests are sent from a server later, these fields are how the client can validate that it knows how to interpret the payload before executing anything.
|
|
70
|
+
|
|
71
|
+
## Manifest Mental Model
|
|
72
|
+
|
|
73
|
+
The manifest runtime executes a script in ordered phases:
|
|
74
|
+
|
|
75
|
+
* `bootstrap`: globals or stubs that must exist before anything else
|
|
76
|
+
* `install`: startup steps plus a single `loadScript`
|
|
77
|
+
* `afterLoad`: work that should run after the external script loads
|
|
78
|
+
* `onBeforeLoadGranted` / `onBeforeLoadDenied`: initial consent-specific setup
|
|
79
|
+
* `onLoadGranted` / `onLoadDenied`: post-load consent-specific setup
|
|
80
|
+
* `onConsentChange`: runs on every consent update
|
|
81
|
+
* `onConsentGranted` / `onConsentDenied`: branch-specific consent updates
|
|
82
|
+
|
|
83
|
+
For vendors with explicit consent APIs, you can also use:
|
|
84
|
+
|
|
85
|
+
* `consentMapping`
|
|
86
|
+
* `consentSignal`
|
|
87
|
+
* `consentSignalTarget`
|
|
88
|
+
|
|
89
|
+
That is how the Google integrations map c15t consent categories to Consent Mode v2 and inject `default` and `update` signals in the correct phase order.
|
|
90
|
+
|
|
91
|
+
`category` supports the same consent condition model as a plain `Script`, so manifests can represent simple or nested rules such as:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
category: { and: ['measurement', { not: 'marketing' }] }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Structured Steps
|
|
98
|
+
|
|
99
|
+
Prefer structured steps over raw script text. The current manifest DSL supports patterns like:
|
|
100
|
+
|
|
101
|
+
* `setGlobal`
|
|
102
|
+
* `setGlobalPath`
|
|
103
|
+
* `defineQueueFunction`
|
|
104
|
+
* `defineStubFunction`
|
|
105
|
+
* `pushToQueue`
|
|
106
|
+
* `callGlobal`
|
|
107
|
+
* `defineQueueMethods`
|
|
108
|
+
* `defineGlobalMethods`
|
|
109
|
+
* `constructGlobal`
|
|
110
|
+
* `loadScript`
|
|
111
|
+
|
|
112
|
+
These steps are easier to validate, test, debug, and eventually transport from the server.
|
|
113
|
+
|
|
114
|
+
## Example Manifest Integration
|
|
115
|
+
|
|
116
|
+
If you are building a reusable helper, the pattern looks like this:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import type { Script } from 'c15t';
|
|
120
|
+
import { resolveManifest } from '@c15t/scripts/resolve';
|
|
121
|
+
import {
|
|
122
|
+
vendorManifestContract,
|
|
123
|
+
type VendorManifest,
|
|
124
|
+
} from '@c15t/scripts/types';
|
|
125
|
+
|
|
126
|
+
const acmeManifest = {
|
|
127
|
+
...vendorManifestContract,
|
|
128
|
+
vendor: 'acme-analytics',
|
|
129
|
+
category: 'measurement',
|
|
130
|
+
bootstrap: [
|
|
131
|
+
{
|
|
132
|
+
type: 'setGlobal',
|
|
133
|
+
name: 'acmeQueue',
|
|
134
|
+
value: [],
|
|
135
|
+
ifUndefined: true,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'defineQueueFunction',
|
|
139
|
+
name: 'acme',
|
|
140
|
+
queue: 'acmeQueue',
|
|
141
|
+
ifUndefined: true,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
install: [
|
|
145
|
+
{
|
|
146
|
+
type: 'callGlobal',
|
|
147
|
+
global: 'acme',
|
|
148
|
+
args: ['init', '{{siteId}}'],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: 'loadScript',
|
|
152
|
+
src: 'https://cdn.acme.com/analytics.js?site={{siteId}}',
|
|
153
|
+
async: true,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
onConsentGranted: [
|
|
157
|
+
{
|
|
158
|
+
type: 'callGlobal',
|
|
159
|
+
global: 'acme',
|
|
160
|
+
args: ['consent', true],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
onConsentDenied: [
|
|
164
|
+
{
|
|
165
|
+
type: 'callGlobal',
|
|
166
|
+
global: 'acme',
|
|
167
|
+
args: ['consent', false],
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
} as const satisfies VendorManifest;
|
|
171
|
+
|
|
172
|
+
export function acmeAnalytics(siteId: string): Script {
|
|
173
|
+
return resolveManifest(acmeManifest, { siteId });
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Design Guidelines
|
|
178
|
+
|
|
179
|
+
When building an integration, prefer these rules:
|
|
180
|
+
|
|
181
|
+
* Keep helper logic thin. Put behavior in the manifest, not in post-resolution callback mutation.
|
|
182
|
+
* Keep manifests serializable. Avoid helper-only runtime branches where possible.
|
|
183
|
+
* Use explicit config inputs. Avoid generic override bags when a named option is clearer.
|
|
184
|
+
* Use `alwaysLoad` only when the vendor truly manages its own consent correctly.
|
|
185
|
+
* Use `persistAfterConsentRevoked` only when the vendor exposes a real consent toggle and does not need a full reload.
|
|
186
|
+
* Keep vendor-specific naming out of the core DSL when a generic step can express it.
|
|
187
|
+
|
|
188
|
+
## Testing Checklist
|
|
189
|
+
|
|
190
|
+
At minimum, test these flows:
|
|
191
|
+
|
|
192
|
+
1. Initial page load with consent denied.
|
|
193
|
+
2. Initial page load with consent granted.
|
|
194
|
+
3. Consent granted after the script was previously denied.
|
|
195
|
+
4. Consent revoked after the script was previously active.
|
|
196
|
+
5. Existing script element reuse if the script persists after revocation.
|
|
197
|
+
6. Error handling if the vendor global or loader is missing.
|
|
198
|
+
|
|
199
|
+
If you are contributing to `@c15t/scripts`, add focused engine/helper tests similar to the existing tests in `packages/scripts/src/engine.test.ts` and `packages/scripts/src/helpers.test.ts`.
|
|
200
|
+
|
|
201
|
+
## Debugging
|
|
202
|
+
|
|
203
|
+
Use `@c15t/dev-tools` while implementing and testing integrations.
|
|
204
|
+
|
|
205
|
+
The scripts panel now shows:
|
|
206
|
+
|
|
207
|
+
* whether a script is loaded, pending, or blocked
|
|
208
|
+
* grouped activity for `onBeforeLoad`, `onLoad`, and `onConsentChange`
|
|
209
|
+
* manifest phase activity such as `bootstrap`, `consent-default`, `setup`, and `afterLoad`
|
|
210
|
+
|
|
211
|
+
The events panel also records script lifecycle and manifest step events, which is useful when a vendor reads consent too early or a startup step runs in the wrong order.
|
|
212
|
+
|
|
213
|
+
## When to Stop and Use a Plain Script
|
|
214
|
+
|
|
215
|
+
Not every integration needs a reusable manifest helper.
|
|
216
|
+
|
|
217
|
+
If the vendor snippet is tiny, unique to one app, or mostly static, a plain `Script` object in your runtime options is usually the simpler choice. Reach for the manifest system when you need reuse, consistency, structured startup behavior, or a path to server-driven manifests.
|
|
218
|
+
|
|
219
|
+
## Reference Types
|
|
220
|
+
|
|
221
|
+
### Script
|
|
222
|
+
|
|
223
|
+
|Property|Type|Description|Default|Required|
|
|
224
|
+
|:--|:--|:--|:--|:--:|
|
|
225
|
+
|id|string|Unique identifier for the script|-|✅ Required|
|
|
226
|
+
|src|string \|undefined|URL of the script to load|-|Optional|
|
|
227
|
+
|textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
|
|
228
|
+
|category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
|
|
229
|
+
|callbackOnly|boolean \|undefined|Whether this is a callback-only script that doesn't need to load an external resource. When true, no script tag will be added to the DOM, only callbacks will be executed.|false|Optional|
|
|
230
|
+
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
|
|
231
|
+
|alwaysLoad|boolean \|undefined|Whether the script should always load regardless of consent state. This is useful for scripts like Google Tag Manager or PostHog that manage their own consent state internally. The script will load immediately and never be unloaded based on consent changes. Note: When using this option, you are responsible for ensuring the script itself respects user consent preferences through its own consent management.|false|Optional|
|
|
232
|
+
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
233
|
+
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
234
|
+
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
235
|
+
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
236
|
+
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
237
|
+
|anonymizeId|boolean \|undefined|Whether to use an anonymized ID for the script element, this helps ensure the script is not blocked by ad blockers|true|Optional|
|
|
238
|
+
|target|"head" \|"body" \|undefined|Where to inject the script element in the DOM. Options: \`'head'\`: Scripts are appended to \`\<head>\` (default); \`'body'\`: Scripts are appended to \`\<body>\`|'head'|Optional|
|
|
239
|
+
|onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
240
|
+
|onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
241
|
+
|onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
242
|
+
|onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
243
|
+
|vendorId|string \|number \|undefined|IAB TCF vendor ID - links script to a registered vendor. When in IAB mode, the script will only load if this vendor has consent. Takes precedence over \`category\` when in IAB mode. Use custom vendor IDs (string or number) to gate non-IAB vendors too.|-|Optional|
|
|
244
|
+
|iabPurposes|number\[] \|undefined|IAB TCF purpose IDs this script requires consent for. When in IAB mode and no vendorId is set, the script will only load if ALL specified purposes have consent.|-|Optional|
|
|
245
|
+
|iabLegIntPurposes|number\[] \|undefined|IAB TCF legitimate interest purpose IDs. These purposes can operate under legitimate interest instead of consent. The script loads if all iabPurposes have consent OR all iabLegIntPurposes have legitimate interest established.|-|Optional|
|
|
246
|
+
|iabSpecialFeatures|number\[] \|undefined|IAB TCF special feature IDs this script requires. Options: 1: Use precise geolocation data; 2: Actively scan device characteristics for identification|-|Optional|
|
|
247
|
+
|
|
248
|
+
#### `onBeforeLoad`
|
|
249
|
+
|
|
250
|
+
Callback executed before the script is loaded
|
|
251
|
+
|
|
252
|
+
|Property|Type|Description|Default|Required|
|
|
253
|
+
|:--|:--|:--|:--|:--:|
|
|
254
|
+
|id|string|The original script ID|-|✅ Required|
|
|
255
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
256
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
257
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
258
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
259
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
260
|
+
|
|
261
|
+
#### `onLoad`
|
|
262
|
+
|
|
263
|
+
Callback executed when the script loads successfully
|
|
264
|
+
|
|
265
|
+
|Property|Type|Description|Default|Required|
|
|
266
|
+
|:--|:--|:--|:--|:--:|
|
|
267
|
+
|id|string|The original script ID|-|✅ Required|
|
|
268
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
269
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
270
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
271
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
272
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
273
|
+
|
|
274
|
+
#### `onError`
|
|
275
|
+
|
|
276
|
+
Callback executed if the script fails to load
|
|
277
|
+
|
|
278
|
+
|Property|Type|Description|Default|Required|
|
|
279
|
+
|:--|:--|:--|:--|:--:|
|
|
280
|
+
|id|string|The original script ID|-|✅ Required|
|
|
281
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
282
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
283
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
284
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
285
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
286
|
+
|
|
287
|
+
#### `onConsentChange`
|
|
288
|
+
|
|
289
|
+
Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
|
|
290
|
+
|
|
291
|
+
|Property|Type|Description|Default|Required|
|
|
292
|
+
|:--|:--|:--|:--|:--:|
|
|
293
|
+
|id|string|The original script ID|-|✅ Required|
|
|
294
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
295
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
296
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
297
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
298
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
299
|
+
|
|
300
|
+
### VendorManifest
|
|
301
|
+
|
|
302
|
+
|Property|Type|Description|Default|Required|
|
|
303
|
+
|:--|:--|:--|:--|:--:|
|
|
304
|
+
|kind|"c15t.vendor-manifest"|Manifest contract identifier.|-|✅ Required|
|
|
305
|
+
|schemaVersion|1|Manifest schema version.|-|✅ Required|
|
|
306
|
+
|vendor|string|Unique vendor identifier (used as Script.id)|-|✅ Required|
|
|
307
|
+
|category|ManifestCategoryCondition|Consent category or condition required to load this vendor|-|✅ Required|
|
|
308
|
+
|alwaysLoad|string \|boolean \|undefined|Load regardless of consent state (vendor manages its own consent internally)|-|Optional|
|
|
309
|
+
|persistAfterConsentRevoked|string \|boolean \|undefined|Keep script in DOM after consent revocation (vendor has a consent API)|-|Optional|
|
|
310
|
+
|bootstrap|ManifestStep \|undefined|Steps that must execute before default consent signaling. This is primarily used for integrations such as Google tags where a stub global must exist before calling the vendor's consent API.|-|Optional|
|
|
311
|
+
|install|ManifestStep|Steps to execute when installing the vendor.|-|✅ Required|
|
|
312
|
+
|afterLoad|ManifestStep \|undefined|Steps to execute after the main script loads|-|Optional|
|
|
313
|
+
|onBeforeLoadGranted|ManifestStep \|undefined|Steps to execute before load when the vendor has consent|-|Optional|
|
|
314
|
+
|onBeforeLoadDenied|ManifestStep \|undefined|Steps to execute before load when the vendor does not have consent|-|Optional|
|
|
315
|
+
|onLoadGranted|ManifestStep \|undefined|Steps to execute after load when the vendor has consent|-|Optional|
|
|
316
|
+
|onLoadDenied|ManifestStep \|undefined|Steps to execute after load when the vendor does not have consent|-|Optional|
|
|
317
|
+
|onConsentChange|ManifestStep \|undefined|Steps to run on any consent state change|-|Optional|
|
|
318
|
+
|onConsentGranted|ManifestStep \|undefined|Steps to run when this vendor's category consent is granted|-|Optional|
|
|
319
|
+
|onConsentDenied|ManifestStep \|undefined|Steps to run when this vendor's category consent is denied|-|Optional|
|
|
320
|
+
|consentMapping|Record\<string, string\[]> \|undefined|Maps c15t consent categories to vendor-specific consent type names. Used with \`consentSignal\` to translate c15t consent state into the vendor's consent API format.|-|Optional|
|
|
321
|
+
|consentSignal|"gtag" \|undefined|How to signal consent state to the vendor|-|Optional|
|
|
322
|
+
|consentSignalTarget|string \|undefined|Target global for consent signaling (defaults based on signal type)|-|Optional|
|
|
323
|
+
|
|
324
|
+
#### `bootstrap` ManifestStep
|
|
325
|
+
|
|
326
|
+
Steps that must execute before default consent signaling. This is primarily used for integrations such as Google tags where a stub global must exist before calling the vendor's consent API.
|
|
327
|
+
|
|
328
|
+
|Property|Type|Description|Default|Required|
|
|
329
|
+
|:--|:--|:--|:--|:--:|
|
|
330
|
+
|type|Object|-|-|✅ Required|
|
|
331
|
+
|
|
332
|
+
#### `install` ManifestStep
|
|
333
|
+
|
|
334
|
+
Steps to execute when installing the vendor.
|
|
335
|
+
|
|
336
|
+
* If a \`loadScript\` step exists, its \`src\` becomes \`Script.src\`
|
|
337
|
+
* All non-\`loadScript\` steps run as part of \`onBeforeLoad\`
|
|
338
|
+
|
|
339
|
+
|Property|Type|Description|Default|Required|
|
|
340
|
+
|:--|:--|:--|:--|:--:|
|
|
341
|
+
|type|Object|-|-|✅ Required|
|
|
342
|
+
|
|
343
|
+
#### `afterLoad` ManifestStep
|
|
344
|
+
|
|
345
|
+
Steps to execute after the main script loads
|
|
346
|
+
|
|
347
|
+
|Property|Type|Description|Default|Required|
|
|
348
|
+
|:--|:--|:--|:--|:--:|
|
|
349
|
+
|type|Object|-|-|✅ Required|
|
|
350
|
+
|
|
351
|
+
#### `onBeforeLoadGranted` ManifestStep
|
|
352
|
+
|
|
353
|
+
Steps to execute before load when the vendor has consent
|
|
354
|
+
|
|
355
|
+
|Property|Type|Description|Default|Required|
|
|
356
|
+
|:--|:--|:--|:--|:--:|
|
|
357
|
+
|type|Object|-|-|✅ Required|
|
|
358
|
+
|
|
359
|
+
#### `onBeforeLoadDenied` ManifestStep
|
|
360
|
+
|
|
361
|
+
Steps to execute before load when the vendor does not have consent
|
|
362
|
+
|
|
363
|
+
|Property|Type|Description|Default|Required|
|
|
364
|
+
|:--|:--|:--|:--|:--:|
|
|
365
|
+
|type|Object|-|-|✅ Required|
|
|
366
|
+
|
|
367
|
+
#### `onLoadGranted` ManifestStep
|
|
368
|
+
|
|
369
|
+
Steps to execute after load when the vendor has consent
|
|
370
|
+
|
|
371
|
+
|Property|Type|Description|Default|Required|
|
|
372
|
+
|:--|:--|:--|:--|:--:|
|
|
373
|
+
|type|Object|-|-|✅ Required|
|
|
374
|
+
|
|
375
|
+
#### `onLoadDenied` ManifestStep
|
|
376
|
+
|
|
377
|
+
Steps to execute after load when the vendor does not have consent
|
|
378
|
+
|
|
379
|
+
|Property|Type|Description|Default|Required|
|
|
380
|
+
|:--|:--|:--|:--|:--:|
|
|
381
|
+
|type|Object|-|-|✅ Required|
|
|
382
|
+
|
|
383
|
+
#### `onConsentChange` ManifestStep
|
|
384
|
+
|
|
385
|
+
Steps to run on any consent state change
|
|
386
|
+
|
|
387
|
+
|Property|Type|Description|Default|Required|
|
|
388
|
+
|:--|:--|:--|:--|:--:|
|
|
389
|
+
|type|Object|-|-|✅ Required|
|
|
390
|
+
|
|
391
|
+
#### `onConsentGranted` ManifestStep
|
|
392
|
+
|
|
393
|
+
Steps to run when this vendor's category consent is granted
|
|
394
|
+
|
|
395
|
+
|Property|Type|Description|Default|Required|
|
|
396
|
+
|:--|:--|:--|:--|:--:|
|
|
397
|
+
|type|Object|-|-|✅ Required|
|
|
398
|
+
|
|
399
|
+
#### `onConsentDenied` ManifestStep
|
|
400
|
+
|
|
401
|
+
Steps to run when this vendor's category consent is denied
|
|
402
|
+
|
|
403
|
+
|Property|Type|Description|Default|Required|
|
|
404
|
+
|:--|:--|:--|:--|:--:|
|
|
405
|
+
|type|Object|-|-|✅ Required|
|
|
@@ -22,9 +22,17 @@ The Databuddy script automatically respects consent preferences by toggling trac
|
|
|
22
22
|
clientId: 'your-client-id',
|
|
23
23
|
scriptUrl: 'https://cdn.databuddy.cc/databuddy.js',
|
|
24
24
|
apiUrl: 'https://basket.databuddy.cc',
|
|
25
|
-
|
|
25
|
+
configWhenGranted: {
|
|
26
|
+
clientId: 'your-client-id',
|
|
27
|
+
apiUrl: 'https://basket.databuddy.cc',
|
|
26
28
|
trackScreenViews: true,
|
|
27
29
|
trackOutgoingLinks: true,
|
|
30
|
+
disabled: false,
|
|
31
|
+
},
|
|
32
|
+
configWhenDenied: {
|
|
33
|
+
clientId: 'your-client-id',
|
|
34
|
+
apiUrl: 'https://basket.databuddy.cc',
|
|
35
|
+
disabled: true,
|
|
28
36
|
}
|
|
29
37
|
})
|
|
30
38
|
```
|
|
@@ -68,14 +76,17 @@ This ensures that no tracking occurs without user consent, keeping your analytic
|
|
|
68
76
|
|
|
69
77
|
## Configuration Options
|
|
70
78
|
|
|
71
|
-
The
|
|
79
|
+
The Databuddy manifest expects explicit initial config objects for the granted
|
|
80
|
+
and denied consent states:
|
|
72
81
|
|
|
73
82
|
```ts
|
|
74
83
|
databuddy({
|
|
75
84
|
clientId: 'your-client-id',
|
|
76
85
|
scriptUrl: 'https://cdn.databuddy.cc/databuddy.js',
|
|
77
86
|
apiUrl: 'https://basket.databuddy.cc', // Optional, defaults to basket.databuddy.cc, change if self-hosting
|
|
78
|
-
|
|
87
|
+
configWhenGranted: {
|
|
88
|
+
clientId: 'your-client-id',
|
|
89
|
+
apiUrl: 'https://basket.databuddy.cc',
|
|
79
90
|
// Tracking options
|
|
80
91
|
trackScreenViews: true, // Automatically track page views
|
|
81
92
|
trackOutgoingLinks: true, // Track clicks on external links
|
|
@@ -90,6 +101,12 @@ databuddy({
|
|
|
90
101
|
batchSize: 10, // Events per batch
|
|
91
102
|
batchTimeout: 2000, // Batch timeout in ms
|
|
92
103
|
samplingRate: 1.0, // Sample rate (0.0-1.0)
|
|
104
|
+
disabled: false,
|
|
105
|
+
},
|
|
106
|
+
configWhenDenied: {
|
|
107
|
+
clientId: 'your-client-id',
|
|
108
|
+
apiUrl: 'https://basket.databuddy.cc',
|
|
109
|
+
disabled: true,
|
|
93
110
|
}
|
|
94
111
|
})
|
|
95
112
|
```
|
|
@@ -103,8 +120,8 @@ databuddy({
|
|
|
103
120
|
|clientId|string|Your Databuddy client ID.|-|✅ Required|
|
|
104
121
|
|apiUrl|string \|undefined|Your Databuddy API URL.|'https\://basket.databuddy.cc'|Optional|
|
|
105
122
|
|scriptUrl|string \|undefined|The Databuddy script URL.|'https\://cdn.databuddy.cc/databuddy.js'|Optional|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
123
|
+
|configWhenGranted|Record\<string, unknown>|Databuddy config object to seed when consent is granted at load time.|-|✅ Required|
|
|
124
|
+
|configWhenDenied|Record\<string, unknown>|Databuddy config object to seed when consent is denied at load time.|-|✅ Required|
|
|
108
125
|
|
|
109
126
|
### Script
|
|
110
127
|
|
|
@@ -70,8 +70,8 @@ This prevents GTM-managed scripts from loading without proper consent while givi
|
|
|
70
70
|
|Property|Type|Description|Default|Required|
|
|
71
71
|
|:--|:--|:--|:--|:--:|
|
|
72
72
|
|id|string|Your Google Tag Manager container ID. Begins with 'GTM-'.|-|✅ Required|
|
|
73
|
-
|updateEventName|string \|undefined|
|
|
74
|
-
|
|
|
73
|
+
|updateEventName|string \|undefined|Custom event name fired after consent updates. Can be used as a trigger in GTM to load scripts once consent is updated.|'consent-update'|Optional|
|
|
74
|
+
|consentMapping|Record\<string, string\[]> \|undefined|Custom mapping from c15t consent categories to Google Consent Mode v2 types. Overrides the default mapping when provided.|\`\`\`ts \{ necessary: \['security\_storage'], functionality: \['functionality\_storage'], measurement: \['analytics\_storage'], marketing: \['ad\_storage', 'ad\_user\_data', 'ad\_personalization'], experience: \['personalization\_storage'], } \`\`\`|Optional|
|
|
75
75
|
|
|
76
76
|
### Script
|
|
77
77
|
|
|
@@ -39,35 +39,8 @@ gtag({
|
|
|
39
39
|
|:--|:--|:--|:--|:--:|
|
|
40
40
|
|id|string|Your gtag id|-|✅ Required|
|
|
41
41
|
|category|AllConsentNames|The consent category to use for the gtag script. This is typically marketing (Ads & Floodlight) or measurement (Analytics)|-|✅ Required|
|
|
42
|
-
|
|
|
43
|
-
|
|
44
|
-
#### `script`
|
|
45
|
-
|
|
46
|
-
Override or extend the default script values. Options: \`id\`: 'gtag'; \`src\`: \`https\://www\.googletagmanager.com/gtag/js?id=$\{id}\`; \`async\`: true; \`alwaysLoad\`: true
|
|
47
|
-
|
|
48
|
-
|Property|Type|Description|Default|Required|
|
|
49
|
-
|:--|:--|:--|:--|:--:|
|
|
50
|
-
|id|string \|undefined|Unique identifier for the script|-|✅ Required|
|
|
51
|
-
|src|string \|undefined|URL of the script to load|-|Optional|
|
|
52
|
-
|textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
|
|
53
|
-
|callbackOnly|boolean \|undefined|Whether this is a callback-only script that doesn't need to load an external resource. When true, no script tag will be added to the DOM, only callbacks will be executed.|-|Optional|
|
|
54
|
-
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|-|Optional|
|
|
55
|
-
|alwaysLoad|boolean \|undefined|Whether the script should always load regardless of consent state. This is useful for scripts like Google Tag Manager or PostHog that manage their own consent state internally. The script will load immediately and never be unloaded based on consent changes. Note: When using this option, you are responsible for ensuring the script itself respects user consent preferences through its own consent management.|-|Optional|
|
|
56
|
-
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
57
|
-
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
58
|
-
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
59
|
-
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
60
|
-
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
61
|
-
|anonymizeId|boolean \|undefined|Whether to use an anonymized ID for the script element, this helps ensure the script is not blocked by ad blockers|-|Optional|
|
|
62
|
-
|target|"head" \|"body" \|undefined|Where to inject the script element in the DOM. Options: \`'head'\`: Scripts are appended to \`\<head>\` (default); \`'body'\`: Scripts are appended to \`\<body>\`|-|Optional|
|
|
63
|
-
|onBeforeLoad|((info: ScriptCallbackInfo) => void) \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
64
|
-
|onLoad|((info: ScriptCallbackInfo) => void) \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
65
|
-
|onError|((info: ScriptCallbackInfo) => void) \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
66
|
-
|onConsentChange|((info: ScriptCallbackInfo) => void) \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
67
|
-
|vendorId|string \|number \|undefined|IAB TCF vendor ID - links script to a registered vendor. When in IAB mode, the script will only load if this vendor has consent. Takes precedence over \`category\` when in IAB mode. Use custom vendor IDs (string or number) to gate non-IAB vendors too.|-|Optional|
|
|
68
|
-
|iabPurposes|number\[] \|undefined|IAB TCF purpose IDs this script requires consent for. When in IAB mode and no vendorId is set, the script will only load if ALL specified purposes have consent.|-|Optional|
|
|
69
|
-
|iabLegIntPurposes|number\[] \|undefined|IAB TCF legitimate interest purpose IDs. These purposes can operate under legitimate interest instead of consent. The script loads if all iabPurposes have consent OR all iabLegIntPurposes have legitimate interest established.|-|Optional|
|
|
70
|
-
|iabSpecialFeatures|number\[] \|undefined|IAB TCF special feature IDs this script requires. Options: 1: Use precise geolocation data; 2: Actively scan device characteristics for identification|-|Optional|
|
|
42
|
+
|consentMapping|Record\<string, string\[]> \|undefined|Custom mapping from c15t consent categories to Google Consent Mode v2 types. Overrides the default mapping when provided.|\`\`\`ts \{ necessary: \['security\_storage'], functionality: \['functionality\_storage'], measurement: \['analytics\_storage'], marketing: \['ad\_storage', 'ad\_user\_data', 'ad\_personalization'], experience: \['personalization\_storage'], } \`\`\`|Optional|
|
|
43
|
+
|script|Script \|undefined|Deprecated script-level overrides preserved for backwards compatibility. Prefer manifest-backed options instead of this generic override bag.|-|Optional|
|
|
71
44
|
|
|
72
45
|
### Script
|
|
73
46
|
|