@c15t/nextjs 2.0.0-rc.7 → 2.0.0-rc.8

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.
Files changed (55) hide show
  1. package/README.md +7 -0
  2. package/dist/iab/styles.css +12 -1
  3. package/dist/iab/styles.tw3.css +14 -1
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/styles.css +10 -1
  7. package/dist/styles.tw3.css +13 -1
  8. package/dist/version.cjs +1 -1
  9. package/dist/version.js +1 -1
  10. package/dist-types/headless.d.ts +1 -1
  11. package/dist-types/index.d.ts +2 -2
  12. package/dist-types/libs/browser-initial-data.d.ts +2 -2
  13. package/dist-types/libs/initial-data.d.ts +1 -1
  14. package/dist-types/types.d.ts +3 -3
  15. package/dist-types/version.d.ts +1 -1
  16. package/docs/building-headless-components.md +40 -22
  17. package/docs/callbacks.md +76 -9
  18. package/docs/components/consent-banner.md +83 -9
  19. package/docs/components/consent-dialog.md +12 -2
  20. package/docs/components/consent-manager-provider.md +3 -1
  21. package/docs/components/consent-widget.md +61 -8
  22. package/docs/concepts/client-modes.md +16 -4
  23. package/docs/concepts/initialization-flow.md +9 -2
  24. package/docs/concepts/policy-packs.md +2 -2
  25. package/docs/hooks/use-consent-manager/overview.md +17 -3
  26. package/docs/hooks/use-ssr-status.md +1 -1
  27. package/docs/hooks/use-translations.md +1 -0
  28. package/docs/iab/consent-banner.md +2 -5
  29. package/docs/iab/consent-dialog.md +3 -6
  30. package/docs/iab/overview.md +11 -5
  31. package/docs/integrations/building-integrations.md +405 -0
  32. package/docs/integrations/databuddy.md +22 -5
  33. package/docs/integrations/google-tag-manager.md +2 -2
  34. package/docs/integrations/google-tag.md +2 -29
  35. package/docs/integrations/linkedin-insights.md +1 -1
  36. package/docs/integrations/meta-pixel.md +1 -1
  37. package/docs/integrations/microsoft-uet.md +1 -1
  38. package/docs/integrations/overview.md +18 -2
  39. package/docs/integrations/posthog.md +39 -17
  40. package/docs/integrations/tiktok-pixel.md +1 -1
  41. package/docs/integrations/x-pixel.md +1 -1
  42. package/docs/optimization.md +68 -9
  43. package/docs/policy-packs.md +7 -7
  44. package/docs/quickstart.md +11 -5
  45. package/docs/script-loader.md +22 -1
  46. package/docs/server-side.md +1 -1
  47. package/docs/styling/tailwind.md +23 -17
  48. package/iab/styles.css +1 -0
  49. package/package.json +10 -8
  50. package/readme.json +4 -0
  51. package/src/iab/styles.css +6 -4
  52. package/src/iab/styles.tw3.css +8 -4
  53. package/src/styles.css +3 -3
  54. package/src/styles.tw3.css +7 -4
  55. package/styles.css +1 -0
