@c15t/react 3.2.0-canary.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.
- package/AGENTS.md +30 -7
- package/dist/styles.tw3.css +2 -2
- package/dist/version.js +1 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +30 -7
- package/docs/concepts/modes.md +5 -3
- package/docs/customization/stylesheets.md +39 -0
- package/docs/frameworks/react/hooks.md +2 -1
- package/docs/frameworks/react/quickstart.md +1 -1
- package/docs/frameworks/react/upgrade-v3.md +2 -2
- package/docs/integrations/activecampaign.md +297 -0
- package/docs/integrations/ada.md +396 -0
- package/docs/integrations/adobe-target.md +460 -0
- package/docs/integrations/adroll.md +336 -0
- package/docs/integrations/amazon-ads.md +424 -0
- package/docs/integrations/appcues.md +368 -0
- package/docs/integrations/attentive.md +313 -0
- package/docs/integrations/building-integrations.md +29 -16
- package/docs/integrations/clearbit.md +1 -1
- package/docs/integrations/customer-io.md +369 -0
- package/docs/integrations/databuddy.md +125 -50
- package/docs/integrations/default-com.md +497 -0
- package/docs/integrations/dynamic-yield.md +373 -0
- package/docs/integrations/fullstory.md +298 -0
- package/docs/integrations/gainsight-px.md +418 -0
- package/docs/integrations/gorgias.md +365 -0
- package/docs/integrations/hubspot.md +529 -0
- package/docs/integrations/insider.md +550 -0
- package/docs/integrations/liveintent.md +327 -0
- package/docs/integrations/lucky-orange.md +336 -0
- package/docs/integrations/marketo.md +309 -0
- package/docs/integrations/optimizely.md +411 -0
- package/docs/integrations/oracle-eloqua.md +301 -0
- package/docs/integrations/overview.md +124 -111
- package/docs/integrations/pendo.md +339 -0
- package/docs/integrations/rb2b.md +363 -0
- package/docs/integrations/salesforce-pardot.md +342 -0
- package/docs/integrations/statable-analytics.md +345 -0
- package/docs/integrations/the-trade-desk.md +328 -0
- package/docs/integrations/vector.md +333 -0
- package/docs/integrations/wisepops.md +416 -0
- package/docs/integrations/zendesk.md +359 -0
- package/package.json +8 -8
- package/docs/integrations/other-ads-and-pixels.md +0 -94
- package/docs/integrations/other-analytics.md +0 -108
- package/docs/integrations/other-chat-and-support.md +0 -112
- package/docs/integrations/other-email-and-sms.md +0 -156
- package/docs/integrations/other-experience.md +0 -222
|
@@ -36,22 +36,22 @@ with your framework, follow any vendor guide, for example
|
|
|
36
36
|
|
|
37
37
|
## Script fields
|
|
38
38
|
|
|
39
|
-
| Field | Default | Behavior
|
|
40
|
-
| ----------------------------------------------- | ---------------------- |
|
|
41
|
-
| `id` | Required | Stable identifier. c15t tracks the script by it across renders.
|
|
42
|
-
| `category` | Required | A category name, or a condition such as `{ or: ['measurement', 'marketing'] }`, `{ and: [...] }` or `{ not: '...' }`.
|
|
43
|
-
| `src` / `textContent` | None | Set exactly one, unless `callbackOnly` is `true`.
|
|
44
|
-
| `vendor` | None | Vendor slug, so a visitor can turn this vendor off inside an allowed category.
|
|
45
|
-
| `callbackOnly` | `false` |
|
|
46
|
-
| `alwaysLoad` | `false` | Load regardless of permission.
|
|
47
|
-
| `persistAfterConsentRevoked` | `false` |
|
|
48
|
-
| `onBeforeLoad`, `onLoad`, `onError` | None | Run before the element is added, after it loads, and if it fails.
|
|
49
|
-
| `onConsentChange` | None | Runs when permissions change after the script has loaded, and when it is removed.
|
|
50
|
-
| `onDispose` | None | Runs when this configuration is removed or its loader is disposed. Revocation alone does not call it.
|
|
51
|
-
| `target` | `'head'` | `'head'` or `'body'`.
|
|
52
|
-
| `async`, `defer`, `attributes`, `fetchPriority` | None | Copied to the script element.
|
|
53
|
-
| `nonce` | The provider's `nonce` | Content Security Policy nonce for this element.
|
|
54
|
-
| `anonymizeId` | `true` | Use a random element ID. Set `false` for `c15t-script-<id>`.
|
|
39
|
+
| Field | Default | Behavior |
|
|
40
|
+
| ----------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
41
|
+
| `id` | Required | Stable identifier. c15t tracks the script by it across renders. |
|
|
42
|
+
| `category` | Required | A category name, or a condition such as `{ or: ['measurement', 'marketing'] }`, `{ and: [...] }` or `{ not: '...' }`. |
|
|
43
|
+
| `src` / `textContent` | None | Set exactly one, unless `callbackOnly` is `true` or returns `true`. |
|
|
44
|
+
| `vendor` | None | Vendor slug, so a visitor can turn this vendor off inside an allowed category. |
|
|
45
|
+
| `callbackOnly` | `false` | `true` or a zero-argument predicate returning `true` runs callbacks without adding a script element. |
|
|
46
|
+
| `alwaysLoad` | `false` | Load regardless of permission. |
|
|
47
|
+
| `persistAfterConsentRevoked` | `false` | `true` keeps the element after withdrawal, including pending downloads. `'loaded'` keeps only elements whose load event completed; pending and failed loads are removed. |
|
|
48
|
+
| `onBeforeLoad`, `onLoad`, `onError` | None | Run before the element is added, after it loads, and if it fails. |
|
|
49
|
+
| `onConsentChange` | None | Runs when permissions change after the script has loaded, and when it is removed. |
|
|
50
|
+
| `onDispose` | None | Runs when this configuration is removed or its loader is disposed. Revocation alone does not call it. |
|
|
51
|
+
| `target` | `'head'` | `'head'` or `'body'`. |
|
|
52
|
+
| `async`, `defer`, `attributes`, `fetchPriority` | None | Copied to the script element. |
|
|
53
|
+
| `nonce` | The provider's `nonce` | Content Security Policy nonce for this element. |
|
|
54
|
+
| `anonymizeId` | `true` | Use a random element ID. Set `false` for `c15t-script-<id>`. |
|
|
55
55
|
|
|
56
56
|
Every callback receives `{ id, elementId, hasConsent, consents }`, plus
|
|
57
57
|
`vendor` when the script declares one, and `element` for scripts with an
|
|
@@ -137,6 +137,19 @@ a callback-only script runs `onBeforeLoad` and `onLoad` only once permission is
|
|
|
137
137
|
allowed. [PostHog](./posthog.md#use-an-existing-posthog-sdk) shows
|
|
138
138
|
this pattern with a real SDK.
|
|
139
139
|
|
|
140
|
+
For runtime detection, `callbackOnly` also accepts a zero-argument function
|
|
141
|
+
that returns a boolean. c15t evaluates it before each new mount, when reading
|
|
142
|
+
diagnostics, and when selecting scripts for server startup. Return `true` to
|
|
143
|
+
use callbacks alone, or `false` to load `src` or `textContent`. Keep the function
|
|
144
|
+
free of side effects and safe to call on the server. It can run more than once,
|
|
145
|
+
and it does not remove an element already mounted by that registration.
|
|
146
|
+
A function survives script customization with object spread, so later mounts
|
|
147
|
+
check the current runtime instead of a value captured when the copy was made.
|
|
148
|
+
Keep the function reference stable across script updates, for example by
|
|
149
|
+
defining it at module level. A new function counts as a resource change and
|
|
150
|
+
remounts the registration. If a predicate throws during server startup, c15t
|
|
151
|
+
leaves that script to the client loader and starts unrelated scripts normally.
|
|
152
|
+
|
|
140
153
|
## Revocation and verification
|
|
141
154
|
|
|
142
155
|
By default c15t reloads the page when a visitor turns off a category or vendor
|
|
@@ -249,7 +249,7 @@ A kernel you create yourself needs a loader from
|
|
|
249
249
|
|
|
250
250
|
`clearbit` uses the `marketing` category, not `measurement`. Clearbit
|
|
251
251
|
identifies visitors and their companies for enrichment, so c15t treats it as
|
|
252
|
-
marketing
|
|
252
|
+
marketing. The `tags.js` script
|
|
253
253
|
loads with `referrerpolicy="strict-origin-when-cross-origin"` only while
|
|
254
254
|
marketing is allowed. On revocation the helper removes the script element and
|
|
255
255
|
calls no Clearbit API.
|
|
@@ -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.
|