@c15t/react 3.1.0 → 3.2.0

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 (146) hide show
  1. package/AGENTS.md +35 -5
  2. package/README.md +2 -2
  3. package/dist/component-hooks/use-consent-gate.js +2 -0
  4. package/dist/component-hooks/use-consent-labels.js +2 -0
  5. package/dist/component-hooks/use-consent-text-direction.js +2 -0
  6. package/dist/component-hooks/use-vendors-listed-under.js +2 -0
  7. package/dist/components/consent-gate/atoms.js +1 -1
  8. package/dist/components/consent-gate/consent-gate.js +1 -1
  9. package/dist/components/iab-prompt/atoms/root.js +1 -1
  10. package/dist/components/panel-trigger/atoms/toolbar.js +1 -1
  11. package/dist/components/preferences/atoms/button.js +1 -1
  12. package/dist/components/preferences/atoms/vendor-list.js +1 -1
  13. package/dist/components/prompt/atoms/root.js +1 -1
  14. package/dist/components/prompt/components.js +1 -1
  15. package/dist/components/prompt/policy-actions.js +1 -1
  16. package/dist/components/prompt/prompt.js +1 -1
  17. package/dist/components/prompt/surface-context.js +1 -1
  18. package/dist/components/prompt/use-banner-copy.js +1 -1
  19. package/dist/components/shared/streamed-surface.js +1 -1
  20. package/dist/headless.js +1 -1
  21. package/dist/index-parts/offline.js +1 -1
  22. package/dist/modes.js +1 -1
  23. package/dist/styles.tw3.css +2 -2
  24. package/dist/transports/offline.js +1 -1
  25. package/dist/version.js +1 -1
  26. package/dist-types/component-hooks/use-consent-gate.d.ts +102 -0
  27. package/dist-types/component-hooks/use-consent-labels.d.ts +32 -0
  28. package/dist-types/component-hooks/use-consent-text-direction.d.ts +22 -0
  29. package/dist-types/component-hooks/use-vendors-listed-under.d.ts +30 -0
  30. package/dist-types/components/prompt/atoms/root.d.ts +3 -3
  31. package/dist-types/components/prompt/prompt.d.ts +4 -3
  32. package/dist-types/components/prompt/surface-context.d.ts +1 -14
  33. package/dist-types/components/prompt/use-banner-copy.d.ts +8 -3
  34. package/dist-types/components/shared/streamed-surface.d.ts +47 -10
  35. package/dist-types/headless.d.ts +10 -1
  36. package/dist-types/hooks/use-iab-policy-guard.d.ts +17 -1
  37. package/dist-types/hooks/use-scroll-lock.d.ts +16 -2
  38. package/dist-types/index-parts/offline.d.ts +1 -1
  39. package/dist-types/modes.d.ts +1 -1
  40. package/dist-types/module-hooks/script-loader.d.ts +9 -0
  41. package/dist-types/provider.d.ts +3 -3
  42. package/dist-types/transports/offline.d.ts +2 -2
  43. package/dist-types/version.d.ts +1 -1
  44. package/docs/README.md +35 -5
  45. package/docs/concepts/choose-your-setup.md +9 -9
  46. package/docs/concepts/consent-state.md +81 -9
  47. package/docs/concepts/data-fetching.md +30 -23
  48. package/docs/concepts/modes.md +87 -35
  49. package/docs/customization/recipes.md +4 -4
  50. package/docs/customization/stylesheets.md +42 -3
  51. package/docs/customization/tailwind.md +17 -34
  52. package/docs/customization/translations.md +18 -12
  53. package/docs/frameworks/react/clear-on-revocation.md +3 -2
  54. package/docs/frameworks/react/components/consent-banner.md +3 -3
  55. package/docs/frameworks/react/components/consent-provider.md +29 -29
  56. package/docs/frameworks/react/gpp.md +1 -1
  57. package/docs/frameworks/react/headless.md +146 -19
  58. package/docs/frameworks/react/hooks.md +2 -1
  59. package/docs/frameworks/react/iab.md +8 -1
  60. package/docs/frameworks/react/quickstart.md +2 -2
  61. package/docs/frameworks/react/rendering.md +1 -1
  62. package/docs/frameworks/react/translations.md +9 -9
  63. package/docs/frameworks/react/troubleshooting.md +1 -1
  64. package/docs/frameworks/react/upgrade-v3.md +39 -32
  65. package/docs/frameworks/react/vendor-consent.md +5 -0
  66. package/docs/guides/banner-experiments.md +3 -3
  67. package/docs/guides/troubleshooting.md +3 -2
  68. package/docs/integrations/activecampaign.md +297 -0
  69. package/docs/integrations/ada.md +396 -0
  70. package/docs/integrations/adobe-analytics.md +2 -2
  71. package/docs/integrations/adobe-target.md +460 -0
  72. package/docs/integrations/adroll.md +336 -0
  73. package/docs/integrations/ahrefs-analytics.md +2 -2
  74. package/docs/integrations/amazon-ads.md +424 -0
  75. package/docs/integrations/amplitude.md +2 -2
  76. package/docs/integrations/appcues.md +368 -0
  77. package/docs/integrations/attentive.md +313 -0
  78. package/docs/integrations/building-integrations.md +29 -16
  79. package/docs/integrations/clay.md +305 -0
  80. package/docs/integrations/clearbit.md +3 -3
  81. package/docs/integrations/cloudflare-web-analytics.md +2 -2
  82. package/docs/integrations/cloudflare-zaraz.md +2 -2
  83. package/docs/integrations/crisp.md +2 -2
  84. package/docs/integrations/customer-io.md +369 -0
  85. package/docs/integrations/databuddy.md +127 -52
  86. package/docs/integrations/default-com.md +497 -0
  87. package/docs/integrations/dynamic-yield.md +373 -0
  88. package/docs/integrations/fathom-analytics.md +2 -2
  89. package/docs/integrations/front-chat.md +2 -2
  90. package/docs/integrations/fullstory.md +298 -0
  91. package/docs/integrations/gainsight-px.md +418 -0
  92. package/docs/integrations/google-maps.md +2 -2
  93. package/docs/integrations/google-tag-manager.md +59 -2
  94. package/docs/integrations/google-tag.md +2 -2
  95. package/docs/integrations/gorgias.md +365 -0
  96. package/docs/integrations/heap.md +2 -2
  97. package/docs/integrations/hightouch.md +2 -2
  98. package/docs/integrations/hotjar.md +40 -26
  99. package/docs/integrations/hubspot.md +529 -0
  100. package/docs/integrations/insider.md +550 -0
  101. package/docs/integrations/intercom.md +2 -2
  102. package/docs/integrations/klaviyo.md +2 -2
  103. package/docs/integrations/linkedin-insights.md +2 -2
  104. package/docs/integrations/liveintent.md +327 -0
  105. package/docs/integrations/logrocket.md +2 -2
  106. package/docs/integrations/lucky-orange.md +336 -0
  107. package/docs/integrations/marketo.md +309 -0
  108. package/docs/integrations/matomo-analytics.md +2 -2
  109. package/docs/integrations/meta-pixel.md +2 -2
  110. package/docs/integrations/microsoft-clarity.md +2 -2
  111. package/docs/integrations/microsoft-uet.md +2 -2
  112. package/docs/integrations/mixpanel-analytics.md +2 -2
  113. package/docs/integrations/one-dollar-stats.md +2 -2
  114. package/docs/integrations/openai-pixel.md +2 -2
  115. package/docs/integrations/optimizely.md +411 -0
  116. package/docs/integrations/oracle-eloqua.md +301 -0
  117. package/docs/integrations/overview.md +128 -81
  118. package/docs/integrations/pendo.md +339 -0
  119. package/docs/integrations/pinterest-tag.md +2 -2
  120. package/docs/integrations/pirsch.md +2 -2
  121. package/docs/integrations/plausible-analytics.md +2 -2
  122. package/docs/integrations/posthog.md +2 -2
  123. package/docs/integrations/promptwatch.md +2 -2
  124. package/docs/integrations/rb2b.md +363 -0
  125. package/docs/integrations/reddit-pixel.md +2 -2
  126. package/docs/integrations/rudderstack.md +2 -2
  127. package/docs/integrations/rybbit-analytics.md +2 -2
  128. package/docs/integrations/salesforce-pardot.md +342 -0
  129. package/docs/integrations/segment.md +2 -2
  130. package/docs/integrations/sentry.md +2 -2
  131. package/docs/integrations/shopify.md +323 -0
  132. package/docs/integrations/snapchat-pixel.md +2 -2
  133. package/docs/integrations/statable-analytics.md +345 -0
  134. package/docs/integrations/the-trade-desk.md +328 -0
  135. package/docs/integrations/tiktok-pixel.md +2 -2
  136. package/docs/integrations/umami-analytics.md +2 -2
  137. package/docs/integrations/vector.md +333 -0
  138. package/docs/integrations/vercel-analytics.md +2 -2
  139. package/docs/integrations/vercel-speed-insights.md +7 -2
  140. package/docs/integrations/wisepops.md +416 -0
  141. package/docs/integrations/x-pixel.md +2 -2
  142. package/docs/integrations/youtube.md +2 -2
  143. package/docs/integrations/zendesk.md +359 -0
  144. package/package.json +10 -32
  145. package/dist/components/prompt/resolve-banner-primary-actions.js +0 -1
  146. package/dist-types/components/prompt/resolve-banner-primary-actions.d.ts +0 -14
