@c15t/react 3.0.0-alpha.9 → 3.0.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 +7 -9
- package/README.md +41 -70
- package/SKILL.md +1 -1
- package/dist/aggregate-components.js +1 -1
- package/dist/components/consent-gate/atoms.js +1 -1
- package/dist/components/consent-gate/frame.js +2 -0
- package/dist/components/consent-gate/index.js +1 -1
- package/dist/components/iab-panel/atoms/root.js +1 -1
- package/dist/components/iab-panel/iab-panel.js +1 -1
- package/dist/components/iab-prompt/atoms/root.js +1 -1
- package/dist/components/iab-prompt/iab-prompt.js +1 -1
- package/dist/components/panel/atoms/root.js +1 -1
- package/dist/components/panel-trigger/atoms/root.js +1 -1
- package/dist/components/panel-trigger/panel-trigger.js +1 -1
- package/dist/components/panel-trigger/toolbar-loader.js +2 -0
- package/dist/components/preferences/atoms/root.js +1 -1
- package/dist/components/prompt/atoms/early-tap-script.js +2 -0
- package/dist/components/prompt/atoms/root.js +1 -1
- package/dist/components/shared/primitives/button.js +1 -1
- package/dist/components/shared/surface-styles.js +1 -1
- package/dist/consent-gate.js +1 -1
- package/dist/context/index.js +1 -1
- package/dist/devtools.js +1 -1
- package/dist/iab/styles.tw3.css +2 -2
- package/dist/iab-dialog-deferred.js +2 -0
- package/dist/iab.js +1 -1
- package/dist/index-parts/consent-gate.js +1 -1
- package/dist/index-parts/core.js +1 -1
- package/dist/index-parts/frame.js +1 -0
- package/dist/index-parts/hosted.js +1 -0
- package/dist/index-parts/offline.js +1 -0
- package/dist/index-parts/presets.js +1 -0
- package/dist/index.js +1 -1
- package/dist/modes.js +1 -0
- package/dist/panel-link.js +1 -1
- package/dist/panel-trigger.js +1 -1
- package/dist/provider.js +1 -1
- package/dist/styles.tw3.css +2 -2
- package/dist/transports/hosted.js +1 -0
- package/dist/transports/manifest.js +1 -0
- package/dist/utils/deferred-module.js +1 -1
- package/dist/version.js +1 -1
- package/dist-types/chunk-warming.d.ts +7 -6
- package/dist-types/components/consent-gate/frame.d.ts +19 -0
- package/dist-types/components/consent-gate/index.d.ts +3 -19
- package/dist-types/components/iab-prompt/iab-prompt.d.ts +1 -1
- package/dist-types/components/panel/index.d.ts +1 -1
- package/dist-types/components/panel-trigger/toolbar-loader.d.ts +34 -0
- package/dist-types/components/preferences/index.d.ts +1 -1
- package/dist-types/components/prompt/atoms/early-tap-script.d.ts +17 -0
- package/dist-types/components/prompt/index.d.ts +1 -1
- package/dist-types/components/shared/surface-styles.d.ts +26 -2
- package/dist-types/consent-gate.d.ts +1 -1
- package/dist-types/context/index.d.ts +3 -3
- package/dist-types/context.d.ts +2 -0
- package/dist-types/gpp.d.ts +1 -1
- package/dist-types/iab-dialog-deferred.d.ts +36 -0
- package/dist-types/iab.d.ts +3 -2
- package/dist-types/index-parts/consent-gate.d.ts +1 -1
- package/dist-types/index-parts/core.d.ts +1 -2
- package/dist-types/index-parts/frame.d.ts +7 -0
- package/dist-types/index-parts/hosted.d.ts +7 -0
- package/dist-types/index-parts/offline.d.ts +7 -0
- package/dist-types/index-parts/presets.d.ts +7 -0
- package/dist-types/index.d.ts +5 -1
- package/dist-types/modes.d.ts +26 -0
- package/dist-types/panel-link.d.ts +1 -1
- package/dist-types/panel-trigger.d.ts +1 -1
- package/dist-types/provider.d.ts +3 -3
- package/dist-types/transports/hosted.d.ts +36 -0
- package/dist-types/transports/manifest.d.ts +48 -0
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +7 -9
- package/docs/concepts/choose-your-setup.md +45 -10
- package/docs/concepts/consent-categories.md +1 -1
- package/docs/concepts/consent-state.md +5 -2
- package/docs/concepts/data-fetching.md +100 -42
- package/docs/concepts/modes.md +281 -0
- package/docs/customization/dark-mode.md +1 -1
- package/docs/customization/motion.md +2 -2
- package/docs/customization/recipes.md +4 -4
- package/docs/customization/slots.md +25 -25
- package/docs/customization/stylesheets.md +12 -14
- package/docs/customization/tailwind.md +17 -11
- package/docs/customization/tokens.md +36 -7
- package/docs/frameworks/react/components/consent-banner.md +14 -10
- package/docs/frameworks/react/components/consent-dialog.md +14 -10
- package/docs/frameworks/react/components/consent-provider.md +51 -44
- package/docs/frameworks/react/components.md +14 -10
- package/docs/frameworks/react/content-security-policy.md +21 -12
- package/docs/frameworks/react/hooks.md +2 -2
- package/docs/frameworks/react/iab.md +20 -2
- package/docs/frameworks/react/quickstart.md +63 -97
- package/docs/frameworks/react/rendering.md +168 -94
- package/docs/frameworks/react/scripts.md +19 -28
- package/docs/frameworks/react/troubleshooting.md +57 -25
- package/docs/frameworks/react/upgrade-v3.md +110 -62
- package/docs/guides/banner-experiments.md +21 -6
- package/docs/guides/troubleshooting.md +89 -25
- package/docs/guides/verify-consent.md +23 -8
- package/docs/integrations/adobe-analytics.md +60 -64
- package/docs/integrations/ahrefs-analytics.md +58 -63
- package/docs/integrations/amplitude.md +60 -64
- package/docs/integrations/clearbit.md +59 -63
- package/docs/integrations/cloudflare-web-analytics.md +56 -60
- package/docs/integrations/cloudflare-zaraz.md +55 -57
- package/docs/integrations/crisp.md +64 -69
- package/docs/integrations/databuddy.md +62 -64
- package/docs/integrations/fathom-analytics.md +56 -60
- package/docs/integrations/front-chat.md +56 -60
- package/docs/integrations/google-maps.md +25 -13
- package/docs/integrations/google-tag-manager.md +153 -77
- package/docs/integrations/google-tag.md +134 -78
- package/docs/integrations/heap.md +56 -60
- package/docs/integrations/hightouch.md +55 -60
- package/docs/integrations/hotjar.md +60 -64
- package/docs/integrations/intercom.md +55 -60
- package/docs/integrations/klaviyo.md +65 -66
- package/docs/integrations/linkedin-insights.md +58 -63
- package/docs/integrations/logrocket.md +55 -60
- package/docs/integrations/matomo-analytics.md +58 -60
- package/docs/integrations/meta-pixel.md +56 -60
- package/docs/integrations/microsoft-clarity.md +57 -60
- package/docs/integrations/microsoft-uet.md +58 -61
- package/docs/integrations/mixpanel-analytics.md +73 -75
- package/docs/integrations/one-dollar-stats.md +53 -59
- package/docs/integrations/openai-pixel.md +58 -60
- package/docs/integrations/overview.md +59 -42
- package/docs/integrations/pinterest-tag.md +56 -60
- package/docs/integrations/pirsch.md +54 -60
- package/docs/integrations/plausible-analytics.md +55 -60
- package/docs/integrations/posthog.md +56 -60
- package/docs/integrations/promptwatch.md +57 -63
- package/docs/integrations/reddit-pixel.md +57 -60
- package/docs/integrations/rudderstack.md +65 -67
- package/docs/integrations/rybbit-analytics.md +70 -75
- package/docs/integrations/segment.md +56 -60
- package/docs/integrations/sentry.md +65 -60
- package/docs/integrations/snapchat-pixel.md +54 -60
- package/docs/integrations/tiktok-pixel.md +59 -63
- package/docs/integrations/umami-analytics.md +54 -60
- package/docs/integrations/vercel-analytics.md +53 -59
- package/docs/integrations/vercel-speed-insights.md +317 -0
- package/docs/integrations/x-pixel.md +57 -63
- package/docs/integrations/youtube.md +25 -13
- package/package.json +18 -8
- package/docs/upgrade-v3.md +0 -429
|
@@ -3,21 +3,33 @@ title: RudderStack
|
|
|
3
3
|
description: Load the RudderStack JavaScript SDK after measurement consent with
|
|
4
4
|
the c15t rudderstack helper, or map c15t categories to destination consent
|
|
5
5
|
IDs, and check each mode.
|
|
6
|
+
seoTitle: RudderStack cookie consent with c15t
|
|
7
|
+
seoDescription: Load RudderStack only after measurement consent, or use
|
|
8
|
+
RudderStack consent management with mapped consent IDs. Set it up with the
|
|
9
|
+
c15t rudderstack helper.
|
|
6
10
|
icon: rudderstack
|
|
7
11
|
group: integrations
|
|
8
12
|
---
|
|
9
13
|
|
|
14
|
+
By default, the c15t `rudderstack` helper keeps the RudderStack JavaScript SDK
|
|
15
|
+
off the page until `measurement` has consent. In this mode, the helper sends no
|
|
16
|
+
consent signal to RudderStack. With `consentManagement`, the helper loads the
|
|
17
|
+
SDK on every page in the RudderStack pre-consent mode, before the visitor
|
|
18
|
+
chooses. In that mode, the SDK keeps events in a buffer and uses no persistent
|
|
19
|
+
storage. The helper then calls `rudderanalytics.consent()` and puts each mapped
|
|
20
|
+
consent ID in the allowed or denied list, from its c15t category.
|
|
21
|
+
|
|
10
22
|
## Configure RudderStack
|
|
11
23
|
|
|
12
24
|
Copy the source write key and the HTTPS data plane URL from your RudderStack
|
|
13
25
|
source. Keep control-plane credentials out of the browser.
|
|
14
26
|
|
|
15
|
-
| Package manager | Command
|
|
16
|
-
| :-------------- |
|
|
17
|
-
| npm | `npm install @c15t/integrations
|
|
18
|
-
| pnpm | `pnpm add @c15t/integrations
|
|
19
|
-
| yarn | `yarn add @c15t/integrations
|
|
20
|
-
| bun | `bun add @c15t/integrations
|
|
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` |
|
|
21
33
|
|
|
22
34
|
```ts title="src/consent-scripts.ts"
|
|
23
35
|
import { rudderstack } from '@c15t/integrations/rudderstack';
|
|
@@ -37,51 +49,41 @@ endpoint, policy, styles and consent UI. Remove the vendor's original script,
|
|
|
37
49
|
SDK initializer or tag-manager entry, so the vendor loads only through c15t.
|
|
38
50
|
|
|
39
51
|
The vendor pages put the helper in `src/consent-scripts.ts`. If your framework
|
|
40
|
-
quickstart already
|
|
41
|
-
Next.js guide, add the helper to that array instead of creating a
|
|
52
|
+
quickstart already has a `scripts` array, such as the one in `c15t.config.ts`
|
|
53
|
+
in the Next.js guide, add the helper to that array instead of creating a
|
|
54
|
+
second file.
|
|
42
55
|
The `scripts` export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration
|
|
43
56
|
point for your framework below. These are edits to that provider, not a second
|
|
44
57
|
provider.
|
|
45
58
|
|
|
46
59
|
**Next.js**
|
|
47
60
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
import { ConsentRoot } from 'c15t/next';
|
|
52
|
-
import { scripts } from './consent-scripts';
|
|
53
|
-
```
|
|
61
|
+
Add the configuration to `scripts` in `c15t.config.ts`, next to
|
|
62
|
+
`next.config.ts`:
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
```ts title="c15t.config.ts"
|
|
65
|
+
import { defineConsentConfig } from 'c15t/next';
|
|
66
|
+
import { scripts } from './src/consent-scripts';
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
<ConsentRoot state={state} config={consentConfig} scripts={scripts}>
|
|
61
|
-
{children}
|
|
62
|
-
</ConsentRoot>
|
|
68
|
+
export default defineConsentConfig({ scripts });
|
|
63
69
|
```
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
Keep the rest of your config, such as `mode` and `routePrefix`, in the
|
|
72
|
+
same call. `ConsentRoot` reads the config in the browser, so the layout
|
|
73
|
+
keeps passing only `state`. App Router, Pages Router and static export all
|
|
74
|
+
read the same file. See
|
|
68
75
|
[Next.js scripts and embeds](https://c15t.com/docs/frameworks/next/scripts).
|
|
69
76
|
|
|
70
77
|
**TanStack Start**
|
|
71
78
|
|
|
72
79
|
Import the configuration into your root route and pass it to the existing
|
|
73
|
-
`ConsentRoot` as a top-level prop. Keep the loader
|
|
74
|
-
|
|
80
|
+
`ConsentRoot` as a top-level prop. Keep the loader from the
|
|
81
|
+
[TanStack Start quickstart](https://c15t.com/docs/frameworks/tanstack-start/quickstart):
|
|
75
82
|
|
|
76
83
|
```tsx title="src/routes/__root.tsx"
|
|
77
84
|
import { scripts } from '../consent-scripts';
|
|
78
85
|
|
|
79
|
-
<ConsentRoot
|
|
80
|
-
state={consent}
|
|
81
|
-
backendURL={backendURL}
|
|
82
|
-
initRoute={false}
|
|
83
|
-
scripts={scripts}
|
|
84
|
-
>
|
|
86
|
+
<ConsentRoot state={consent} scripts={scripts}>
|
|
85
87
|
```
|
|
86
88
|
|
|
87
89
|
Import vendor helpers in the root route module, not in a server function.
|
|
@@ -100,8 +102,8 @@ import { scripts } from './consent-scripts';
|
|
|
100
102
|
<ConsentProvider options={{ mode, scripts }}>
|
|
101
103
|
```
|
|
102
104
|
|
|
103
|
-
`mode` is the `
|
|
104
|
-
|
|
105
|
+
`mode` is the `manifest()` value from the
|
|
106
|
+
[React quickstart](../frameworks/react/quickstart.md). Keep the banner,
|
|
105
107
|
dialog and preferences link inside the provider. See
|
|
106
108
|
[React scripts and embeds](../frameworks/react/scripts.md).
|
|
107
109
|
|
|
@@ -130,15 +132,16 @@ callbacks. Write the vendor IDs into `consent-scripts.ts`. See
|
|
|
130
132
|
Pass the scripts to the existing `c15tVue` plugin call in `src/main.ts`:
|
|
131
133
|
|
|
132
134
|
```ts title="src/main.ts"
|
|
135
|
+
import { c15tVue, manifest } from 'c15t/vue/vue-plugin';
|
|
133
136
|
import { scripts } from './consent-scripts';
|
|
134
137
|
|
|
135
138
|
app.use(c15tVue, {
|
|
136
|
-
|
|
139
|
+
mode: manifest(),
|
|
137
140
|
scripts,
|
|
138
141
|
});
|
|
139
142
|
```
|
|
140
143
|
|
|
141
|
-
Keep your existing
|
|
144
|
+
Keep your existing `mode` and other options. The plugin starts one
|
|
142
145
|
script loader when the app mounts, after it has applied the visitor's stored
|
|
143
146
|
choice. Do not also call `createScriptLoader` from a component. See
|
|
144
147
|
[Vue scripts and embeds](https://c15t.com/docs/frameworks/vue/scripts).
|
|
@@ -146,12 +149,11 @@ choice. Do not also call `createScriptLoader` from a component. See
|
|
|
146
149
|
**Astro**
|
|
147
150
|
|
|
148
151
|
Add the scripts to the client entrypoint from the
|
|
149
|
-
[Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart),
|
|
150
|
-
integration
|
|
151
|
-
|
|
152
|
-
already exports scripts, combine the two arrays.
|
|
152
|
+
[Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart), `src/c15t.client.ts`,
|
|
153
|
+
which the integration finds on its own. Keep `astro.config.mjs` as it is.
|
|
154
|
+
If the module already exports scripts, combine the two arrays.
|
|
153
155
|
|
|
154
|
-
```ts title="src/
|
|
156
|
+
```ts title="src/c15t.client.ts"
|
|
155
157
|
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
156
158
|
import { scripts } from './consent-scripts';
|
|
157
159
|
|
|
@@ -171,15 +173,13 @@ pass them as a top-level prop:
|
|
|
171
173
|
|
|
172
174
|
```svelte title="src/App.svelte"
|
|
173
175
|
<script lang="ts">
|
|
174
|
-
import {
|
|
176
|
+
import { ConsentProvider, manifest } from '@c15t/svelte';
|
|
175
177
|
import { scripts } from './consent-scripts';
|
|
176
|
-
|
|
177
|
-
const mode = hosted({ url: 'https://your-project.inth.app' });
|
|
178
178
|
</script>
|
|
179
179
|
|
|
180
|
-
<
|
|
180
|
+
<ConsentProvider mode={manifest()} {scripts}>
|
|
181
181
|
<!-- Keep your application, consent UI and preferences link here. -->
|
|
182
|
-
</
|
|
182
|
+
</ConsentProvider>
|
|
183
183
|
```
|
|
184
184
|
|
|
185
185
|
Retain the styles and consent UI from the [Svelte quickstart](https://c15t.com/docs/frameworks/svelte/quickstart).
|
|
@@ -187,22 +187,21 @@ The provider owns the loader and disposes it on unmount.
|
|
|
187
187
|
|
|
188
188
|
**SvelteKit**
|
|
189
189
|
|
|
190
|
-
Add the scripts to the existing root layout
|
|
191
|
-
and
|
|
190
|
+
Add the scripts to the existing `ConsentRoot` in the root layout. Keep the
|
|
191
|
+
handle and the layout load from the [SvelteKit quickstart](https://c15t.com/docs/frameworks/sveltekit/quickstart).
|
|
192
192
|
|
|
193
193
|
```svelte title="src/routes/+layout.svelte"
|
|
194
194
|
<script lang="ts">
|
|
195
|
-
import {
|
|
195
|
+
import { ConsentRoot } from '@c15t/svelte';
|
|
196
196
|
import { scripts } from '../consent-scripts';
|
|
197
197
|
|
|
198
198
|
let { children, data } = $props();
|
|
199
|
-
const mode = hosted({ url: 'https://your-project.inth.app' });
|
|
200
199
|
</script>
|
|
201
200
|
|
|
202
|
-
<
|
|
201
|
+
<ConsentRoot state={data.consent} {scripts}>
|
|
203
202
|
{@render children()}
|
|
204
203
|
<!-- Keep your consent UI and preferences link here. -->
|
|
205
|
-
</
|
|
204
|
+
</ConsentRoot>
|
|
206
205
|
```
|
|
207
206
|
|
|
208
207
|
Import vendor helpers in the layout component, not in `+layout.server.ts`:
|
|
@@ -229,20 +228,19 @@ to a pasted snippet. See [HTML scripts](https://c15t.com/docs/frameworks/html/sc
|
|
|
229
228
|
|
|
230
229
|
**JavaScript**
|
|
231
230
|
|
|
232
|
-
Pass the scripts to `init()` from `@c15t/browser`, next to your
|
|
233
|
-
URL:
|
|
231
|
+
Pass the scripts to `init()` from `@c15t/browser`, next to your mode:
|
|
234
232
|
|
|
235
233
|
```ts
|
|
236
|
-
import { init } from '@c15t/browser';
|
|
234
|
+
import { init, manifest } from '@c15t/browser';
|
|
237
235
|
import { scripts } from './consent-scripts';
|
|
238
236
|
|
|
239
237
|
const consent = init({
|
|
240
|
-
|
|
238
|
+
mode: manifest(),
|
|
241
239
|
scripts,
|
|
242
240
|
});
|
|
243
241
|
```
|
|
244
242
|
|
|
245
|
-
Keep the
|
|
243
|
+
Keep the mode from your quickstart. With
|
|
246
244
|
`createConsentRuntime` from `c15t/runtime`, pass `scripts` to it instead.
|
|
247
245
|
A kernel you create yourself needs a loader from
|
|
248
246
|
`c15t/modules/script-loader`. Attach one loader per kernel. See
|
|
@@ -250,14 +248,14 @@ A kernel you create yourself needs a loader from
|
|
|
250
248
|
|
|
251
249
|
## Options
|
|
252
250
|
|
|
253
|
-
| Option | Default | Behavior
|
|
254
|
-
| ------------------- | ------------------------------------------------- |
|
|
255
|
-
| `writeKey` | Required | Source write key. Surrounding whitespace is trimmed
|
|
256
|
-
| `dataPlaneUrl` | Required | Data plane URL. A missing, invalid or non-HTTPS URL
|
|
257
|
-
| `consentManagement` | None | `{ mapping }` from c15t categories to RudderStack consent IDs. Switches to destination consent mode.
|
|
258
|
-
| `loadOptions` | `{}` | Third argument to `rudderanalytics.load()`. Use JSON-serializable values only.
|
|
259
|
-
| `trackPageView` | `true` | Queues `rudderanalytics.page()` before the loader.
|
|
260
|
-
| `scriptUrl` | `https://cdn.rudderlabs.com/v3/modern/rsa.min.js` | Loader URL override. A non-HTTPS URL throws; a blank value uses the default.
|
|
251
|
+
| Option | Default | Behavior |
|
|
252
|
+
| ------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
253
|
+
| `writeKey` | Required | Source write key. Surrounding whitespace is trimmed. An empty value logs an error and the script does not load. |
|
|
254
|
+
| `dataPlaneUrl` | Required | Data plane URL. A missing, invalid or non-HTTPS URL logs an error and the script does not load. |
|
|
255
|
+
| `consentManagement` | None | `{ mapping }` from c15t categories to RudderStack consent IDs. Switches to destination consent mode. |
|
|
256
|
+
| `loadOptions` | `{}` | Third argument to `rudderanalytics.load()`. Use JSON-serializable values only. |
|
|
257
|
+
| `trackPageView` | `true` | Queues `rudderanalytics.page()` before the loader. |
|
|
258
|
+
| `scriptUrl` | `https://cdn.rudderlabs.com/v3/modern/rsa.min.js` | Loader URL override. A non-HTTPS URL throws; a blank value uses the default. |
|
|
261
259
|
|
|
262
260
|
## Loading and revocation
|
|
263
261
|
|
|
@@ -322,8 +320,8 @@ permission before each of your own event calls. The reload does not delete
|
|
|
322
320
|
cookies the vendor already set; see
|
|
323
321
|
[clear on revocation for your framework](./overview.md#vendor-switches-and-cookie-cleanup).
|
|
324
322
|
|
|
325
|
-
The helper
|
|
326
|
-
|
|
323
|
+
The helper lists its vendor by name in the preference dialog, so a visitor can
|
|
324
|
+
turn it off inside an allowed category. See
|
|
327
325
|
[vendor consent for your framework](./overview.md#vendor-switches-and-cookie-cleanup). The
|
|
328
326
|
[consent verification guide](../guides/verify-consent.md) covers navigation,
|
|
329
327
|
expiry and hosting checks.
|
|
@@ -3,21 +3,30 @@ title: Rybbit Analytics
|
|
|
3
3
|
description: Load Rybbit Analytics only after measurement consent with the c15t
|
|
4
4
|
rybbitAnalytics helper, map its tracking options to data attributes, and check
|
|
5
5
|
it in DevTools.
|
|
6
|
+
seoTitle: Rybbit Analytics cookie consent with c15t
|
|
7
|
+
seoDescription: Load Rybbit Analytics, with session replay and web vitals, only
|
|
8
|
+
with measurement consent. Set it up with the c15t rybbitAnalytics helper.
|
|
6
9
|
icon: rybbit-analytics
|
|
7
10
|
group: integrations
|
|
8
11
|
---
|
|
9
12
|
|
|
13
|
+
The c15t `rybbitAnalytics` helper keeps Rybbit Analytics off the page until
|
|
14
|
+
`measurement` has consent. Options such as `sessionReplay` and `webVitals` run
|
|
15
|
+
inside the same script, under the same consent. The helper sends no consent
|
|
16
|
+
signal to Rybbit. If the visitor withdraws consent, c15t removes the script
|
|
17
|
+
element. By default, c15t also reloads the page.
|
|
18
|
+
|
|
10
19
|
## Configure Rybbit Analytics
|
|
11
20
|
|
|
12
21
|
Copy the site ID from your Rybbit tracking snippet. The helper passes it to
|
|
13
22
|
the script as `data-site-id`.
|
|
14
23
|
|
|
15
|
-
| Package manager | Command
|
|
16
|
-
| :-------------- |
|
|
17
|
-
| npm | `npm install @c15t/integrations
|
|
18
|
-
| pnpm | `pnpm add @c15t/integrations
|
|
19
|
-
| yarn | `yarn add @c15t/integrations
|
|
20
|
-
| bun | `bun add @c15t/integrations
|
|
24
|
+
| Package manager | Command |
|
|
25
|
+
| :-------------- | :------------------------------- |
|
|
26
|
+
| npm | `npm install @c15t/integrations` |
|
|
27
|
+
| pnpm | `pnpm add @c15t/integrations` |
|
|
28
|
+
| yarn | `yarn add @c15t/integrations` |
|
|
29
|
+
| bun | `bun add @c15t/integrations` |
|
|
21
30
|
|
|
22
31
|
```ts title="src/consent-scripts.ts"
|
|
23
32
|
import { rybbitAnalytics } from '@c15t/integrations/rybbit-analytics';
|
|
@@ -32,51 +41,41 @@ endpoint, policy, styles and consent UI. Remove the vendor's original script,
|
|
|
32
41
|
SDK initializer or tag-manager entry, so the vendor loads only through c15t.
|
|
33
42
|
|
|
34
43
|
The vendor pages put the helper in `src/consent-scripts.ts`. If your framework
|
|
35
|
-
quickstart already
|
|
36
|
-
Next.js guide, add the helper to that array instead of creating a
|
|
44
|
+
quickstart already has a `scripts` array, such as the one in `c15t.config.ts`
|
|
45
|
+
in the Next.js guide, add the helper to that array instead of creating a
|
|
46
|
+
second file.
|
|
37
47
|
The `scripts` export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration
|
|
38
48
|
point for your framework below. These are edits to that provider, not a second
|
|
39
49
|
provider.
|
|
40
50
|
|
|
41
51
|
**Next.js**
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { ConsentRoot } from 'c15t/next';
|
|
47
|
-
import { scripts } from './consent-scripts';
|
|
48
|
-
```
|
|
53
|
+
Add the configuration to `scripts` in `c15t.config.ts`, next to
|
|
54
|
+
`next.config.ts`:
|
|
49
55
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
```ts title="c15t.config.ts"
|
|
57
|
+
import { defineConsentConfig } from 'c15t/next';
|
|
58
|
+
import { scripts } from './src/consent-scripts';
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
<ConsentRoot state={state} config={consentConfig} scripts={scripts}>
|
|
56
|
-
{children}
|
|
57
|
-
</ConsentRoot>
|
|
60
|
+
export default defineConsentConfig({ scripts });
|
|
58
61
|
```
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
Keep the rest of your config, such as `mode` and `routePrefix`, in the
|
|
64
|
+
same call. `ConsentRoot` reads the config in the browser, so the layout
|
|
65
|
+
keeps passing only `state`. App Router, Pages Router and static export all
|
|
66
|
+
read the same file. See
|
|
63
67
|
[Next.js scripts and embeds](https://c15t.com/docs/frameworks/next/scripts).
|
|
64
68
|
|
|
65
69
|
**TanStack Start**
|
|
66
70
|
|
|
67
71
|
Import the configuration into your root route and pass it to the existing
|
|
68
|
-
`ConsentRoot` as a top-level prop. Keep the loader
|
|
69
|
-
|
|
72
|
+
`ConsentRoot` as a top-level prop. Keep the loader from the
|
|
73
|
+
[TanStack Start quickstart](https://c15t.com/docs/frameworks/tanstack-start/quickstart):
|
|
70
74
|
|
|
71
75
|
```tsx title="src/routes/__root.tsx"
|
|
72
76
|
import { scripts } from '../consent-scripts';
|
|
73
77
|
|
|
74
|
-
<ConsentRoot
|
|
75
|
-
state={consent}
|
|
76
|
-
backendURL={backendURL}
|
|
77
|
-
initRoute={false}
|
|
78
|
-
scripts={scripts}
|
|
79
|
-
>
|
|
78
|
+
<ConsentRoot state={consent} scripts={scripts}>
|
|
80
79
|
```
|
|
81
80
|
|
|
82
81
|
Import vendor helpers in the root route module, not in a server function.
|
|
@@ -95,8 +94,8 @@ import { scripts } from './consent-scripts';
|
|
|
95
94
|
<ConsentProvider options={{ mode, scripts }}>
|
|
96
95
|
```
|
|
97
96
|
|
|
98
|
-
`mode` is the `
|
|
99
|
-
|
|
97
|
+
`mode` is the `manifest()` value from the
|
|
98
|
+
[React quickstart](../frameworks/react/quickstart.md). Keep the banner,
|
|
100
99
|
dialog and preferences link inside the provider. See
|
|
101
100
|
[React scripts and embeds](../frameworks/react/scripts.md).
|
|
102
101
|
|
|
@@ -125,15 +124,16 @@ callbacks. Write the vendor IDs into `consent-scripts.ts`. See
|
|
|
125
124
|
Pass the scripts to the existing `c15tVue` plugin call in `src/main.ts`:
|
|
126
125
|
|
|
127
126
|
```ts title="src/main.ts"
|
|
127
|
+
import { c15tVue, manifest } from 'c15t/vue/vue-plugin';
|
|
128
128
|
import { scripts } from './consent-scripts';
|
|
129
129
|
|
|
130
130
|
app.use(c15tVue, {
|
|
131
|
-
|
|
131
|
+
mode: manifest(),
|
|
132
132
|
scripts,
|
|
133
133
|
});
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
Keep your existing
|
|
136
|
+
Keep your existing `mode` and other options. The plugin starts one
|
|
137
137
|
script loader when the app mounts, after it has applied the visitor's stored
|
|
138
138
|
choice. Do not also call `createScriptLoader` from a component. See
|
|
139
139
|
[Vue scripts and embeds](https://c15t.com/docs/frameworks/vue/scripts).
|
|
@@ -141,12 +141,11 @@ choice. Do not also call `createScriptLoader` from a component. See
|
|
|
141
141
|
**Astro**
|
|
142
142
|
|
|
143
143
|
Add the scripts to the client entrypoint from the
|
|
144
|
-
[Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart),
|
|
145
|
-
integration
|
|
146
|
-
|
|
147
|
-
already exports scripts, combine the two arrays.
|
|
144
|
+
[Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart), `src/c15t.client.ts`,
|
|
145
|
+
which the integration finds on its own. Keep `astro.config.mjs` as it is.
|
|
146
|
+
If the module already exports scripts, combine the two arrays.
|
|
148
147
|
|
|
149
|
-
```ts title="src/
|
|
148
|
+
```ts title="src/c15t.client.ts"
|
|
150
149
|
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
151
150
|
import { scripts } from './consent-scripts';
|
|
152
151
|
|
|
@@ -166,15 +165,13 @@ pass them as a top-level prop:
|
|
|
166
165
|
|
|
167
166
|
```svelte title="src/App.svelte"
|
|
168
167
|
<script lang="ts">
|
|
169
|
-
import {
|
|
168
|
+
import { ConsentProvider, manifest } from '@c15t/svelte';
|
|
170
169
|
import { scripts } from './consent-scripts';
|
|
171
|
-
|
|
172
|
-
const mode = hosted({ url: 'https://your-project.inth.app' });
|
|
173
170
|
</script>
|
|
174
171
|
|
|
175
|
-
<
|
|
172
|
+
<ConsentProvider mode={manifest()} {scripts}>
|
|
176
173
|
<!-- Keep your application, consent UI and preferences link here. -->
|
|
177
|
-
</
|
|
174
|
+
</ConsentProvider>
|
|
178
175
|
```
|
|
179
176
|
|
|
180
177
|
Retain the styles and consent UI from the [Svelte quickstart](https://c15t.com/docs/frameworks/svelte/quickstart).
|
|
@@ -182,22 +179,21 @@ The provider owns the loader and disposes it on unmount.
|
|
|
182
179
|
|
|
183
180
|
**SvelteKit**
|
|
184
181
|
|
|
185
|
-
Add the scripts to the existing root layout
|
|
186
|
-
and
|
|
182
|
+
Add the scripts to the existing `ConsentRoot` in the root layout. Keep the
|
|
183
|
+
handle and the layout load from the [SvelteKit quickstart](https://c15t.com/docs/frameworks/sveltekit/quickstart).
|
|
187
184
|
|
|
188
185
|
```svelte title="src/routes/+layout.svelte"
|
|
189
186
|
<script lang="ts">
|
|
190
|
-
import {
|
|
187
|
+
import { ConsentRoot } from '@c15t/svelte';
|
|
191
188
|
import { scripts } from '../consent-scripts';
|
|
192
189
|
|
|
193
190
|
let { children, data } = $props();
|
|
194
|
-
const mode = hosted({ url: 'https://your-project.inth.app' });
|
|
195
191
|
</script>
|
|
196
192
|
|
|
197
|
-
<
|
|
193
|
+
<ConsentRoot state={data.consent} {scripts}>
|
|
198
194
|
{@render children()}
|
|
199
195
|
<!-- Keep your consent UI and preferences link here. -->
|
|
200
|
-
</
|
|
196
|
+
</ConsentRoot>
|
|
201
197
|
```
|
|
202
198
|
|
|
203
199
|
Import vendor helpers in the layout component, not in `+layout.server.ts`:
|
|
@@ -224,20 +220,19 @@ to a pasted snippet. See [HTML scripts](https://c15t.com/docs/frameworks/html/sc
|
|
|
224
220
|
|
|
225
221
|
**JavaScript**
|
|
226
222
|
|
|
227
|
-
Pass the scripts to `init()` from `@c15t/browser`, next to your
|
|
228
|
-
URL:
|
|
223
|
+
Pass the scripts to `init()` from `@c15t/browser`, next to your mode:
|
|
229
224
|
|
|
230
225
|
```ts
|
|
231
|
-
import { init } from '@c15t/browser';
|
|
226
|
+
import { init, manifest } from '@c15t/browser';
|
|
232
227
|
import { scripts } from './consent-scripts';
|
|
233
228
|
|
|
234
229
|
const consent = init({
|
|
235
|
-
|
|
230
|
+
mode: manifest(),
|
|
236
231
|
scripts,
|
|
237
232
|
});
|
|
238
233
|
```
|
|
239
234
|
|
|
240
|
-
Keep the
|
|
235
|
+
Keep the mode from your quickstart. With
|
|
241
236
|
`createConsentRuntime` from `c15t/runtime`, pass `scripts` to it instead.
|
|
242
237
|
A kernel you create yourself needs a loader from
|
|
243
238
|
`c15t/modules/script-loader`. Attach one loader per kernel. See
|
|
@@ -248,22 +243,22 @@ A kernel you create yourself needs a loader from
|
|
|
248
243
|
Boolean options become `'true'` or `'false'` data attributes. An option you
|
|
249
244
|
leave unset adds no attribute, so Rybbit uses its own default.
|
|
250
245
|
|
|
251
|
-
| Option | Default | Behavior
|
|
252
|
-
| ------------------- | ------------------------------------- |
|
|
253
|
-
| `siteId` | Required | Site ID as a string or number, set as `data-site-id`. Empty or whitespace-only values
|
|
254
|
-
| `autoTrackPageview` | None | Automatic page views, set as `data-auto-track-pageview`.
|
|
255
|
-
| `trackSpa` | None | Client-side route tracking, set as `data-track-spa`.
|
|
256
|
-
| `trackQuery` | None | Query strings in tracked URLs, set as `data-track-query`.
|
|
257
|
-
| `trackOutbound` | None | Outbound link clicks, set as `data-track-outbound`.
|
|
258
|
-
| `trackErrors` | None | JavaScript errors, set as `data-track-errors`.
|
|
259
|
-
| `sessionReplay` | None | Session replay, set as `data-session-replay`.
|
|
260
|
-
| `webVitals` | None | Web Vitals, set as `data-web-vitals`.
|
|
261
|
-
| `skipPatterns` | None | URL patterns to skip, written as a JSON array to `data-skip-patterns`.
|
|
262
|
-
| `maskPatterns` | None | URL patterns to mask, written as a JSON array to `data-mask-patterns`.
|
|
263
|
-
| `debounce` | None | Page view debounce interval, set as `data-debounce`.
|
|
264
|
-
| `apiKey` | None | Tracking API key, set as `data-api-key`. The key is visible in the page source.
|
|
265
|
-
| `analyticsHost` | None | Self-hosted Rybbit host. The helper loads `<analyticsHost>/script.js`.
|
|
266
|
-
| `scriptUrl` | `https://app.rybbit.io/api/script.js` | Loader URL override. Takes precedence over `analyticsHost`. Blank values are ignored.
|
|
246
|
+
| Option | Default | Behavior |
|
|
247
|
+
| ------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
248
|
+
| `siteId` | Required | Site ID as a string or number, set as `data-site-id`. Empty or whitespace-only values log an error and the script does not load. |
|
|
249
|
+
| `autoTrackPageview` | None | Automatic page views, set as `data-auto-track-pageview`. |
|
|
250
|
+
| `trackSpa` | None | Client-side route tracking, set as `data-track-spa`. |
|
|
251
|
+
| `trackQuery` | None | Query strings in tracked URLs, set as `data-track-query`. |
|
|
252
|
+
| `trackOutbound` | None | Outbound link clicks, set as `data-track-outbound`. |
|
|
253
|
+
| `trackErrors` | None | JavaScript errors, set as `data-track-errors`. |
|
|
254
|
+
| `sessionReplay` | None | Session replay, set as `data-session-replay`. |
|
|
255
|
+
| `webVitals` | None | Web Vitals, set as `data-web-vitals`. |
|
|
256
|
+
| `skipPatterns` | None | URL patterns to skip, written as a JSON array to `data-skip-patterns`. |
|
|
257
|
+
| `maskPatterns` | None | URL patterns to mask, written as a JSON array to `data-mask-patterns`. |
|
|
258
|
+
| `debounce` | None | Page view debounce interval, set as `data-debounce`. |
|
|
259
|
+
| `apiKey` | None | Tracking API key, set as `data-api-key`. The key is visible in the page source. |
|
|
260
|
+
| `analyticsHost` | None | Self-hosted Rybbit host. The helper loads `<analyticsHost>/script.js`. |
|
|
261
|
+
| `scriptUrl` | `https://app.rybbit.io/api/script.js` | Loader URL override. Takes precedence over `analyticsHost`. Blank values are ignored. |
|
|
267
262
|
|
|
268
263
|
## Loading and revocation
|
|
269
264
|
|
|
@@ -300,8 +295,8 @@ permission before each of your own event calls. The reload does not delete
|
|
|
300
295
|
cookies the vendor already set; see
|
|
301
296
|
[clear on revocation for your framework](./overview.md#vendor-switches-and-cookie-cleanup).
|
|
302
297
|
|
|
303
|
-
The helper
|
|
304
|
-
|
|
298
|
+
The helper lists its vendor by name in the preference dialog, so a visitor can
|
|
299
|
+
turn it off inside an allowed category. See
|
|
305
300
|
[vendor consent for your framework](./overview.md#vendor-switches-and-cookie-cleanup). The
|
|
306
301
|
[consent verification guide](../guides/verify-consent.md) covers navigation,
|
|
307
302
|
expiry and hosting checks.
|