@c15t/nextjs 2.0.0-rc.0 → 2.0.0-rc.10
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 +10 -3
- package/client/components/consent-dialog-link.js +3 -0
- package/dist/headless.cjs +1 -1
- package/dist/iab/styles.css +12 -0
- package/dist/iab/styles.tw3.css +14 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/libs/browser-initial-data.cjs +1 -0
- package/dist/libs/browser-initial-data.js +1 -0
- package/dist/libs/initial-data.cjs +1 -1
- package/dist/libs/initial-data.js +1 -1
- package/dist/styles.css +10 -0
- package/dist/styles.tw3.css +13 -0
- package/dist/types.cjs +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/{dist → dist-types}/headless.d.ts +0 -1
- package/{dist → dist-types}/index.d.ts +3 -2
- package/dist-types/libs/browser-initial-data.d.ts +9 -0
- package/{dist → dist-types}/libs/initial-data.d.ts +7 -2
- package/dist-types/types.d.ts +38 -0
- package/dist-types/version.d.ts +1 -0
- package/docs/README.md +73 -0
- package/docs/building-headless-components.md +377 -0
- package/docs/callbacks.md +184 -0
- package/docs/components/consent-banner.md +269 -0
- package/docs/components/consent-dialog-link.md +59 -0
- package/docs/components/consent-dialog-trigger.md +103 -0
- package/docs/components/consent-dialog.md +177 -0
- package/docs/components/consent-manager-provider.md +425 -0
- package/docs/components/consent-widget.md +133 -0
- package/docs/components/dev-tools.md +63 -0
- package/docs/components/frame.md +73 -0
- package/docs/concepts/client-modes.md +175 -0
- package/docs/concepts/consent-categories.md +97 -0
- package/docs/concepts/consent-models.md +116 -0
- package/docs/concepts/cookie-management.md +122 -0
- package/docs/concepts/glossary.md +23 -0
- package/docs/concepts/initialization-flow.md +148 -0
- package/docs/concepts/policy-packs.md +229 -0
- package/docs/headless.md +190 -0
- package/docs/hooks/use-color-scheme.md +40 -0
- package/docs/hooks/use-consent-manager/checking-consent.md +94 -0
- package/docs/hooks/use-consent-manager/location-info.md +95 -0
- package/docs/hooks/use-consent-manager/overview.md +420 -0
- package/docs/hooks/use-consent-manager/setting-consent.md +92 -0
- package/docs/hooks/use-draggable.md +57 -0
- package/docs/hooks/use-focus-trap.md +41 -0
- package/docs/hooks/use-reduced-motion.md +35 -0
- package/docs/hooks/use-ssr-status.md +31 -0
- package/docs/hooks/use-text-direction.md +49 -0
- package/docs/hooks/use-translations.md +118 -0
- package/docs/iab/consent-banner.md +94 -0
- package/docs/iab/consent-dialog.md +134 -0
- package/docs/iab/overview.md +126 -0
- package/docs/iab/use-gvl-data.md +20 -0
- package/docs/iframe-blocking.md +107 -0
- package/docs/integrations/building-integrations.md +405 -0
- package/docs/integrations/databuddy.md +203 -0
- package/docs/integrations/google-tag-manager.md +153 -0
- package/docs/integrations/google-tag.md +122 -0
- package/docs/integrations/linkedin-insights.md +109 -0
- package/docs/integrations/meta-pixel.md +342 -0
- package/docs/integrations/microsoft-uet.md +112 -0
- package/docs/integrations/overview.md +105 -0
- package/docs/integrations/posthog.md +199 -0
- package/docs/integrations/tiktok-pixel.md +113 -0
- package/docs/integrations/x-pixel.md +143 -0
- package/docs/internationalization.md +197 -0
- package/docs/network-blocker.md +178 -0
- package/docs/optimization.md +234 -0
- package/docs/policy-packs.md +246 -0
- package/docs/quickstart.md +161 -0
- package/docs/script-loader.md +321 -0
- package/docs/server-side.md +176 -0
- package/docs/styling/classnames.md +92 -0
- package/docs/styling/color-scheme.md +82 -0
- package/docs/styling/css-variables.md +92 -0
- package/docs/styling/overview.md +456 -0
- package/docs/styling/slots.md +127 -0
- package/docs/styling/tailwind.md +113 -0
- package/docs/styling/tokens.md +216 -0
- package/docs/troubleshooting.md +146 -0
- package/iab/styles.css +1 -0
- package/package.json +38 -17
- package/readme.json +4 -0
- package/src/iab/styles.css +12 -0
- package/src/iab/styles.tw3.css +14 -0
- package/src/styles.css +10 -0
- package/src/styles.tw3.css +13 -0
- package/styles.css +1 -0
- package/dist/headless.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/libs/initial-data.d.ts.map +0 -1
- package/dist/types.d.ts +0 -16
- package/dist/types.d.ts.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PostHog
|
|
3
|
+
description: PostHog is an open-source product analytics platform for tracking user behavior, session replays, feature flags, and A/B testing. It supports cookieless tracking, allowing analytics to continue even without cookie consent.
|
|
4
|
+
lastModified: 2026-04-08
|
|
5
|
+
|
|
6
|
+
icon: posthog
|
|
7
|
+
---
|
|
8
|
+
PostHog is an open-source product analytics platform that helps you understand user behavior, track events, and analyze product usage. Unlike traditional analytics tools, PostHog supports both cookieless and cookie-based tracking. This means you can sync c15t with PostHog and continue collecting analytics even when users haven't given consent—PostHog simply operates in cookieless mode until consent is granted.
|
|
9
|
+
|
|
10
|
+
## PostHog SDK Implementation
|
|
11
|
+
|
|
12
|
+
This is the recommended approach if you're using the Posthog JS SDK, this is commonly used in React projects.
|
|
13
|
+
|
|
14
|
+
### Adding the PostHog SDK to c15t
|
|
15
|
+
|
|
16
|
+
1. **Initialize Posthog** When you initialize posthog make sure to set cookieless\_mode to on\_reject.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
posthog.init("phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", {
|
|
20
|
+
api_host: "https://eu.i.posthog.com",
|
|
21
|
+
defaults: "2025-05-24",
|
|
22
|
+
cookieless_mode: 'on_reject'
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
posthog.opt_out_capturing() // Avoids accidental tracking without consent till c15t has loaded
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. **Sync settled consent once, then subscribe to real changes** The recommended PostHog SDK approach uses two phases: run one initial sync after c15t has finished resolving consent, then subscribe to future real preference changes with subscribeToConsentChanges().
|
|
29
|
+
|
|
30
|
+
> ℹ️ Info:
|
|
31
|
+
>
|
|
32
|
+
> See the integration overview for how to wrap this in your framework (React or Next.js). Pass the callbacks option to your ConsentManagerProvider the same way you would pass scripts.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
36
|
+
import { posthog } from 'posthog-js';
|
|
37
|
+
|
|
38
|
+
function syncPostHogMeasurementConsent(hasMeasurementConsent: boolean) {
|
|
39
|
+
if (hasMeasurementConsent) {
|
|
40
|
+
posthog.opt_in_capturing();
|
|
41
|
+
} else {
|
|
42
|
+
posthog.opt_out_capturing();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const runtime = getOrCreateConsentRuntime({
|
|
47
|
+
mode: 'hosted',
|
|
48
|
+
callbacks: {
|
|
49
|
+
onBannerFetched() {
|
|
50
|
+
syncPostHogMeasurementConsent(
|
|
51
|
+
runtime.consentStore.getState().has('measurement')
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
runtime.consentStore
|
|
58
|
+
.getState()
|
|
59
|
+
.subscribeToConsentChanges(({ allowedCategories }) => {
|
|
60
|
+
syncPostHogMeasurementConsent(
|
|
61
|
+
allowedCategories.includes('measurement')
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> ℹ️ Info:
|
|
67
|
+
>
|
|
68
|
+
> Avoid using onConsentSet plus manual deduplication for PostHog. subscribeToConsentChanges() already gives you the exact change-only semantics most analytics SDKs need.
|
|
69
|
+
|
|
70
|
+
## PostHog Script Implementation
|
|
71
|
+
|
|
72
|
+
If you want to load posthog via a script tag it's recommended to use this approach.
|
|
73
|
+
|
|
74
|
+
By default c15t will always load the script regardless of consent. This is because the script has built-in functionality to opt into and out of tracking based on consent.
|
|
75
|
+
|
|
76
|
+
1. **Initialize Posthog** This script does not load the Posthog script, it only syncs the consent state with Posthog via the Posthog JS SDK.
|
|
77
|
+
|
|
78
|
+
This is due to Posthog's use of cookieless tracking. However, you need to set cookieless\_mode to on\_reject when initializing Posthog.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
posthog.init("phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", {
|
|
82
|
+
api_host: "https://eu.i.posthog.com",
|
|
83
|
+
defaults: "2025-05-24",
|
|
84
|
+
// PostHog will not set any cookies until the user has given consent
|
|
85
|
+
cookieless_mode: 'on_reject'
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
2. **Adding the script to c15t**
|
|
90
|
+
|
|
91
|
+
> ℹ️ Info:
|
|
92
|
+
>
|
|
93
|
+
> See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { posthog } from '@c15t/scripts/posthog';
|
|
97
|
+
|
|
98
|
+
posthog({
|
|
99
|
+
id: 'phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
|
100
|
+
apiHost: 'https://eu.i.posthog.com',
|
|
101
|
+
scriptUrl: 'https://eu-assets.i.posthog.com/static/array.js',
|
|
102
|
+
initOptions: {
|
|
103
|
+
api_host: 'https://eu.i.posthog.com',
|
|
104
|
+
ui_host: 'https://eu.i.posthog.com',
|
|
105
|
+
autocapture: false,
|
|
106
|
+
person_profiles: 'identified_only',
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Types
|
|
112
|
+
|
|
113
|
+
### PosthogConsentOptions
|
|
114
|
+
|
|
115
|
+
|Property|Type|Description|Default|Required|
|
|
116
|
+
|:--|:--|:--|:--|:--:|
|
|
117
|
+
|id|string|Your posthog id, begins with 'phc\_'.|-|✅ Required|
|
|
118
|
+
|apiHost|string \|undefined|Your posthog api host.|'https\://eu.i.posthog.com'|Optional|
|
|
119
|
+
|scriptUrl|string \|undefined|The PostHog array loader URL.|-|Optional|
|
|
120
|
+
|initOptions|Record\<string, unknown> \|undefined|PostHog init options passed to \`posthog.init(...)\`.|-|Optional|
|
|
121
|
+
|
|
122
|
+
### Script
|
|
123
|
+
|
|
124
|
+
|Property|Type|Description|Default|Required|
|
|
125
|
+
|:--|:--|:--|:--|:--:|
|
|
126
|
+
|id|string|Unique identifier for the script|-|✅ Required|
|
|
127
|
+
|src|string \|undefined|URL of the script to load|-|Optional|
|
|
128
|
+
|textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
|
|
129
|
+
|category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
|
|
130
|
+
|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|
|
|
131
|
+
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
|
|
132
|
+
|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|
|
|
133
|
+
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
134
|
+
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
135
|
+
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
136
|
+
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
137
|
+
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
138
|
+
|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|
|
|
139
|
+
|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|
|
|
140
|
+
|onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
141
|
+
|onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
142
|
+
|onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
143
|
+
|onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
144
|
+
|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|
|
|
145
|
+
|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|
|
|
146
|
+
|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|
|
|
147
|
+
|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|
|
|
148
|
+
|
|
149
|
+
#### `onBeforeLoad`
|
|
150
|
+
|
|
151
|
+
Callback executed before the script is loaded
|
|
152
|
+
|
|
153
|
+
|Property|Type|Description|Default|Required|
|
|
154
|
+
|:--|:--|:--|:--|:--:|
|
|
155
|
+
|id|string|The original script ID|-|✅ Required|
|
|
156
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
157
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
158
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
159
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
160
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
161
|
+
|
|
162
|
+
#### `onLoad`
|
|
163
|
+
|
|
164
|
+
Callback executed when the script loads successfully
|
|
165
|
+
|
|
166
|
+
|Property|Type|Description|Default|Required|
|
|
167
|
+
|:--|:--|:--|:--|:--:|
|
|
168
|
+
|id|string|The original script ID|-|✅ Required|
|
|
169
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
170
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
171
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
172
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
173
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
174
|
+
|
|
175
|
+
#### `onError`
|
|
176
|
+
|
|
177
|
+
Callback executed if the script fails to load
|
|
178
|
+
|
|
179
|
+
|Property|Type|Description|Default|Required|
|
|
180
|
+
|:--|:--|:--|:--|:--:|
|
|
181
|
+
|id|string|The original script ID|-|✅ Required|
|
|
182
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
183
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
184
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
185
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
186
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
187
|
+
|
|
188
|
+
#### `onConsentChange`
|
|
189
|
+
|
|
190
|
+
Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
|
|
191
|
+
|
|
192
|
+
|Property|Type|Description|Default|Required|
|
|
193
|
+
|:--|:--|:--|:--|:--:|
|
|
194
|
+
|id|string|The original script ID|-|✅ Required|
|
|
195
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
196
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
197
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
198
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
199
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TikTok Pixel
|
|
3
|
+
description: Measure ad performance and build audiences for TikTok advertising campaigns.
|
|
4
|
+
lastModified: 2025-09-24
|
|
5
|
+
|
|
6
|
+
icon: tiktok
|
|
7
|
+
---
|
|
8
|
+
TikTok Pixel is TikTok's conversion tracking and audience targeting tool. It measures ad effectiveness, tracks user actions, and helps optimize your TikTok advertising campaigns. By default, c15t loads this script based on `marketing` consent.
|
|
9
|
+
|
|
10
|
+
This script persists after consent is revoked because it has built-in consent management. When consent changes, c15t updates TikTok's internal consent state rather than removing the script entirely.
|
|
11
|
+
|
|
12
|
+
## Implementation
|
|
13
|
+
|
|
14
|
+
### Adding the script to c15t
|
|
15
|
+
|
|
16
|
+
> ℹ️ **Info:**
|
|
17
|
+
> See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { tiktokPixel } from '@c15t/scripts/tiktok-pixel';
|
|
21
|
+
|
|
22
|
+
tiktokPixel({
|
|
23
|
+
pixelId: '123456789012345',
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Types
|
|
28
|
+
|
|
29
|
+
### TikTokPixelOptions
|
|
30
|
+
|
|
31
|
+
|Property|Type|Description|Default|Required|
|
|
32
|
+
|:--|:--|:--|:--|:--:|
|
|
33
|
+
|pixelId|string|Your TikTok Pixel ID|-|✅ Required|
|
|
34
|
+
|scriptSrc|string \|undefined|TikTok Pixel loader base URL.|-|Optional|
|
|
35
|
+
|
|
36
|
+
### Script
|
|
37
|
+
|
|
38
|
+
|Property|Type|Description|Default|Required|
|
|
39
|
+
|:--|:--|:--|:--|:--:|
|
|
40
|
+
|id|string|Unique identifier for the script|-|✅ Required|
|
|
41
|
+
|src|string \|undefined|URL of the script to load|-|Optional|
|
|
42
|
+
|textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
|
|
43
|
+
|category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
|
|
44
|
+
|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|
|
|
45
|
+
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
|
|
46
|
+
|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|
|
|
47
|
+
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
48
|
+
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
49
|
+
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
50
|
+
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
51
|
+
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
52
|
+
|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|
|
|
53
|
+
|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|
|
|
54
|
+
|onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
55
|
+
|onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
56
|
+
|onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
57
|
+
|onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
58
|
+
|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|
|
|
59
|
+
|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|
|
|
60
|
+
|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|
|
|
61
|
+
|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|
|
|
62
|
+
|
|
63
|
+
#### `onBeforeLoad`
|
|
64
|
+
|
|
65
|
+
Callback executed before the script is loaded
|
|
66
|
+
|
|
67
|
+
|Property|Type|Description|Default|Required|
|
|
68
|
+
|:--|:--|:--|:--|:--:|
|
|
69
|
+
|id|string|The original script ID|-|✅ Required|
|
|
70
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
71
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
72
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
73
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
74
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
75
|
+
|
|
76
|
+
#### `onLoad`
|
|
77
|
+
|
|
78
|
+
Callback executed when the script loads successfully
|
|
79
|
+
|
|
80
|
+
|Property|Type|Description|Default|Required|
|
|
81
|
+
|:--|:--|:--|:--|:--:|
|
|
82
|
+
|id|string|The original script ID|-|✅ Required|
|
|
83
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
84
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
85
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
86
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
87
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
88
|
+
|
|
89
|
+
#### `onError`
|
|
90
|
+
|
|
91
|
+
Callback executed if the script fails to load
|
|
92
|
+
|
|
93
|
+
|Property|Type|Description|Default|Required|
|
|
94
|
+
|:--|:--|:--|:--|:--:|
|
|
95
|
+
|id|string|The original script ID|-|✅ Required|
|
|
96
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
97
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
98
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
99
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
100
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
101
|
+
|
|
102
|
+
#### `onConsentChange`
|
|
103
|
+
|
|
104
|
+
Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
|
|
105
|
+
|
|
106
|
+
|Property|Type|Description|Default|Required|
|
|
107
|
+
|:--|:--|:--|:--|:--:|
|
|
108
|
+
|id|string|The original script ID|-|✅ Required|
|
|
109
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
110
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
111
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
112
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
113
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: X Pixel (Twitter Pixel)
|
|
3
|
+
description: Track conversions and build audiences for advertising campaigns on X (formerly Twitter).
|
|
4
|
+
lastModified: 2025-09-24
|
|
5
|
+
|
|
6
|
+
icon: x
|
|
7
|
+
---
|
|
8
|
+
X Pixel (formerly Twitter Pixel) is X's conversion tracking and audience building tool. It helps you measure ad performance, retarget website visitors, and optimize campaigns on the X platform. By default, c15t loads this script based on `marketing` consent.
|
|
9
|
+
|
|
10
|
+
## Implementation
|
|
11
|
+
|
|
12
|
+
> ℹ️ **Info:**
|
|
13
|
+
> See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { xPixel } from '@c15t/scripts/x-pixel';
|
|
17
|
+
|
|
18
|
+
xPixel({
|
|
19
|
+
id: '123456789012345',
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## xPixelEvent
|
|
24
|
+
|
|
25
|
+
You can use the `xPixelEvent` function to track events. This is a wrapper around the `twq` function that the X Pixel script uses.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { xPixelEvent } from '@c15t/scripts/x-pixel';
|
|
29
|
+
|
|
30
|
+
xPixelEvent('tw-xxxx-xxxx', { value: 10.00, currency: 'USD' });
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Types
|
|
34
|
+
|
|
35
|
+
### XPixelOptions
|
|
36
|
+
|
|
37
|
+
|Property|Type|Description|Default|Required|
|
|
38
|
+
|:--|:--|:--|:--|:--:|
|
|
39
|
+
|pixelId|string|Your X Pixel ID|-|✅ Required|
|
|
40
|
+
|scriptSrc|string \|undefined|X Pixel loader URL.|-|Optional|
|
|
41
|
+
|
|
42
|
+
### Script
|
|
43
|
+
|
|
44
|
+
|Property|Type|Description|Default|Required|
|
|
45
|
+
|:--|:--|:--|:--|:--:|
|
|
46
|
+
|id|string|Unique identifier for the script|-|✅ Required|
|
|
47
|
+
|src|string \|undefined|URL of the script to load|-|Optional|
|
|
48
|
+
|textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
|
|
49
|
+
|category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
|
|
50
|
+
|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|
|
|
51
|
+
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
|
|
52
|
+
|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|
|
|
53
|
+
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
54
|
+
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
55
|
+
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
56
|
+
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
57
|
+
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
58
|
+
|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|
|
|
59
|
+
|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|
|
|
60
|
+
|onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
61
|
+
|onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
62
|
+
|onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
63
|
+
|onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
64
|
+
|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|
|
|
65
|
+
|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|
|
|
66
|
+
|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|
|
|
67
|
+
|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|
|
|
68
|
+
|
|
69
|
+
#### `onBeforeLoad`
|
|
70
|
+
|
|
71
|
+
Callback executed before the script is loaded
|
|
72
|
+
|
|
73
|
+
|Property|Type|Description|Default|Required|
|
|
74
|
+
|:--|:--|:--|:--|:--:|
|
|
75
|
+
|id|string|The original script ID|-|✅ Required|
|
|
76
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
77
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
78
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
79
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
80
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
81
|
+
|
|
82
|
+
#### `onLoad`
|
|
83
|
+
|
|
84
|
+
Callback executed when the script loads successfully
|
|
85
|
+
|
|
86
|
+
|Property|Type|Description|Default|Required|
|
|
87
|
+
|:--|:--|:--|:--|:--:|
|
|
88
|
+
|id|string|The original script ID|-|✅ Required|
|
|
89
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
90
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
91
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
92
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
93
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
94
|
+
|
|
95
|
+
#### `onError`
|
|
96
|
+
|
|
97
|
+
Callback executed if the script fails to load
|
|
98
|
+
|
|
99
|
+
|Property|Type|Description|Default|Required|
|
|
100
|
+
|:--|:--|:--|:--|:--:|
|
|
101
|
+
|id|string|The original script ID|-|✅ Required|
|
|
102
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
103
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
104
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
105
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
106
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
107
|
+
|
|
108
|
+
#### `onConsentChange`
|
|
109
|
+
|
|
110
|
+
Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
|
|
111
|
+
|
|
112
|
+
|Property|Type|Description|Default|Required|
|
|
113
|
+
|:--|:--|:--|:--|:--:|
|
|
114
|
+
|id|string|The original script ID|-|✅ Required|
|
|
115
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
116
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
117
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
118
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
119
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
120
|
+
|
|
121
|
+
### XPixelEvent
|
|
122
|
+
|
|
123
|
+
|Property|Type|Description|Default|Required|
|
|
124
|
+
|:--|:--|:--|:--|:--:|
|
|
125
|
+
|value|number \|undefined|Total value of the conversion event (ex: $ value of the transaction in case of a purchase, etc.)|-|Optional|
|
|
126
|
+
|currency|string \|undefined|Currency of the conversion event ISO 4217 code (ex: USD, EUR, JPY, etc.)|-|Optional|
|
|
127
|
+
|conversion\_id|string \|undefined|Unique identifier for the event that can be used for deduplication purposes|-|Optional|
|
|
128
|
+
|search\_string|string \|undefined|Search string of the conversion event|-|Optional|
|
|
129
|
+
|description|string \|undefined|Description of the conversion event|-|Optional|
|
|
130
|
+
|twclid|string \|undefined|twclid of the conversion event The X Pixel already automatically passes twclid from URL or first-party cookie. This parameter can be optionally used to force attribution to a certain ad click.|-|Optional|
|
|
131
|
+
|status|boolean \|undefined|Status of the conversion event|-|Optional|
|
|
132
|
+
|contents|XPixelContent \|undefined|Content/products associated with the conversion event|-|Optional|
|
|
133
|
+
|
|
134
|
+
### XPixelContent
|
|
135
|
+
|
|
136
|
+
|Property|Type|Description|Default|Required|
|
|
137
|
+
|:--|:--|:--|:--|:--:|
|
|
138
|
+
|content\_type|[string \|undefined](https://www.google.com/basepages/producttype/taxonomy.en-US.txt)|Type of the content|-|Optional|
|
|
139
|
+
|content\_id|string|ID of the content For product catalog users: please pass SKU For all other users: Please pass Global Trade Item Number (GTIN) if available, otherwise pass SKU|-|✅ Required|
|
|
140
|
+
|content\_name|string \|undefined|Name of a product or service|-|Optional|
|
|
141
|
+
|content\_price|number \|undefined|Price of a product or service|-|Optional|
|
|
142
|
+
|num\_items|number \|undefined|Quantity of the content|-|Optional|
|
|
143
|
+
|content\_group\_id|string \|undefined|ID associated with a group of product variants|-|Optional|
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Internationalization
|
|
3
|
+
description: Translate consent UI into 30+ languages with built-in translations, custom overrides, and automatic browser language detection.
|
|
4
|
+
---
|
|
5
|
+
c15t ships with built-in translations for 30+ languages via the `@c15t/translations` package. Language detection happens automatically based on the browser's language preference, and you can override or extend translations for any language.
|
|
6
|
+
|
|
7
|
+
In c15t v2, the preferred config shape is `i18n` with `locale`, `detectBrowserLanguage`, and `messages`.
|
|
8
|
+
|
|
9
|
+
There are two ways c15t can load translations: client-side or server-side.
|
|
10
|
+
|
|
11
|
+
|Server-side|Client-side|
|
|
12
|
+
|--|--|
|
|
13
|
+
|The best way to reduce bundle size and improve performance. We can detect the user's language based on the browser's language settings, allowing for the most accurate translations. By default, when using a [inth.com](https://inth.com) hosted instance, [these languages](https://github.com/c15t/c15t/tree/main/packages/translations/src/translations) are supported.|Bundled with the application allowing for multiple languages to be supported without the need for a backend. The more translations you have, the larger the bundle size will be, which may impact the performance of your application.|
|
|
14
|
+
|
|
15
|
+
## Basic Configuration
|
|
16
|
+
|
|
17
|
+
Pass custom translations via the `i18n` option:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { type ReactNode } from 'react';
|
|
21
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
22
|
+
|
|
23
|
+
export default function ConsentManager({ children }: { children: ReactNode }) {
|
|
24
|
+
return (
|
|
25
|
+
<ConsentManagerProvider
|
|
26
|
+
options={{
|
|
27
|
+
mode: 'hosted',
|
|
28
|
+
backendURL: '/api/c15t',
|
|
29
|
+
i18n: {
|
|
30
|
+
locale: 'en',
|
|
31
|
+
messages: {
|
|
32
|
+
de: {
|
|
33
|
+
cookieBanner: {
|
|
34
|
+
title: 'Datenschutzeinstellungen',
|
|
35
|
+
description: 'Wir verwenden Cookies, um Ihnen das beste Erlebnis zu bieten.',
|
|
36
|
+
},
|
|
37
|
+
common: {
|
|
38
|
+
acceptAll: 'Alle akzeptieren',
|
|
39
|
+
rejectAll: 'Alle ablehnen',
|
|
40
|
+
customize: 'Anpassen',
|
|
41
|
+
save: 'Speichern',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</ConsentManagerProvider>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Custom translations are deep-merged with built-in defaults - you only need to override the keys you want to change.
|
|
55
|
+
|
|
56
|
+
## Translation Package Imports
|
|
57
|
+
|
|
58
|
+
Use the import path that matches your use case:
|
|
59
|
+
|
|
60
|
+
* `@c15t/translations`: types, utilities, and `enTranslations` only (smallest client bundle)
|
|
61
|
+
* `@c15t/translations/en`: English-only translation object
|
|
62
|
+
* `@c15t/translations/all`: full `baseTranslations` map for all bundled locales
|
|
63
|
+
|
|
64
|
+
If you bundle translations client-side and need multiple languages, import from `@c15t/translations/all` explicitly:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { baseTranslations } from '@c15t/translations/all';
|
|
68
|
+
|
|
69
|
+
const translations = {
|
|
70
|
+
en: baseTranslations.en,
|
|
71
|
+
de: baseTranslations.de,
|
|
72
|
+
fr: baseTranslations.fr,
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Translation Sections
|
|
77
|
+
|
|
78
|
+
The `Translations` object is organized into sections:
|
|
79
|
+
|
|
80
|
+
|Section|Controls|
|
|
81
|
+
|--|--|
|
|
82
|
+
|`common`|Shared button labels: acceptAll, rejectAll, customize, save|
|
|
83
|
+
|`cookieBanner`|Banner title and description|
|
|
84
|
+
|`consentManagerDialog`|Dialog title and description|
|
|
85
|
+
|`consentTypes`|Per-category title and description (keyed by AllConsentNames)|
|
|
86
|
+
|`frame`|Frame placeholder title and button text (supports `{category}` placeholder)|
|
|
87
|
+
|`legalLinks`|Privacy policy, cookie policy, terms of service link text|
|
|
88
|
+
|`iab`|IAB TCF banner, preference center, vendor list translations|
|
|
89
|
+
|
|
90
|
+
## Reading Translations
|
|
91
|
+
|
|
92
|
+
Use the `useTranslations()` hook to access the current language's translations:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { useTranslations } from '@c15t/nextjs';
|
|
96
|
+
|
|
97
|
+
function CustomBanner() {
|
|
98
|
+
const translations = useTranslations();
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div>
|
|
102
|
+
<h2>{translations.cookieBanner.title}</h2>
|
|
103
|
+
<p>{translations.cookieBanner.description}</p>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Changing Language
|
|
110
|
+
|
|
111
|
+
Switch the active language at runtime with `setLanguage()`:
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { useConsentManager } from '@c15t/nextjs';
|
|
115
|
+
|
|
116
|
+
function LanguageSwitcher() {
|
|
117
|
+
const { setLanguage } = useConsentManager();
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<select onChange={(e) => setLanguage(e.target.value)}>
|
|
121
|
+
<option value="en">English</option>
|
|
122
|
+
<option value="de">Deutsch</option>
|
|
123
|
+
<option value="fr">Français</option>
|
|
124
|
+
<option value="es">Español</option>
|
|
125
|
+
</select>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`setLanguage()` re-fetches the consent banner to get server-resolved translations for the new language.
|
|
131
|
+
|
|
132
|
+
## Automatic Language Detection
|
|
133
|
+
|
|
134
|
+
By default, c15t detects the browser's language (`navigator.language`) and selects the closest matching translation. If custom `messages` are configured, fallback stays within your configured languages before using `locale` (or `'en'`) as the preferred fallback language.
|
|
135
|
+
|
|
136
|
+
When backend policy packs use `i18n.messageProfile`, the active language pool comes only from that resolved profile.
|
|
137
|
+
|
|
138
|
+
Example: if your Europe profile defines `en`, `fr`, and `de`, and your default profile defines `en`, `es`, and `pt`, a Europe visitor can resolve to `en`, `fr`, or `de`, but not `es`, `pt`, or `zh`.
|
|
139
|
+
|
|
140
|
+
Use profile-local `fallbackLanguage` inside backend `i18n.messages` to choose which configured language a policy profile should fall back to when the browser asks for an unsupported locale.
|
|
141
|
+
|
|
142
|
+
Disable auto-detection to always use `locale`:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
i18n: {
|
|
146
|
+
locale: 'de',
|
|
147
|
+
detectBrowserLanguage: false,
|
|
148
|
+
messages: { ... },
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
If you need a policy to always use one specific language regardless of browser preference, set `policy.i18n.language` on the backend policy pack.
|
|
153
|
+
|
|
154
|
+
## Custom Consent Type Labels
|
|
155
|
+
|
|
156
|
+
Override the title and description for individual consent categories:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
i18n: {
|
|
160
|
+
messages: {
|
|
161
|
+
en: {
|
|
162
|
+
consentTypes: {
|
|
163
|
+
measurement: {
|
|
164
|
+
title: 'Analytics & Performance',
|
|
165
|
+
description: 'Help us understand how visitors interact with our site.',
|
|
166
|
+
},
|
|
167
|
+
marketing: {
|
|
168
|
+
title: 'Advertising',
|
|
169
|
+
description: 'Used to deliver relevant ads and measure campaign effectiveness.',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Legacy `translations` Compatibility
|
|
178
|
+
|
|
179
|
+
The legacy syntax is still supported in 2.0 for RC compatibility:
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
// Legacy (still supported)
|
|
183
|
+
translations: {
|
|
184
|
+
defaultLanguage: 'en',
|
|
185
|
+
disableAutoLanguageSwitch: true,
|
|
186
|
+
translations: { ... },
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Preferred in v2
|
|
190
|
+
i18n: {
|
|
191
|
+
locale: 'en',
|
|
192
|
+
detectBrowserLanguage: false,
|
|
193
|
+
messages: { ... },
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
If both are provided, `i18n` takes precedence.
|