@@ -0,0 +1,369 @@
1
+ ---
2
+ title: Customer.io
3
+ description: Load Customer.io Data Pipelines only after marketing consent with
4
+ the c15t customerIo helper, set up a proxy, and check withdrawal.
5
+ seoTitle: Customer.io cookie consent with c15t
6
+ seoDescription: Load Customer.io only with marketing consent. Set your write
7
+ key, region and proxy, and reset identity on withdrawal with c15t.
8
+ icon: chart-line
9
+ group: integrations
10
+ ---
11
+
12
+ Customer.io collects events and visitor identity on your site through its
13
+ Data Pipelines JavaScript source, for use in its messaging. The c15t
14
+ `customerIo` helper waits for `marketing` consent before it creates the
15
+ `cioanalytics` global or downloads the SDK.
16
+
17
+ When the visitor withdraws, the helper calls `cioanalytics.reset()` to clear
18
+ the stored identity, and c15t reloads the page. `reset()` is not an opt-out.
19
+ The reload is what stops the SDK.
20
+
21
+ ## Configure Customer.io
22
+
23
+ Create a JavaScript source in Customer.io Data Pipelines and copy its write
24
+ key. Note the region of your workspace. Then remove the original Customer.io
25
+ snippet from your site, so that c15t controls when it loads.
26
+
27
+ | Package manager | Command |
28
+ | :-------------- | :------------------------------- |
29
+ | npm | `npm install @c15t/integrations` |
30
+ | pnpm | `pnpm add @c15t/integrations` |
31
+ | yarn | `yarn add @c15t/integrations` |
32
+ | bun | `bun add @c15t/integrations` |
33
+
34
+ ```ts title="src/consent-scripts.ts"
35
+ import { customerIo } from '@c15t/integrations/customer-io';
36
+
37
+ export const scripts = [customerIo({ writeKey: 'YOUR_WRITE_KEY' })];
38
+ ```
39
+
40
+ ## Register the scripts
41
+
42
+ Complete your [framework quickstart](https://c15t.com/docs/frameworks) first. Keep its Inth
43
+ endpoint, policy, styles and consent UI. Remove the vendor's original script,
44
+ SDK initializer or tag-manager entry, so the vendor loads only through c15t.
45
+
46
+ The vendor pages put the helper in `src/consent-scripts.ts`. If your framework
47
+ quickstart already has a `scripts` array, such as the one in `c15t.config.ts`
48
+ in the Next.js guide, add the helper to that array instead of creating a
49
+ second file.
50
+ The `scripts` export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration
51
+ point for your framework below. These are edits to that provider, not a second
52
+ provider.
53
+
54
+ **Next.js**
55
+
56
+ Add the configuration to `scripts` in `c15t.config.ts`, next to
57
+ `next.config.ts`:
58
+
59
+ ```ts title="c15t.config.ts"
60
+ import { defineConsentConfig } from 'c15t/next';
61
+ import { scripts } from './src/consent-scripts';
62
+
63
+ export default defineConsentConfig({ scripts });
64
+ ```
65
+
66
+ Keep the rest of your config, such as `mode` and `routePrefix`, in the
67
+ same call. `ConsentRoot` reads the config in the browser, so the layout
68
+ keeps passing only `state`. App Router, Pages Router and static export all
69
+ read the same file. See
70
+ [Next.js scripts and embeds](https://c15t.com/docs/frameworks/next/scripts).
71
+
72
+ **TanStack Start**
73
+
74
+ Import the configuration into your root route and pass it to the existing
75
+ `ConsentRoot` as a top-level prop. Keep the loader from the
76
+ [TanStack Start quickstart](https://c15t.com/docs/frameworks/tanstack-start/quickstart):
77
+
78
+ ```tsx title="src/routes/__root.tsx"
79
+ import { scripts } from '../consent-scripts';
80
+
81
+ <ConsentRoot state={consent} scripts={scripts}>
82
+ ```
83
+
84
+ Import vendor helpers in the root route module, not in a server function.
85
+ A server function's return value must be serializable, and script
86
+ configurations carry callbacks. See
87
+ [TanStack Start scripts](https://c15t.com/docs/frameworks/tanstack-start/scripts).
88
+
89
+ **React**
90
+
91
+ Add the configuration to the existing `ConsentProvider` options, next to
92
+ `mode`:
93
+
94
+ ```tsx title="src/consent.tsx"
95
+ import { scripts } from './consent-scripts';
96
+
97
+ <ConsentProvider options={{ mode, scripts }}>
98
+ ```
99
+
100
+ `mode` is the `manifest()` value from the
101
+ [React quickstart](../frameworks/react/quickstart.md). Keep the banner,
102
+ dialog and preferences link inside the provider. See
103
+ [React scripts and embeds](../frameworks/react/scripts.md).
104
+
105
+ **Nuxt**
106
+
107
+ Register the scripts under the `c15t` key in `app/app.config.ts`. Adjust the
108
+ relative import to where you created `consent-scripts.ts`:
109
+
110
+ ```ts title="app/app.config.ts"
111
+ import { scripts } from '../src/consent-scripts';
112
+
113
+ export default defineAppConfig({
114
+ c15t: { scripts },
115
+ });
116
+ ```
117
+
118
+ The Nuxt module merges this over its options in `nuxt.config.ts` and starts
119
+ one script loader in the browser after hydration, once it has applied the
120
+ visitor's stored choice and privacy signals. Keep `scripts` out of
121
+ `nuxt.config.ts`, which reaches the browser as JSON and drops the vendor
122
+ callbacks. Write the vendor IDs into `consent-scripts.ts`. See
123
+ [Nuxt scripts and embeds](https://c15t.com/docs/frameworks/nuxt/scripts).
124
+
125
+ **Vue**
126
+
127
+ Pass the scripts to the existing `c15tVue` plugin call in `src/main.ts`:
128
+
129
+ ```ts title="src/main.ts"
130
+ import { c15tVue, manifest } from 'c15t/vue/vue-plugin';
131
+ import { scripts } from './consent-scripts';
132
+
133
+ app.use(c15tVue, {
134
+ mode: manifest(),
135
+ scripts,
136
+ });
137
+ ```
138
+
139
+ Keep your existing `mode` and other options. The plugin starts one
140
+ script loader when the app mounts, after it has applied the visitor's stored
141
+ choice. Do not also call `createScriptLoader` from a component. See
142
+ [Vue scripts and embeds](https://c15t.com/docs/frameworks/vue/scripts).
143
+
144
+ **Astro**
145
+
146
+ Add the scripts to the client entrypoint from the
147
+ [Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart), `src/c15t.client.ts`,
148
+ which the integration finds on its own. Keep `astro.config.mjs` as it is.
149
+ If the module already exports scripts, combine the two arrays.
150
+
151
+ ```ts title="src/c15t.client.ts"
152
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
153
+ import { scripts } from './consent-scripts';
154
+
155
+ export default { scripts } satisfies C15tClientOptionsExtension;
156
+ ```
157
+
158
+ Vendor helpers contain callbacks, and the integration options in
159
+ `astro.config.mjs` are serialized into the page, so do not put helpers in
160
+ the integration's `scripts` option. The integration passes the client
161
+ entrypoint to the one runtime every page shares, including across
162
+ `ClientRouter` navigation.
163
+
164
+ **Svelte**
165
+
166
+ Import the scripts in the component that owns your existing provider and
167
+ pass them as a top-level prop:
168
+
169
+ ```svelte title="src/App.svelte"
170
+ <script lang="ts">
171
+ import { ConsentProvider, manifest } from 'c15t/svelte';
172
+ import { scripts } from './consent-scripts';
173
+ </script>
174
+
175
+ <ConsentProvider mode={manifest()} {scripts}>
176
+ <!-- Keep your application, consent UI and preferences link here. -->
177
+ </ConsentProvider>
178
+ ```
179
+
180
+ Retain the styles and consent UI from the [Svelte quickstart](https://c15t.com/docs/frameworks/svelte/quickstart).
181
+ The provider owns the loader and disposes it on unmount.
182
+
183
+ **SvelteKit**
184
+
185
+ Add the scripts to the existing `ConsentRoot` in the root layout. Keep the
186
+ handle and the layout load from the [SvelteKit quickstart](https://c15t.com/docs/frameworks/sveltekit/quickstart).
187
+
188
+ ```svelte title="src/routes/+layout.svelte"
189
+ <script lang="ts">
190
+ import { ConsentRoot } from 'c15t/svelte';
191
+ import { scripts } from '../consent-scripts';
192
+
193
+ let { children, data } = $props();
194
+ </script>
195
+
196
+ <ConsentRoot state={data.consent} {scripts}>
197
+ {@render children()}
198
+ <!-- Keep your consent UI and preferences link here. -->
199
+ </ConsentRoot>
200
+ ```
201
+
202
+ Import vendor helpers in the layout component, not in `+layout.server.ts`:
203
+ a server load cannot send functions to the browser. Prerendered, static and
204
+ SPA-mode pages use the same `scripts` prop. If you pass an externally owned
205
+ `runtime` to the provider, register scripts when creating that runtime instead.
206
+
207
+ **HTML**
208
+
209
+ The helpers in `@c15t/integrations` are ES modules that need a bundler. On a
210
+ page that loads the c15t script tag, paste the vendor's own snippet instead
211
+ and keep it inert until its category is allowed:
212
+
213
+ ```html
214
+ <script type="text/plain" data-c15t-category="measurement">
215
+ // The vendor's snippet, unchanged
216
+ </script>
217
+ ```
218
+
219
+ Use the category this guide names for the vendor. c15t runs the snippet
220
+ once that category is allowed, and reloads the page when the visitor
221
+ withdraws it. Helper options on this page, such as `loadMode`, do not apply
222
+ to a pasted snippet. See [HTML scripts](https://c15t.com/docs/frameworks/html/scripts).
223
+
224
+ **JavaScript**
225
+
226
+ Pass the scripts to `init()` from `@c15t/browser`, next to your mode:
227
+
228
+ ```ts
229
+ import { init, manifest } from '@c15t/browser';
230
+ import { scripts } from './consent-scripts';
231
+
232
+ const consent = init({
233
+ mode: manifest(),
234
+ scripts,
235
+ });
236
+ ```
237
+
238
+ Keep the mode from your quickstart. With
239
+ `createConsentRuntime` from `c15t/runtime`, pass `scripts` to it instead.
240
+ A kernel you create yourself needs a loader from
241
+ `c15t/modules/script-loader`. Attach one loader per kernel. See
242
+ [JavaScript scripts](https://c15t.com/docs/frameworks/javascript/scripts).
243
+
244
+ ## Options
245
+
246
+ | Option | Default | Behavior |
247
+ | ------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
248
+ | `writeKey` | Required | Write key of your Data Pipelines JavaScript source. Whitespace is trimmed. If it's missing or blank, c15t logs an error and never loads Customer.io. |
249
+ | `region` | `us` | `us` uses `cdp.customer.io`. `eu` uses `cdp-eu.customer.io`. Any other value throws `customerIo: region must be 'us' or 'eu'`. |
250
+ | `loadOptions` | Unset | Options for the Customer.io loader, such as destination settings. The helper always sets `initialPageview` to `false`, even if you pass `true`. |
251
+ | `category` | `marketing` | Consent condition for the whole loader. |
252
+ | `cdnUrl` | Region's HTTPS origin | Origin for the loader, source settings and SDK files. See [Use a proxy](#use-a-proxy). Blank values use the regional default. |
253
+ | `scriptUrl` | `<cdnUrl>/v1/analytics-js/snippet/<writeKey>/analytics.min.js` | Overrides only the initial loader URL. Blank values use the default. |
254
+
255
+ ## Use a proxy
256
+
257
+ Set `cdnUrl` to your proxy's HTTP(S) origin. The helper trims whitespace and
258
+ trailing slashes. Any path, query, fragment or credentials, or a value without
259
+ a scheme, throws `customerIo: cdnUrl must be an HTTP(S) origin`. `cdnUrl` sets
260
+ `cioanalytics._cdn` as well as the default loader URL, so source settings and
261
+ SDK files come from your proxy too. The proxy must keep Customer.io's paths and
262
+ forward to the source's regional host. A `scriptUrl` override alone doesn't
263
+ change where the SDK loads its files from.
264
+
265
+ `cdnUrl` doesn't move collected events. To proxy Data Pipelines events, set
266
+ `apiHost` for the `Customer.io Data Pipelines` integration in `loadOptions` to
267
+ your collection proxy host plus `/v1`, without a scheme, and set `protocol` to
268
+ `https`:
269
+
270
+ ```ts title="src/customer-io-proxy.ts"
271
+ import { customerIo } from '@c15t/integrations/customer-io';
272
+
273
+ export const proxiedScripts = [
274
+ customerIo({
275
+ cdnUrl: 'https://analytics.example.com',
276
+ loadOptions: {
277
+ integrations: {
278
+ 'Customer.io Data Pipelines': {
279
+ apiHost: 'collect.example.com/v1',
280
+ protocol: 'https',
281
+ },
282
+ },
283
+ },
284
+ writeKey: 'YOUR_WRITE_KEY',
285
+ }),
286
+ ];
287
+ ```
288
+
289
+ Replace both example domains with your own proxies. Neither option redirects
290
+ traffic that destinations send themselves. Configure each destination
291
+ separately where it supports a proxy.
292
+
293
+ ## Loading and revocation
294
+
295
+ After consent, the helper creates Customer.io's array queue and method stubs,
296
+ sets `_writeKey`, `_cdn` and `_loadOptions`, and loads the SDK. The script
297
+ element carries the namespace attribute Customer.io requires. If the page
298
+ already has a loaded `cioanalytics`, the helper keeps it.
299
+
300
+ The helper sends the first `page()` call itself, once the SDK has loaded and
301
+ consent is still granted, and again on each new grant after that. That's why
302
+ it forces `initialPageview` to `false`. It copies `loadOptions`, so your object
303
+ stays unchanged. It doesn't wait for `ready()`, because a destination can fail
304
+ to initialize and some destinations need `page()` before they can start. A
305
+ revoked or disposed loader doesn't send a pending first page view.
306
+
307
+ While the SDK downloads, each method stub returns the same `cioanalytics`
308
+ queue. Calls such as `cioanalytics.identify('customer-123').track('Signed up')`
309
+ queue both calls in order. `cioanalytics` is undefined before consent, so
310
+ check marketing consent before your own code calls it.
311
+
312
+ On withdrawal, the helper calls `reset()` to clear identity. That doesn't stop
313
+ the SDK, its retries or destination SDKs from sending, so keep
314
+ `reloadOnConsentRevoked` enabled. The SDK loads once per page. A new grant on
315
+ the same page reuses it instead of adding another copy. On the next page,
316
+ while marketing is denied, the helper creates no queue and makes no vendor
317
+ requests.
318
+
319
+ ## Cookies and storage
320
+
321
+ Customer.io can use analytics identity cookies and `localStorage` keys
322
+ including `ack`, `reclaimStart`, `reclaimEnd`, `inProgress` and `queue`.
323
+ Destinations can add storage of their own. `reset()` doesn't erase all
324
+ destination data.
325
+
326
+ ## Verify Customer.io
327
+
328
+ Filter the Network panel by `customer.io`, or by your proxy's domain. Before
329
+ consent, and after you allow an unrelated category, check that there is no
330
+ snippet request, no `cioanalytics` global and no vendor cookies or browser
331
+ storage. Allow marketing and check that the SDK initialized. Withdraw marketing
332
+ and confirm the page reloads and the next page stays quiet. A 200 JSON response
333
+ for an invalid write key doesn't prove the SDK initialized.
334
+
335
+ With a proxy, check that the snippet, `/v1/projects/<writeKey>/settings` and
336
+ the SDK files come from the CDN proxy. Check event collection separately
337
+ against the `apiHost` you set. A successful load doesn't prove that events
338
+ reach your workspace or destinations.
339
+
340
+ Sources: Customer.io's [JavaScript source](https://docs.customer.io/cdp/sources/connections/javascript/js-source/),
341
+ [in-app snippet](https://docs.customer.io/integrations/data-in/connections/javascript/in-app/),
342
+ [proxy setup](https://docs.customer.io/integrations/data-in/connections/javascript/js-source-proxy/)
343
+ and [utility methods](https://docs.customer.io/integrations/data-in/connections/javascript/utility-methods/).
344
+
345
+ Test in a private window with an opt-in policy. Open DevTools Network, disable
346
+ the cache and filter by the vendor's domain:
347
+
348
+ 1. Load the page. No request goes to the vendor before you choose.
349
+ 2. Click Reject, then reload. There is still no vendor request.
350
+ 3. Open Privacy settings and allow the helper's category. The vendor script
351
+ loads without a page reload.
352
+ 4. Turn the category off again and save. c15t reloads the page, and the new
353
+ page makes no vendor request.
354
+
355
+ c15t reloads on revocation because removing a script element does not stop
356
+ code that already ran. The vendor's listeners, timers and queued events stay
357
+ alive until the page unloads. If you set `reloadOnConsentRevoked: false`, stop
358
+ the vendor yourself. Register a callback-only script whose `onConsentChange`
359
+ calls the vendor's opt-out API, as shown in
360
+ [custom integrations](./building-integrations.md), and check the
361
+ permission before each of your own event calls. The reload does not delete
362
+ cookies the vendor already set; see
363
+ [clear on revocation for your framework](./overview.md#vendor-switches-and-cookie-cleanup).
364
+
365
+ The helper lists its vendor by name in the preference dialog, so a visitor can
366
+ turn it off inside an allowed category. See
367
+ [vendor consent for your framework](./overview.md#vendor-switches-and-cookie-cleanup). The
368
+ [consent verification guide](../guides/verify-consent.md) covers navigation,
369
+ expiry and hosting checks.
@@ -1,30 +1,29 @@
1
1
  ---
2
2
  title: Databuddy
3
- description: Load the Databuddy SDK on every page with the c15t databuddy
4
- helper, switch its disabled flag and config from measurement consent, and
5
- check both in DevTools.
3
+ description: Load Databuddy only after measurement consent with the c15t
4
+ databuddy helper, turn off tracking features you do not use, record sessions
5
+ with the replay option, and check revocation in DevTools.
6
6
  seoTitle: Databuddy cookie consent with c15t
7
- seoDescription: Keep Databuddy disabled without measurement consent, and turn it
8
- on with consent. Set it up with the c15t databuddy helper.
7
+ seoDescription: Load Databuddy and its session replay only with measurement
8
+ consent, and stop both when consent is withdrawn. Set it up with the c15t
9
+ databuddy helper.
9
10
  icon: databuddy
10
11
  group: integrations
11
12
  ---
12
13
 
13
- The c15t `databuddy` helper loads `databuddy.js` on every page, before the
14
- visitor chooses. The helper uses `alwaysLoad`, but its category is
15
- `measurement`. While `measurement` has no consent, the helper sets
16
- `window.databuddy.options.disabled` to `true`. It also sets
17
- `window.databuddyConfig` to `configWhenDenied`, unless your page set
18
- `window.databuddyConfig` first. When `measurement` has consent, the helper
19
- changes to `configWhenGranted` and sets `disabled` to `false`. If the visitor
20
- withdraws consent, the helper changes both values back.
14
+ The c15t `databuddy` helper waits for `measurement` consent before it loads
15
+ `databuddy.js`. Before the visitor allows measurement, the page sends no
16
+ request to Databuddy and Databuddy stores nothing. If the visitor withdraws
17
+ consent, the helper disables the Databuddy tracker and stops session replay,
18
+ and c15t reloads the page.
21
19
 
22
20
  ## Configure Databuddy
23
21
 
24
22
  Copy the client ID from your Databuddy project. The helper passes it to the
25
- script as `data-client-id`. Remove any existing Databuddy script and any code
26
- that sets `window.databuddyConfig`. The helper seeds that global only when it
27
- is absent, so an existing value overrides your initial state.
23
+ script as `data-client-id`. Remove any existing Databuddy or `replay.js` script
24
+ tag, any `<Databuddy />` component from `@databuddy/sdk`, and any code that
25
+ sets `window.databuddyConfig`. The helper seeds that global only when it is absent,
26
+ so an existing value overrides it.
28
27
 
29
28
  | Package manager | Command |
30
29
  | :-------------- | :------------------------------- |
@@ -37,11 +36,7 @@ is absent, so an existing value overrides your initial state.
37
36
  import { databuddy } from '@c15t/integrations/databuddy';
38
37
 
39
38
  export const scripts = [
40
- databuddy({
41
- clientId: 'YOUR_CLIENT_ID',
42
- configWhenGranted: { disabled: false },
43
- configWhenDenied: { disabled: true },
44
- }),
39
+ databuddy({ clientId: 'YOUR_CLIENT_ID', features: { interactions: false } }),
45
40
  ];
46
41
  ```
47
42
 
@@ -176,7 +171,7 @@ pass them as a top-level prop:
176
171
 
177
172
  ```svelte title="src/App.svelte"
178
173
  <script lang="ts">
179
- import { ConsentProvider, manifest } from '@c15t/svelte';
174
+ import { ConsentProvider, manifest } from 'c15t/svelte';
180
175
  import { scripts } from './consent-scripts';
181
176
  </script>
182
177
 
@@ -195,7 +190,7 @@ handle and the layout load from the [SvelteKit quickstart](https://c15t.com/docs
195
190
 
196
191
  ```svelte title="src/routes/+layout.svelte"
197
192
  <script lang="ts">
198
- import { ConsentRoot } from '@c15t/svelte';
193
+ import { ConsentRoot } from 'c15t/svelte';
199
194
  import { scripts } from '../consent-scripts';
200
195
 
201
196
  let { children, data } = $props();
@@ -251,43 +246,123 @@ A kernel you create yourself needs a loader from
251
246
 
252
247
  ## Options
253
248
 
254
- | Option | Default | Behavior |
255
- | ------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
256
- | `clientId` | Required | Set as `data-client-id`. The helper trims it. Empty or whitespace-only values log an error and the script does not load. |
257
- | `configWhenGranted` | Required | Object set as `window.databuddyConfig` while measurement is allowed. |
258
- | `configWhenDenied` | Required | Object set as `window.databuddyConfig` while measurement is denied. |
259
- | `apiUrl` | `https://basket.databuddy.cc` | Collection endpoint, set as `data-api-url`. |
260
- | `scriptUrl` | `https://cdn.databuddy.cc/databuddy.js` | Loader URL override. A blank value falls back to the default. |
249
+ | Option | Default | Behavior |
250
+ | ------------------------ | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
251
+ | `clientId` | Required | Set as `data-client-id`. The helper trims it. Empty or whitespace-only values log an error and the script does not load. |
252
+ | `loadMode` | `'after-consent'` | When the script loads. See [loading and revocation](#loading-and-revocation). |
253
+ | `features.interactions` | Unset, Databuddy turns it on | Sets `data-track-interactions`. |
254
+ | `features.webVitals` | Unset, Databuddy turns it off | Sets `data-track-web-vitals`. |
255
+ | `features.errors` | Unset, Databuddy turns it off | Sets `data-track-errors`. |
256
+ | `features.outgoingLinks` | Unset, Databuddy turns it off | Sets `data-track-outgoing-links`. |
257
+ | `replay` | `false` | `true` or an object loads `replay.js` while measurement is allowed. See [record sessions](#record-sessions). |
258
+ | `replay.maskText` | Unset, Databuddy masks text | Sets `data-mask-text` on `replay.js`. `false` records page text. |
259
+ | `replay.recordIframes` | Unset, Databuddy turns it off | Sets `data-record-iframes` on `replay.js`. |
260
+ | `replay.scriptUrl` | `https://cdn.databuddy.cc/replay.js` | Replay script URL override. A blank value falls back to the default. |
261
+ | `configWhenGranted` | `{ apiUrl, clientId, disabled: false }` | Object set as `window.databuddyConfig` before the script loads with measurement allowed, and on each grant. c15t sets its `disabled` key from consent. |
262
+ | `configWhenDenied` | `{ apiUrl, clientId, disabled: true }` | With `loadMode: 'always'` only. Object set as `window.databuddyConfig` before the script loads without measurement permission, and on each refusal. c15t sets its `disabled` key from consent. |
263
+ | `apiUrl` | `https://basket.databuddy.cc` | Collection endpoint, set as `data-api-url`. |
264
+ | `scriptUrl` | `https://cdn.databuddy.cc/databuddy.js` | Loader URL override. A blank value falls back to the default. |
265
+
266
+ ## Turn off features you do not use
267
+
268
+ Databuddy collects some data unless the site turns it off. Set a `features`
269
+ switch to `false` to stop that collection, or to `true` to turn on a feature
270
+ Databuddy leaves off:
271
+
272
+ ```ts
273
+ databuddy({
274
+ clientId: 'YOUR_CLIENT_ID',
275
+ features: {
276
+ interactions: false,
277
+ webVitals: false,
278
+ errors: false,
279
+ outgoingLinks: false,
280
+ },
281
+ });
282
+ ```
283
+
284
+ | Switch | Databuddy default | What Databuddy collects |
285
+ | --------------- | ----------------- | -------------------------------------------- |
286
+ | `interactions` | On | Rage clicks, dead clicks and abandoned forms |
287
+ | `webVitals` | Off | FCP, LCP, INP, CLS, TTFB and FPS |
288
+ | `errors` | Off | JavaScript errors, with message and stack |
289
+ | `outgoingLinks` | Off | Clicks on links to other sites |
290
+
291
+ Each switch sets a `data-track-*` attribute on the script. An unset switch
292
+ sets no attribute, so Databuddy keeps its own default. Databuddy reads `data-*`
293
+ attributes after `window.databuddyConfig`, so a switch wins over the same key
294
+ in `configWhenGranted` or `configWhenDenied`.
261
295
 
262
296
  ## Loading and revocation
263
297
 
264
- `databuddy` uses the `measurement` category with `alwaysLoad`, so the
265
- Databuddy script loads on every page, before the visitor chooses. Before the
266
- script loads, the helper sets `window.databuddyConfig` to `configWhenDenied` or
267
- `configWhenGranted`, unless that global already exists. After the script
268
- loads, the helper sets `window.databuddy.options.disabled` to `true` without
269
- measurement permission and to `false` with it. On each later consent change,
270
- the helper replaces `window.databuddyConfig` with the matching object and
271
- updates `disabled` again. c15t never removes the script.
298
+ | `loadMode` | When `databuddy.js` loads | Before the visitor allows measurement |
299
+ | ----------------- | --------------------------------- | -------------------------------------------------------------------------- |
300
+ | `'after-consent'` | Only while measurement is allowed | No request to Databuddy and no storage |
301
+ | `'always'` | On every page, before consent | The script loads and stores a visitor ID while `disabled` stops it sending |
302
+
303
+ On revocation, the helper sets `window.databuddy.options.disabled` to `true`,
304
+ which stops the main tracker sending. It also sets `disabled: true` in
305
+ `window.databuddyConfig`, or replaces the object with `configWhenDenied` in
306
+ `'always'` mode. A `databuddy.js` download that finishes after the refusal then
307
+ starts disabled. With [`replay`](#record-sessions) on, the helper also stops
308
+ the recorder. c15t then reloads the page, which is the default
309
+ `reloadOnConsentRevoked` behavior. On a later grant, c15t sets both back to
310
+ `false`, and `window.databuddyConfig` to `configWhenGranted`.
311
+
312
+ With `loadMode: 'always'`, `databuddy.js` runs before the visitor chooses. It
313
+ stores its visitor ID in localStorage even while `disabled` is `true`.
314
+ Databuddy's own consent guidance is to delay loading until consent where prior
315
+ consent is required. Use `'always'` only where your policy allows that.
316
+
317
+ ## Record sessions
318
+
319
+ Databuddy records sessions with a separate script, `replay.js`. Set `replay`
320
+ to have the helper load it:
321
+
322
+ ```ts
323
+ databuddy({ clientId: 'YOUR_CLIENT_ID', replay: true });
324
+ ```
272
325
 
273
- The Databuddy SDK decides what `disabled` stops. The helper cannot prevent the
274
- script request before consent. If Databuddy must receive no request before
275
- consent, write a
276
- [custom gated integration](./building-integrations.md) instead.
326
+ `replay: true` keeps Databuddy's replay defaults, which mask page text and
327
+ typed input. The helper adds `replay.js` only while measurement is allowed,
328
+ including with `loadMode: 'always'`, and passes it the same `clientId` and
329
+ `apiUrl` as `databuddy.js`. `replay.js` does not read Databuddy's `disabled`
330
+ flag, so the helper calls `window.databuddyReplay.stop()` and removes the
331
+ script on revocation. It does the same when you turn `replay` off, remove the
332
+ helper or dispose the script loader. Recording stops without waiting for the
333
+ page reload. A later grant loads `replay.js` again.
334
+
335
+ `replay: { maskText: false }` records page text; typed input stays masked. Use
336
+ it only when your pages show no personal data, such as names, email addresses
337
+ or order details. Recordings would otherwise include that data. To change
338
+ masking for one element, add an attribute to it in your markup:
339
+
340
+ * `data-replay-unmask` records the text of an element that is safe to show.
341
+ * `data-replay-block` leaves the element out. The recording shows an empty box
342
+ of the same size.
343
+
344
+ `recordIframes: true` records your own embedded pages into the parent page's
345
+ recording. Set it on the framed page too. See
346
+ [Databuddy's session replay guide](https://www.databuddy.cc/docs/session-replay)
347
+ for its limits and the dashboard setting that turns replay off.
348
+
349
+ Do not also add `replay.js` to the page as a plain `<script>` tag. Outside
350
+ c15t, it starts recording on the visitor's first click, scroll or key press,
351
+ and uploads that recording even if the visitor has not chosen.
277
352
 
278
353
  ## Verify Databuddy
279
354
 
280
- 1. In a private window with an opt-in policy, load the page. `databuddy.js`
281
- loads from `cdn.databuddy.cc` with your `data-client-id`. In the console,
282
- `window.databuddyConfig` matches `configWhenDenied` and
283
- `window.databuddy.options.disabled` is `true`.
284
- 2. Click Reject, then reload. `disabled` is still `true`, and DevTools Network
285
- shows no event request to your `apiUrl`.
286
- 3. Open Privacy settings and allow measurement. Without a reload, `disabled`
287
- becomes `false`, `window.databuddyConfig` matches `configWhenGranted`, and
288
- event requests reach your `apiUrl`.
355
+ 1. In a private window with an opt-in policy, load the page. DevTools Network
356
+ shows no request to `cdn.databuddy.cc` or `basket.databuddy.cc`, and
357
+ Application shows no `did` key in localStorage.
358
+ 2. Click Reject, then reload. There are still no Databuddy requests.
359
+ 3. Open Privacy settings and allow measurement. Without a reload,
360
+ `databuddy.js` loads from `cdn.databuddy.cc` with your `data-client-id`, and
361
+ requests reach your `apiUrl`. With `replay` on, `replay.js` loads too. Move
362
+ the pointer or scroll, and a `POST` to `/replay` follows within a few
363
+ seconds.
289
364
  4. Turn measurement off again and save. c15t reloads the page, and the new
290
- page starts with `disabled` set to `true`.
365
+ page sends no request to `cdn.databuddy.cc` or `basket.databuddy.cc`.
291
366
 
292
367
  See the [consent verification guide](../guides/verify-consent.md) for
293
368
  navigation and hosting checks.