@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,323 @@
1
+ ---
2
+ title: Shopify
3
+ description: Send c15t consent to Shopify's Customer Privacy API from a Hydrogen
4
+ storefront, so Shopify analytics wait for the visitor's choice and follow each
5
+ later change.
6
+ seoTitle: Shopify Hydrogen cookie consent with c15t
7
+ seoDescription: Use your c15t banner as a custom consent banner in Shopify
8
+ Hydrogen. The c15t Shopify bridge passes each choice to Shopify's Customer
9
+ Privacy API.
10
+ group: integrations
11
+ ---
12
+
13
+ The c15t Shopify bridge sends each consent choice to Shopify's Customer
14
+ Privacy API. Shopify's analytics, and the apps and pixels that read that API,
15
+ then follow your c15t banner instead of Shopify's own. The bridge loads no
16
+ script. Hydrogen's `ShopifyScripts` loads the Customer Privacy API, and the
17
+ bridge's `setup` function holds Hydrogen's analytics events until Shopify has
18
+ the visitor's choice.
19
+
20
+ The [Shopify example](https://github.com/c15t/c15t/tree/v3/examples/shopify-nextjs)
21
+ runs the code on this page in a Next.js app against mock.shop.
22
+
23
+ ## Add the bridge
24
+
25
+ Set up c15t with the [Next.js quickstart](https://c15t.com/docs/frameworks/next/quickstart)
26
+ first, then install the integrations package:
27
+
28
+ | Package manager | Command |
29
+ | :-------------- | :------------------------------- |
30
+ | npm | `npm install @c15t/integrations` |
31
+ | pnpm | `pnpm add @c15t/integrations` |
32
+ | yarn | `yarn add @c15t/integrations` |
33
+ | bun | `bun add @c15t/integrations` |
34
+
35
+ Create the bridge once per page and pass its `setup` to `ShopifyScripts` with
36
+ `mode: 'custom-banner'`. A second component feeds the bridge each c15t
37
+ snapshot:
38
+
39
+ ```tsx title="components/shopify-analytics.tsx"
40
+ 'use client';
41
+
42
+ import { createShopifyCustomerPrivacy } from '@c15t/integrations/shopify';
43
+ import type { ShopifyScriptsI18n, ShopifyScriptsShop } from '@shopify/hydrogen';
44
+ import { ShopifyScripts } from '@shopify/hydrogen/react';
45
+ import { useSnapshot } from 'c15t/next';
46
+ import { useRouter } from 'next/navigation';
47
+ import { useEffect } from 'react';
48
+
49
+ // One bridge per page. It sends each c15t choice to Shopify's Customer
50
+ // Privacy API, and its `setup` holds Hydrogen's analytics until Shopify has
51
+ // the visitor's choice.
52
+ const shopifyPrivacy = createShopifyCustomerPrivacy();
53
+
54
+ /** Hydrogen's scripts and analytics bus. Render it in the document head. */
55
+ export const ShopifyAnalytics = ({
56
+ i18n,
57
+ shop,
58
+ }: {
59
+ i18n: ShopifyScriptsI18n;
60
+ shop: ShopifyScriptsShop;
61
+ }) => {
62
+ const router = useRouter();
63
+ return (
64
+ <ShopifyScripts
65
+ analytics={{ channel: 'headless' }}
66
+ consent={{ mode: 'custom-banner', setup: shopifyPrivacy.setup }}
67
+ i18n={i18n}
68
+ // Shopify's scripts route storefront links through Next's router.
69
+ navigate={(url) => router.push(url)}
70
+ shop={shop}
71
+ />
72
+ );
73
+ };
74
+
75
+ /** Feeds each c15t snapshot to the bridge. Render it inside `ConsentRoot`. */
76
+ export const ShopifyConsentSync = () => {
77
+ const snapshot = useSnapshot();
78
+ useEffect(() => shopifyPrivacy.update(snapshot), [snapshot]);
79
+ return null;
80
+ };
81
+ ```
82
+
83
+ Render `ShopifyAnalytics` in the document head, as Hydrogen requires, with
84
+ your shop's details. Render `ShopifyConsentSync` inside `ConsentRoot`:
85
+
86
+ ```tsx title="app/layout.tsx"
87
+ import {
88
+ ConsentBanner,
89
+ ConsentDialog,
90
+ ConsentDialogLink,
91
+ ConsentRoot,
92
+ } from 'c15t/next';
93
+ import { resolveConsent } from 'c15t/next/server';
94
+ import { connection } from 'next/server';
95
+ import { Suspense } from 'react';
96
+ import type { ReactNode } from 'react';
97
+
98
+ import { PageViewTracker } from '@/components/page-view-tracker';
99
+ import {
100
+ ShopifyAnalytics,
101
+ ShopifyConsentSync,
102
+ } from '@/components/shopify-analytics';
103
+ import { SiteHeader } from '@/components/site-header';
104
+ import { StoreProviders } from '@/components/store-providers';
105
+ import { currency, i18n, shop } from '@/lib/shop';
106
+ import { getCart } from '@/lib/storefront';
107
+
108
+ import './globals.css';
109
+
110
+ const RootLayout = async ({ children }: { children: ReactNode }) => {
111
+ // The cart comes from the visitor's cookie, so every page renders per request.
112
+ await connection();
113
+
114
+ return (
115
+ <html lang="en">
116
+ <head>
117
+ {/* Hydrogen's scripts belong in the head, once per page. */}
118
+ <ShopifyAnalytics i18n={{ ...i18n, currency }} shop={shop} />
119
+ </head>
120
+ <body>
121
+ <ConsentRoot state={resolveConsent()}>
122
+ <ShopifyConsentSync />
123
+ <StoreProviders cart={getCart()}>
124
+ <SiteHeader />
125
+ <Suspense fallback={null}>
126
+ <PageViewTracker />
127
+ </Suspense>
128
+ {children}
129
+ </StoreProviders>
130
+ <ConsentBanner />
131
+ <ConsentDialog />
132
+ <footer className="site-footer">
133
+ <ConsentDialogLink>Privacy settings</ConsentDialogLink>
134
+ </footer>
135
+ </ConsentRoot>
136
+ </body>
137
+ </html>
138
+ );
139
+ };
140
+
141
+ export default RootLayout;
142
+ ```
143
+
144
+ ## Declare the categories
145
+
146
+ c15t's dialog offers only the categories that something on the page uses.
147
+ Shopify's scripts load through `ShopifyScripts`, not through c15t's `scripts`
148
+ option, so c15t cannot find them. Declare the categories the bridge maps, or
149
+ the dialog shows only Necessary and Shopify receives a denial for everything:
150
+
151
+ ```ts title="c15t.config.ts"
152
+ import { defineConsentConfig } from 'c15t/next';
153
+
154
+ export default defineConsentConfig({
155
+ options: {
156
+ // The categories the Shopify bridge maps. Shopify's scripts load through
157
+ // Hydrogen's `ShopifyScripts`, not `scripts`, so c15t can't discover them.
158
+ consentCategories: ['measurement', 'marketing', 'functionality'],
159
+ },
160
+ });
161
+ ```
162
+
163
+ The categories must also be in your policy's scope.
164
+
165
+ ## Serve the Storefront API route
166
+
167
+ The Customer Privacy API saves each choice by posting to the storefront's own
168
+ `/api/<version>/graphql.json`. Hydrogen's `handleShopifyRoutes` serves that
169
+ route, forwards it to your shop and keeps the cookies Shopify sets. In
170
+ Next.js, call it from `proxy.ts`:
171
+
172
+ ```ts title="proxy.ts"
173
+ import {
174
+ createShopifyRequestContext,
175
+ createStorefrontClient,
176
+ handleShopifyRoutes,
177
+ } from '@shopify/hydrogen';
178
+ import { NextResponse } from 'next/server';
179
+ import type { NextRequest } from 'next/server';
180
+
181
+ import { cartHandlers } from '@/lib/cart-handlers';
182
+ import { i18n, storeDomain } from '@/lib/shop';
183
+
184
+ // This store has no customer accounts, so nothing keeps a session.
185
+ const noSession = {
186
+ getSessionItem: () => undefined,
187
+ getSessionOrigin: () => '',
188
+ removeSessionItem: () => undefined,
189
+ setSessionItem: () => undefined,
190
+ };
191
+
192
+ /**
193
+ * Serves Hydrogen's routes: `/api/cart` for the cart, and the Storefront API
194
+ * at `/api/<version>/graphql.json`, where Shopify's Customer Privacy API
195
+ * saves each consent choice.
196
+ */
197
+ export const proxy = (request: NextRequest) => {
198
+ const requestContext = createShopifyRequestContext({ i18n, request });
199
+ const storefrontClient = createStorefrontClient({
200
+ config: { publicStorefrontToken: undefined, storeDomain },
201
+ requestContext,
202
+ type: 'public',
203
+ });
204
+
205
+ const shopifyRoute = handleShopifyRoutes({
206
+ handlers: [cartHandlers],
207
+ request,
208
+ requestContext,
209
+ sessionManager: noSession,
210
+ storefrontClient,
211
+ });
212
+ if (shopifyRoute) {
213
+ return shopifyRoute;
214
+ }
215
+
216
+ const response = NextResponse.next({
217
+ request: { headers: requestContext.getForwardedRequestHeaders() },
218
+ });
219
+ requestContext.applyResponseHeaders(response.headers);
220
+ return response;
221
+ };
222
+
223
+ export const config = {
224
+ matcher: ['/((?!_next/static|_next/image|_next/data|favicon.ico).*)'],
225
+ };
226
+ ```
227
+
228
+ The consent route needs no handlers. The example adds Hydrogen's cart
229
+ handlers for its cart, and its `lib/shop.ts` holds the store domain and
230
+ market. It has no customer accounts, so it passes a session manager that
231
+ stores nothing. Pass your own if your storefront signs customers in.
232
+
233
+ ## How categories map
234
+
235
+ | Shopify consent | c15t category |
236
+ | --------------- | --------------- |
237
+ | `analytics` | `measurement` |
238
+ | `marketing` | `marketing` |
239
+ | `preferences` | `functionality` |
240
+ | `sale_of_data` | `marketing` |
241
+
242
+ Each Shopify value is `true` only while its c15t category is allowed in the
243
+ effective permissions, which include policy restrictions. Pass `categories`
244
+ to change the mapping:
245
+
246
+ ```ts
247
+ const shopifyPrivacy = createShopifyCustomerPrivacy({
248
+ categories: { sale_of_data: 'measurement' },
249
+ });
250
+ ```
251
+
252
+ `toShopifyConsent(permissions, categories)` returns the same four values for
253
+ your own code.
254
+
255
+ ## When the bridge sends
256
+
257
+ Shopify records consent only when the visitor makes a choice, so the bridge
258
+ sends nothing until then, or while the policy is pending.
259
+
260
+ * **Opt-in or IAB policy:** `setup` waits until the visitor answers the
261
+ banner, including with Reject All, so Hydrogen holds events until then.
262
+ * **Opt-out policy:** `setup` resolves without recording a choice, and
263
+ Shopify applies its region defaults, including Global Privacy Control,
264
+ until the visitor saves a choice in c15t. A stale grant is the exception,
265
+ below.
266
+
267
+ After the first choice, the bridge sends each change once. When a visitor
268
+ revokes a category, c15t reloads the page and the bridge sends the stored
269
+ choice on load.
270
+
271
+ While the visitor has no current choice, Shopify may still hold grants from
272
+ an earlier one, for example after that choice expired or a policy change
273
+ asks again. If c15t now denies any of them, the bridge sends `false` for
274
+ those grants only, so Shopify keeps the other signals, including unset ones.
275
+ It counts grants the bridge sent and each `yes` from Shopify's
276
+ `currentVisitorConsent()`, and sends the revocation again if Shopify reports
277
+ a dropped grant again, for example after another tab granted it. If that
278
+ function isn't available, it assumes a choice c15t stored may have granted
279
+ anything. Under an opt-in or IAB policy, Hydrogen keeps holding events until
280
+ the visitor answers. Under opt-out, `setup` resolves once Shopify accepts the
281
+ revocation.
282
+
283
+ If the Customer Privacy API hasn't loaded yet, the bridge waits for
284
+ Shopify's `consentTrackingApiLoaded` or `shopifyCustomerPrivacyApiLoaded`
285
+ event.
286
+
287
+ `setup` resolves once Shopify has accepted the visitor's latest choice, and
288
+ Hydrogen then delivers the events that choice allows. If the visitor changes
289
+ their mind while the first request is in flight, `setup` waits for the newer
290
+ one. It never rejects, because Hydrogen stops calling `setup` after a
291
+ rejection. When Shopify rejects a choice, the bridge keeps events blocked and
292
+ sends it again after 1, 2 and 4 seconds, then on the next update. If the
293
+ policy turns pending meanwhile, the bridge drops those retries.
294
+
295
+ ## Options
296
+
297
+ | Option | Default | Behavior |
298
+ | ------------ | ------------------- | -------------------------------------------------------------------------------------------------------- |
299
+ | `categories` | The table above | Overrides the c15t category for any of the four Shopify values. |
300
+ | `onSync` | None | Called with what Shopify accepted: the four values for a choice, or the dropped grants for a revocation. |
301
+ | `onError` | Logs to the console | Called when Shopify rejects a choice or `onSync` throws. |
302
+
303
+ The bridge returns `update(snapshot)`, `connect(source)` and `setup()`.
304
+ `connect` follows anything with `getSnapshot` and `subscribe`, such as a c15t
305
+ kernel, and returns a function that stops following it.
306
+
307
+ ## Limits
308
+
309
+ * Checkout runs on Shopify's domain and doesn't render your storefront code.
310
+ Shopify reads the stored choice there.
311
+ * Shopify's analytics need a real shop. mock.shop accepts the consent request
312
+ but sets no consent cookie, so `currentVisitorConsent()` stays empty.
313
+ * The bridge maps categories only; it doesn't translate IAB TCF choices.
314
+
315
+ ## Verify the bridge
316
+
317
+ 1. In a private window with an opt-in policy, load the page. The network panel
318
+ shows no `graphql.json` request with `visitorConsent`.
319
+ 2. Click Reject All. One request goes out with every value `false`.
320
+ 3. Open the dialog, allow Marketing and save. One request goes out with
321
+ `marketing` and `saleOfData` set to `true`.
322
+ 4. On a real shop, run `window.Shopify.customerPrivacy.currentVisitorConsent()`
323
+ in the console and check it matches your choice.
@@ -163,7 +163,7 @@ pass them as a top-level prop:
163
163
 
164
164
  ```svelte title="src/App.svelte"
165
165
  <script lang="ts">
166
- import { ConsentProvider, manifest } from '@c15t/svelte';
166
+ import { ConsentProvider, manifest } from 'c15t/svelte';
167
167
  import { scripts } from './consent-scripts';
168
168
  </script>
169
169
 
@@ -182,7 +182,7 @@ handle and the layout load from the [SvelteKit quickstart](https://c15t.com/docs
182
182
 
183
183
  ```svelte title="src/routes/+layout.svelte"
184
184
  <script lang="ts">
185
- import { ConsentRoot } from '@c15t/svelte';
185
+ import { ConsentRoot } from 'c15t/svelte';
186
186
  import { scripts } from '../consent-scripts';
187
187
 
188
188
  let { children, data } = $props();
@@ -0,0 +1,345 @@
1
+ ---
2
+ title: Statable
3
+ description: Load Statable analytics after measurement consent with the c15t
4
+ statableAnalytics helper, configure its ingestion endpoint, and verify
5
+ requests and browser storage.
6
+ seoTitle: Statable cookie consent with c15t
7
+ seoDescription: Keep the Statable tracker off your page until measurement
8
+ consent. Configure the site ID, check browser storage, and stop tracking on
9
+ consent withdrawal.
10
+ icon: chart-line
11
+ group: integrations
12
+ ---
13
+
14
+ Statable describes its web analytics as cookieless. The c15t
15
+ `statableAnalytics` helper still waits until the `measurement` category is
16
+ allowed before it loads Statable's tracker, so no request reaches Statable
17
+ before then.
18
+
19
+ Statable has no stop API. When the visitor withdraws, c15t reloads the page by
20
+ default, and the reload stops the running tracker.
21
+
22
+ ## Configure Statable
23
+
24
+ Copy the numeric site ID from **Site settings > Tracking Code** in Statable,
25
+ and replace `12345` in the example with it. This helper uses the standalone
26
+ `/js/<siteId>/s.js` tracker, which Statable offers on paid plans. The Hobby
27
+ plan bundles tracking inside a widget with a different loader, which this
28
+ helper doesn't support.
29
+
30
+ Delete any existing Statable script tag or tag manager copy, so it can't load
31
+ outside c15t.
32
+
33
+ | Package manager | Command |
34
+ | :-------------- | :------------------------------- |
35
+ | npm | `npm install @c15t/integrations` |
36
+ | pnpm | `pnpm add @c15t/integrations` |
37
+ | yarn | `yarn add @c15t/integrations` |
38
+ | bun | `bun add @c15t/integrations` |
39
+
40
+ ```ts title="src/consent-scripts.ts"
41
+ import { statableAnalytics } from '@c15t/integrations/statable-analytics';
42
+
43
+ export const scripts = [statableAnalytics({ siteId: '12345' })];
44
+ ```
45
+
46
+ ## Register the scripts
47
+
48
+ Complete your [framework quickstart](https://c15t.com/docs/frameworks) first. Keep its Inth
49
+ endpoint, policy, styles and consent UI. Remove the vendor's original script,
50
+ SDK initializer or tag-manager entry, so the vendor loads only through c15t.
51
+
52
+ The vendor pages put the helper in `src/consent-scripts.ts`. If your framework
53
+ quickstart already has a `scripts` array, such as the one in `c15t.config.ts`
54
+ in the Next.js guide, add the helper to that array instead of creating a
55
+ second file.
56
+ The `scripts` export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration
57
+ point for your framework below. These are edits to that provider, not a second
58
+ provider.
59
+
60
+ **Next.js**
61
+
62
+ Add the configuration to `scripts` in `c15t.config.ts`, next to
63
+ `next.config.ts`:
64
+
65
+ ```ts title="c15t.config.ts"
66
+ import { defineConsentConfig } from 'c15t/next';
67
+ import { scripts } from './src/consent-scripts';
68
+
69
+ export default defineConsentConfig({ scripts });
70
+ ```
71
+
72
+ Keep the rest of your config, such as `mode` and `routePrefix`, in the
73
+ same call. `ConsentRoot` reads the config in the browser, so the layout
74
+ keeps passing only `state`. App Router, Pages Router and static export all
75
+ read the same file. See
76
+ [Next.js scripts and embeds](https://c15t.com/docs/frameworks/next/scripts).
77
+
78
+ **TanStack Start**
79
+
80
+ Import the configuration into your root route and pass it to the existing
81
+ `ConsentRoot` as a top-level prop. Keep the loader from the
82
+ [TanStack Start quickstart](https://c15t.com/docs/frameworks/tanstack-start/quickstart):
83
+
84
+ ```tsx title="src/routes/__root.tsx"
85
+ import { scripts } from '../consent-scripts';
86
+
87
+ <ConsentRoot state={consent} scripts={scripts}>
88
+ ```
89
+
90
+ Import vendor helpers in the root route module, not in a server function.
91
+ A server function's return value must be serializable, and script
92
+ configurations carry callbacks. See
93
+ [TanStack Start scripts](https://c15t.com/docs/frameworks/tanstack-start/scripts).
94
+
95
+ **React**
96
+
97
+ Add the configuration to the existing `ConsentProvider` options, next to
98
+ `mode`:
99
+
100
+ ```tsx title="src/consent.tsx"
101
+ import { scripts } from './consent-scripts';
102
+
103
+ <ConsentProvider options={{ mode, scripts }}>
104
+ ```
105
+
106
+ `mode` is the `manifest()` value from the
107
+ [React quickstart](../frameworks/react/quickstart.md). Keep the banner,
108
+ dialog and preferences link inside the provider. See
109
+ [React scripts and embeds](../frameworks/react/scripts.md).
110
+
111
+ **Nuxt**
112
+
113
+ Register the scripts under the `c15t` key in `app/app.config.ts`. Adjust the
114
+ relative import to where you created `consent-scripts.ts`:
115
+
116
+ ```ts title="app/app.config.ts"
117
+ import { scripts } from '../src/consent-scripts';
118
+
119
+ export default defineAppConfig({
120
+ c15t: { scripts },
121
+ });
122
+ ```
123
+
124
+ The Nuxt module merges this over its options in `nuxt.config.ts` and starts
125
+ one script loader in the browser after hydration, once it has applied the
126
+ visitor's stored choice and privacy signals. Keep `scripts` out of
127
+ `nuxt.config.ts`, which reaches the browser as JSON and drops the vendor
128
+ callbacks. Write the vendor IDs into `consent-scripts.ts`. See
129
+ [Nuxt scripts and embeds](https://c15t.com/docs/frameworks/nuxt/scripts).
130
+
131
+ **Vue**
132
+
133
+ Pass the scripts to the existing `c15tVue` plugin call in `src/main.ts`:
134
+
135
+ ```ts title="src/main.ts"
136
+ import { c15tVue, manifest } from 'c15t/vue/vue-plugin';
137
+ import { scripts } from './consent-scripts';
138
+
139
+ app.use(c15tVue, {
140
+ mode: manifest(),
141
+ scripts,
142
+ });
143
+ ```
144
+
145
+ Keep your existing `mode` and other options. The plugin starts one
146
+ script loader when the app mounts, after it has applied the visitor's stored
147
+ choice. Do not also call `createScriptLoader` from a component. See
148
+ [Vue scripts and embeds](https://c15t.com/docs/frameworks/vue/scripts).
149
+
150
+ **Astro**
151
+
152
+ Add the scripts to the client entrypoint from the
153
+ [Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart), `src/c15t.client.ts`,
154
+ which the integration finds on its own. Keep `astro.config.mjs` as it is.
155
+ If the module already exports scripts, combine the two arrays.
156
+
157
+ ```ts title="src/c15t.client.ts"
158
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
159
+ import { scripts } from './consent-scripts';
160
+
161
+ export default { scripts } satisfies C15tClientOptionsExtension;
162
+ ```
163
+
164
+ Vendor helpers contain callbacks, and the integration options in
165
+ `astro.config.mjs` are serialized into the page, so do not put helpers in
166
+ the integration's `scripts` option. The integration passes the client
167
+ entrypoint to the one runtime every page shares, including across
168
+ `ClientRouter` navigation.
169
+
170
+ **Svelte**
171
+
172
+ Import the scripts in the component that owns your existing provider and
173
+ pass them as a top-level prop:
174
+
175
+ ```svelte title="src/App.svelte"
176
+ <script lang="ts">
177
+ import { ConsentProvider, manifest } from 'c15t/svelte';
178
+ import { scripts } from './consent-scripts';
179
+ </script>
180
+
181
+ <ConsentProvider mode={manifest()} {scripts}>
182
+ <!-- Keep your application, consent UI and preferences link here. -->
183
+ </ConsentProvider>
184
+ ```
185
+
186
+ Retain the styles and consent UI from the [Svelte quickstart](https://c15t.com/docs/frameworks/svelte/quickstart).
187
+ The provider owns the loader and disposes it on unmount.
188
+
189
+ **SvelteKit**
190
+
191
+ Add the scripts to the existing `ConsentRoot` in the root layout. Keep the
192
+ handle and the layout load from the [SvelteKit quickstart](https://c15t.com/docs/frameworks/sveltekit/quickstart).
193
+
194
+ ```svelte title="src/routes/+layout.svelte"
195
+ <script lang="ts">
196
+ import { ConsentRoot } from 'c15t/svelte';
197
+ import { scripts } from '../consent-scripts';
198
+
199
+ let { children, data } = $props();
200
+ </script>
201
+
202
+ <ConsentRoot state={data.consent} {scripts}>
203
+ {@render children()}
204
+ <!-- Keep your consent UI and preferences link here. -->
205
+ </ConsentRoot>
206
+ ```
207
+
208
+ Import vendor helpers in the layout component, not in `+layout.server.ts`:
209
+ a server load cannot send functions to the browser. Prerendered, static and
210
+ SPA-mode pages use the same `scripts` prop. If you pass an externally owned
211
+ `runtime` to the provider, register scripts when creating that runtime instead.
212
+
213
+ **HTML**
214
+
215
+ The helpers in `@c15t/integrations` are ES modules that need a bundler. On a
216
+ page that loads the c15t script tag, paste the vendor's own snippet instead
217
+ and keep it inert until its category is allowed:
218
+
219
+ ```html
220
+ <script type="text/plain" data-c15t-category="measurement">
221
+ // The vendor's snippet, unchanged
222
+ </script>
223
+ ```
224
+
225
+ Use the category this guide names for the vendor. c15t runs the snippet
226
+ once that category is allowed, and reloads the page when the visitor
227
+ withdraws it. Helper options on this page, such as `loadMode`, do not apply
228
+ to a pasted snippet. See [HTML scripts](https://c15t.com/docs/frameworks/html/scripts).
229
+
230
+ **JavaScript**
231
+
232
+ Pass the scripts to `init()` from `@c15t/browser`, next to your mode:
233
+
234
+ ```ts
235
+ import { init, manifest } from '@c15t/browser';
236
+ import { scripts } from './consent-scripts';
237
+
238
+ const consent = init({
239
+ mode: manifest(),
240
+ scripts,
241
+ });
242
+ ```
243
+
244
+ Keep the mode from your quickstart. With
245
+ `createConsentRuntime` from `c15t/runtime`, pass `scripts` to it instead.
246
+ A kernel you create yourself needs a loader from
247
+ `c15t/modules/script-loader`. Attach one loader per kernel. See
248
+ [JavaScript scripts](https://c15t.com/docs/frameworks/javascript/scripts).
249
+
250
+ ## Options
251
+
252
+ | Option | Default | Behavior |
253
+ | ------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
254
+ | `siteId` | Required | Positive integer as a string or number. Trimmed. If it's missing, blank, fractional, negative, non-decimal or above the safe integer limit, c15t logs an error and never loads the tracker. |
255
+ | `scriptUrl` | `https://statable.com/js/{siteId}/s.js` | Loader URL override. Each `{siteId}` is replaced with the site ID. A blank value uses the default. |
256
+ | `trackingApi` | Loader origin plus `/api/event` | Full ingestion endpoint, set as the `data-tracking-api` attribute. The tracker posts to this URL as you give it. A blank value leaves the attribute off, so Statable uses its default. |
257
+
258
+ If you serve the tracker from your own CDN, and that CDN doesn't serve or proxy
259
+ `/api/event`, set `trackingApi` to the full ingestion URL too. Replace both
260
+ example hosts with your own:
261
+
262
+ ```ts title="src/consent-scripts.ts"
263
+ import { statableAnalytics } from '@c15t/integrations/statable-analytics';
264
+
265
+ export const scripts = [
266
+ statableAnalytics({
267
+ scriptUrl: 'https://cdn.example.com/js/{siteId}/s.js',
268
+ siteId: '12345',
269
+ trackingApi: 'https://analytics.example.com/api/event',
270
+ }),
271
+ ];
272
+ ```
273
+
274
+ A custom `scriptUrl` only changes where the browser fetches the tracker. It
275
+ doesn't proxy event requests. Statable uses the visitor's connection to the
276
+ ingestion server for its reports, so check Statable's guidance before you proxy
277
+ collection.
278
+
279
+ ## Loading and revocation
280
+
281
+ When `measurement` is allowed, the helper adds a deferred script with your
282
+ site ID in its path and in the `data-id` attribute. It doesn't create
283
+ `window.statable` or queue events. The tracker sets up `window.statable.t`
284
+ after it loads, and it doesn't replay events sent before then. Check the
285
+ measurement permission and wait for that function before you send an event.
286
+
287
+ The helper calls no Statable consent or stop API. On withdrawal, c15t removes
288
+ the loader element, but the tracker's listeners and timers keep running until
289
+ the page unloads. Keep `reloadOnConsentRevoked` enabled. If you turn it off,
290
+ tracking continues on the current page.
291
+
292
+ ## Cookies and storage
293
+
294
+ Statable says it sets no cookies and stores no persistent visitor ID in the
295
+ browser. Its tracker reads the `analytics_ignore` flag in local storage. It
296
+ sends the full page URL to ingestion, including the query and fragment.
297
+ Statable says it strips both when it processes URLs. Keep sensitive data out of
298
+ URLs anyway.
299
+
300
+ For CSP, allow `https://statable.com` in `script-src` and `connect-src`, or
301
+ your custom loader and ingestion hosts.
302
+
303
+ ## Verify Statable
304
+
305
+ With measurement denied, filter the DevTools Network panel by `statable.com`
306
+ and check that no loader or event request appears. Check Cookies, Local Storage
307
+ and Session Storage in the Application panel for Statable entries. Allowing
308
+ only marketing must leave Statable blocked too.
309
+
310
+ After you allow measurement, expect one `/js/<siteId>/s.js` script element, and
311
+ `typeof window.statable?.t === 'function'`. With a configured site, events post
312
+ to `/api/event` or to your `trackingApi` URL. Statable suppresses collection
313
+ for automated browsers, Do Not Track, Global Privacy Control and the
314
+ `analytics_ignore` flag. A ready API alone doesn't prove that an event reached
315
+ your dashboard.
316
+
317
+ Sources: [tracking script reference](https://statable.com/docs/developers/tracking-script/),
318
+ [JavaScript API reference](https://statable.com/docs/developers/javascript-api/)
319
+ and [privacy policy](https://statable.com/privacy).
320
+
321
+ Test in a private window with an opt-in policy. Open DevTools Network, disable
322
+ the cache and filter by the vendor's domain:
323
+
324
+ 1. Load the page. No request goes to the vendor before you choose.
325
+ 2. Click Reject, then reload. There is still no vendor request.
326
+ 3. Open Privacy settings and allow the helper's category. The vendor script
327
+ loads without a page reload.
328
+ 4. Turn the category off again and save. c15t reloads the page, and the new
329
+ page makes no vendor request.
330
+
331
+ c15t reloads on revocation because removing a script element does not stop
332
+ code that already ran. The vendor's listeners, timers and queued events stay
333
+ alive until the page unloads. If you set `reloadOnConsentRevoked: false`, stop
334
+ the vendor yourself. Register a callback-only script whose `onConsentChange`
335
+ calls the vendor's opt-out API, as shown in
336
+ [custom integrations](./building-integrations.md), and check the
337
+ permission before each of your own event calls. The reload does not delete
338
+ cookies the vendor already set; see
339
+ [clear on revocation for your framework](./overview.md#vendor-switches-and-cookie-cleanup).
340
+
341
+ The helper lists its vendor by name in the preference dialog, so a visitor can
342
+ turn it off inside an allowed category. See
343
+ [vendor consent for your framework](./overview.md#vendor-switches-and-cookie-cleanup). The
344
+ [consent verification guide](../guides/verify-consent.md) covers navigation,
345
+ expiry and hosting checks.