@@ -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
- options: {
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 `options` parameter allows you to customize Databuddy's behavior:
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
- options: {
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
- |options|Record\<string, unknown> \|undefined|Additional configuration options for Databuddy.|-|Optional|
107
- |script|Script \|undefined|Override or extend the default script values. Options: \`id\`: 'databuddy'; \`category\`: 'measurement'|-|Optional|
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|Update Event Name A custom event name used as a trigger to load your script once the consent has been updated.|'consent-update'|Optional|
74
- |script|Script \|undefined|Override or extend the default script values.|-|Optional|
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
- |script|Object \|undefined|Override or extend the default script values. Options: \`id\`: 'gtag'; \`src\`: \`https\://www\.googletagmanager.com/gtag/js?id=$\{id}\`; \`async\`: true; \`alwaysLoad\`: true|-|Optional|
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
 
@@ -27,7 +27,7 @@ linkedinInsights({
27
27
  |Property|Type|Description|Default|Required|
28
28
  |:--|:--|:--|:--|:--:|
29
29
  |id|string|Your LinkedIn Insights ID|-|✅ Required|
30
- |script|Script \|undefined|Override or extend the default script values. Options: \`id\`: 'linkedin-insights'; \`src\`: \`https\://snap.licdn.com/li.lms-analytics/insight.min.js\`; \`category\`: 'marketing'|-|Optional|
30
+ |scriptSrc|string \|undefined|LinkedIn Insights loader URL.|-|Optional|
31
31
 
32
32
  ### Script
33
33
 
@@ -41,7 +41,7 @@ metaPixelEvent('Purchase', { value: 10.0, currency: 'USD' });
41
41
  |Property|Type|Description|Default|Required|
42
42
  |:--|:--|:--|:--|:--:|
43
43
  |pixelId|string|Your Meta Pixel ID|-|✅ Required|
44
- |script|Script \|undefined|Override or extend the default script values. Options: \`id\`: 'meta-pixel'; \`src\`: \`https\://connect.facebook.net/en\_US/fbevents.js\`; \`category\`: 'marketing'|-|Optional|
44
+ |scriptSrc|string \|undefined|Meta Pixel loader URL.|-|Optional|
45
45
 
46
46
  ### Script
47
47
 
@@ -30,7 +30,7 @@ microsoftUet({
30
30
  |Property|Type|Description|Default|Required|
31
31
  |:--|:--|:--|:--|:--:|
32
32
  |id|string|Your Microsoft UET ID|-|✅ Required|
33
- |script|Script \|undefined|Override or extend the default script values. Options: \`id\`: 'microsoft-uet'; \`src\`: \`//bat.bing.com/bat.js\`; \`category\`: 'marketing'|-|Optional|
33
+ |scriptSrc|string \|undefined|Microsoft UET loader URL.|-|Optional|
34
34
 
35
35
  ### Script
36
36
 
@@ -1,9 +1,16 @@
1
1
  ---
2
2
  title: Integrations
3
3
  description: "Many of your tools may require consent to be given before they can be used. This is especially true for analytics and marketing tools. \nc15t has various ways to integrate with your tools, depending on the tool you are using."
4
- lastModified: 2025-10-02
4
+ lastModified: 2026-04-10
5
5
 
6
6
  ---
7
+ c15t supports two integration styles:
8
+
9
+ * use a prebuilt helper from `@c15t/scripts`
10
+ * build your own script or manifest-backed helper
11
+
12
+ If you are building something reusable or contributing to `@c15t/scripts`, start with the [custom integration guide](/docs/integrations/building-integrations).
13
+
7
14
  ## General Pattern
8
15
 
9
16
  Every integration provides a script configuration function. Pass it to your framework's setup:
@@ -68,12 +75,21 @@ export function App({ children }: { children: React.ReactNode }) {
68
75
 
69
76
  Many marketing and analytics tools are commonly loaded using a script tag, such as Google Tag Manager (GTM), Google Tag (gtag.js), Meta Pixel and TikTok Pixel.
70
77
 
71
- c15t's script loader allows you to easily integrate your tools that require consent with c15t, to make this even easier we have provided a set of prebuilt scripts for you to use.
78
+ c15t's script loader allows you to easily integrate your tools that require consent with c15t. The prebuilt integrations in `@c15t/scripts` are the recommended starting point, and the custom integration guide explains how to build your own when you need something more specialized.
72
79
 
73
80
  * [JavaScript](/docs/frameworks/javascript/script-loader)
74
81
  * [React](/docs/frameworks/react/script-loader)
75
82
  * [Next.js](/docs/frameworks/next/script-loader)
76
83
 
84
+ ## Building Your Own
85
+
86
+ If you need a vendor we do not ship yet:
87
+
88
+ * build a one-off `Script` directly in your app for simple cases
89
+ * build a reusable manifest-backed helper for shared or package-level integrations
90
+
91
+ Read the [custom integration guide](/docs/integrations/building-integrations) for the manifest phases, structured step model, testing checklist, and devtools debugging flow.
92
+
77
93
  ## has() method
78
94
 
79
95
  The `has()` method allows you to check if the user has given consent for a specific purpose. You can learn more about the `has()` method [here](/docs/frameworks/javascript/store/checking-consent).