c15t 2.0.4 → 2.1.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 (34) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/index.cjs +2 -2
  3. package/dist/index.js +2 -2
  4. package/dist-types/index.d.ts +1 -1
  5. package/dist-types/version.d.ts +1 -1
  6. package/docs/integrations/ahrefs-analytics.md +224 -0
  7. package/docs/integrations/cloudflare-web-analytics.md +194 -0
  8. package/docs/integrations/crisp.md +214 -0
  9. package/docs/integrations/databuddy.md +136 -65
  10. package/docs/integrations/fathom-analytics.md +221 -0
  11. package/docs/integrations/google-tag-manager.md +84 -15
  12. package/docs/integrations/google-tag.md +89 -8
  13. package/docs/integrations/hotjar.md +211 -0
  14. package/docs/integrations/intercom.md +214 -0
  15. package/docs/integrations/linkedin-insights.md +130 -11
  16. package/docs/integrations/matomo-analytics.md +246 -0
  17. package/docs/integrations/meta-pixel.md +377 -24
  18. package/docs/integrations/microsoft-clarity.md +241 -0
  19. package/docs/integrations/microsoft-uet.md +120 -9
  20. package/docs/integrations/mixpanel-analytics.md +198 -0
  21. package/docs/integrations/overview.md +69 -74
  22. package/docs/integrations/plausible-analytics.md +237 -0
  23. package/docs/integrations/posthog.md +172 -41
  24. package/docs/integrations/promptwatch.md +187 -0
  25. package/docs/integrations/reddit-pixel.md +336 -0
  26. package/docs/integrations/rybbit-analytics.md +222 -0
  27. package/docs/integrations/segment.md +213 -0
  28. package/docs/integrations/snapchat-pixel.md +244 -0
  29. package/docs/integrations/tiktok-pixel.md +88 -10
  30. package/docs/integrations/umami-analytics.md +220 -0
  31. package/docs/integrations/vercel-analytics.md +213 -0
  32. package/docs/integrations/x-pixel.md +99 -10
  33. package/docs/script-loader.md +168 -51
  34. package/package.json +3 -3
@@ -1,39 +1,51 @@
1
1
  ---
2
2
  title: PostHog
3
3
  description: PostHog is an open-source product analytics platform for tracking user behavior, session replays, feature flags, and A/B testing. It supports cookieless tracking, allowing analytics to continue even without cookie consent.
4
- lastModified: 2026-04-08
5
-
4
+ lastModified: 2026-05-12
6
5
  icon: posthog
7
6
  ---
8
- PostHog is an open-source product analytics platform that helps you understand user behavior, track events, and analyze product usage. Unlike traditional analytics tools, PostHog supports both cookieless and cookie-based tracking. This means you can sync c15t with PostHog and continue collecting analytics even when users haven't given consent—PostHog simply operates in cookieless mode until consent is granted.
7
+ PostHog is an open-source product analytics platform that helps you understand user behavior, track events, and analyze product usage. Unlike traditional analytics tools, PostHog supports both cookieless and cookie-based tracking. This means you can sync c15t with PostHog and, when your PostHog project is configured for cookieless tracking, continue collecting privacy-preserving analytics after a user rejects measurement consent.
8
+
9
+ c15t exposes two integration patterns for PostHog. Pick the one that matches how you already load the SDK:
10
+
11
+ * **PostHog SDK** — your app loads `posthog-js` itself; c15t only synchronizes consent. Recommended for most React apps.
12
+ * **PostHog Script** — c15t loads PostHog's array bootstrap as a managed `Script`.
9
13
 
10
- ## PostHog SDK Implementation
14
+ ## Integrate with c15t
11
15
 
12
- This is the recommended approach if you're using the Posthog JS SDK, this is commonly used in React projects.
16
+ ### SDK pattern
13
17
 
14
- ### Adding the PostHog SDK to c15t
18
+ This is the recommended approach if you're using the PostHog JS SDK; it's commonly used in React projects.
15
19
 
16
- 1. **Initialize Posthog** When you initialize posthog make sure to set cookieless\_mode to on\_reject.
20
+ 1. **Enable cookieless tracking in PostHog** Before using cookieless\_mode, enable Cookieless server hash mode in your PostHog project under Project Settings > Web analytics. PostHog ignores cookieless events unless this project setting is enabled.
21
+
22
+ 2. **Initialize PostHog** When you initialize PostHog, set cookieless\_mode to on\_reject. This keeps PostHog from writing cookies or local/session storage until the user grants measurement consent. If the user rejects measurement consent, c15t calls opt\_out\_capturing() and PostHog switches to cookieless capture.
17
23
 
18
24
  ```ts
19
25
  posthog.init("phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", {
20
26
  api_host: "https://eu.i.posthog.com",
21
- defaults: "2025-05-24",
27
+ defaults: "2026-01-30",
22
28
  cookieless_mode: 'on_reject'
23
29
  })
24
30
 
25
- posthog.opt_out_capturing() // Avoids accidental tracking without consent till c15t has loaded
31
+ posthog.opt_out_capturing() // Avoids cookie-based capture until c15t syncs consent
26
32
  ```
27
33
 
28
- 2. **Sync settled consent once, then subscribe to real changes** The recommended PostHog SDK approach uses two phases: run one initial sync after c15t has finished resolving consent, then subscribe to future real preference changes with subscribeToConsentChanges().
34
+ 3. **Sync settled consent once, then subscribe to real changes** The recommended PostHog SDK approach uses two phases: run one initial sync after c15t has finished resolving consent, then subscribe to future real preference changes with subscribeToConsentChanges().
35
+
36
+ With cookieless\_mode: 'on\_reject', denied measurement consent does not mean "no events." It means PostHog records cookieless events without browser persistence. If your product needs denied consent to stop all PostHog event capture, do not use cookieless mode; load or call PostHog only after consent is granted.
29
37
 
38
+ > ⚠️ Warning:
39
+ >
40
+ > Do not use posthog.has\_opted\_in\_capturing() or posthog.has\_opted\_out\_capturing() to decide whether to show your banner. In recent PostHog versions, has\_opted\_in\_capturing() can return true when consent is still pending. Use c15t's consent store as the source of truth, or use PostHog's get\_explicit\_consent\_status() when you specifically need PostHog's stored consent state.
41
+ >
30
42
  > ℹ️ Info:
31
43
  >
32
- > See the integration overview for how to wrap this in your framework (React or Next.js). Pass the callbacks option to your ConsentManagerProvider the same way you would pass scripts.
44
+ > To wrap this in your framework, pass the callbacks option to your ConsentManagerProvider the same way you would pass scripts — see the JavaScript, React, or Next.js script loader guide.
33
45
 
34
46
  ```ts
35
47
  import { getOrCreateConsentRuntime } from 'c15t';
36
- import { posthog } from 'posthog-js';
48
+ import posthog from 'posthog-js';
37
49
 
38
50
  function syncPostHogMeasurementConsent(hasMeasurementConsent: boolean) {
39
51
  if (hasMeasurementConsent) {
@@ -67,47 +79,163 @@ This is the recommended approach if you're using the Posthog JS SDK, this is com
67
79
  >
68
80
  > Avoid using onConsentSet plus manual deduplication for PostHog. subscribeToConsentChanges() already gives you the exact change-only semantics most analytics SDKs need.
69
81
 
70
- ## PostHog Script Implementation
82
+ ### Script helper pattern
71
83
 
72
- If you want to load posthog via a script tag it's recommended to use this approach.
84
+ If you want to load PostHog via a script tag, it's recommended to use this approach.
73
85
 
74
- By default c15t will always load the script regardless of consent. This is because the script has built-in functionality to opt into and out of tracking based on consent.
86
+ 1. **Choose a region and loading mode** The c15t helper loads PostHog's bootstrap script, calls posthog.init() for you, and then synchronizes consent through posthog.opt\_in\_capturing() / posthog.opt\_out\_capturing(). You do not need to call posthog.init() separately.
75
87
 
76
- 1. **Initialize Posthog** This script does not load the Posthog script, it only syncs the consent state with Posthog via the Posthog JS SDK.
88
+ Use region to keep PostHog's API, UI, and bootstrap script hosts aligned. c15t defaults to region: 'eu'; set region: 'us' for PostHog Cloud US. You can still pass apiHost, uiHost, or scriptUrl for self-hosted or proxied setups.
77
89
 
78
- This is due to Posthog's use of cookieless tracking. However, you need to set cookieless\_mode to on\_reject when initializing Posthog.
79
-
80
- ```ts
81
- posthog.init("phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", {
82
- api_host: "https://eu.i.posthog.com",
83
- defaults: "2025-05-24",
84
- // PostHog will not set any cookies until the user has given consent
85
- cookieless_mode: 'on_reject'
86
- })
87
- ```
90
+ The helper supports three loading modes:
88
91
 
89
- 2. **Adding the script to c15t**
92
+ loadMode: 'always' — the backwards-compatible default. PostHog loads immediately and c15t synchronizes measurement consent through PostHog's APIs. Use this when you intentionally want PostHog cookieless behavior after rejection.loadMode: 'after-consent' — PostHog is not requested until measurement consent is granted. This is the recommended GDPR/EU cookie-banner default when your policy requires no PostHog network activity before consent.loadMode: 'disabled' — returns an inert callback-only script with no PostHog network request. Use this for environment flags or temporary rollouts.
90
93
 
91
94
  > ℹ️ Info:
92
95
  >
93
- > See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
96
+ > For a privacy-first GDPR/EU cookie-banner setup, use region: 'eu' with loadMode: 'after-consent'. This keeps PostHog Cloud in the EU region and prevents any PostHog script request until measurement consent is granted.
97
+
98
+ The helper includes these PostHog init defaults:
94
99
 
95
100
  ```ts
96
- import { posthog } from '@c15t/scripts/posthog';
97
-
98
- posthog({
99
- id: 'phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
100
- apiHost: 'https://eu.i.posthog.com',
101
- scriptUrl: 'https://eu-assets.i.posthog.com/static/array.js',
102
- initOptions: {
103
- api_host: 'https://eu.i.posthog.com',
104
- ui_host: 'https://eu.i.posthog.com',
105
- autocapture: false,
106
- person_profiles: 'identified_only',
107
- }
108
- })
101
+ const initOptions = {
102
+ api_host: 'https://eu.i.posthog.com',
103
+ ui_host: 'https://eu.posthog.com',
104
+ defaults: '2026-01-30',
105
+ cookieless_mode: 'on_reject',
106
+ };
109
107
  ```
110
108
 
109
+ You can still override any of these through initOptions. Keep cookieless\_mode: 'on\_reject' when you want PostHog to use cookieless capture after a consent rejection.
110
+
111
+ 2. **Enable cookieless tracking in PostHog** Enable Cookieless server hash mode in your PostHog project under Project Settings > Web analytics when you use loadMode: 'always' and want rejected-consent traffic to be recorded cookielessly. This is required by PostHog before cookieless events are accepted.
112
+
113
+ 3. **Add the script helper**
114
+
115
+ import \{ type ReactNode } from 'react';
116
+ import \{ ConsentManagerProvider } from '@c15t/react';
117
+ import \{ posthog } from '@c15t/scripts/posthog';
118
+
119
+ const scripts = \[
120
+  posthog(\{
121
+  id: 'phc\_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
122
+  region: 'eu',
123
+  loadMode: 'after-consent',
124
+  }),
125
+ ];
126
+
127
+ export function ConsentProvider(\{ children }: \{ children: ReactNode }) \{
128
+  return (
129
+ &#x20;\<ConsentManagerProvider
130
+ &#x20;options=\{\{
131
+ &#x20;mode: 'hosted',
132
+ &#x20;backendURL: 'https\://your-instance.c15t.dev',
133
+ &#x20;scripts,
134
+ &#x20;}}
135
+ &#x20;\>
136
+ &#x20;\{children}
137
+ &#x20;\</ConsentManagerProvider>
138
+ &#x20;);
139
+ }'use client';
140
+
141
+ import \{ type ReactNode } from 'react';
142
+ import \{ ConsentManagerProvider } from '@c15t/nextjs';
143
+ import \{ posthog } from '@c15t/scripts/posthog';
144
+
145
+ const scripts = \[
146
+ &#x20;posthog(\{
147
+ &#x20;id: 'phc\_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
148
+ &#x20;region: 'eu',
149
+ &#x20;loadMode: 'after-consent',
150
+ &#x20;}),
151
+ ];
152
+
153
+ export function ConsentProvider(\{ children }: \{ children: ReactNode }) \{
154
+ &#x20;return (
155
+ &#x20;\<ConsentManagerProvider
156
+ &#x20;options=\{\{
157
+ &#x20;mode: 'hosted',
158
+ &#x20;backendURL: '/api/c15t',
159
+ &#x20;scripts,
160
+ &#x20;}}
161
+ &#x20;\>
162
+ &#x20;\{children}
163
+ &#x20;\</ConsentManagerProvider>
164
+ &#x20;);
165
+ }import \{ getOrCreateConsentRuntime } from 'c15t';
166
+ import \{ posthog } from '@c15t/scripts/posthog';
167
+
168
+ getOrCreateConsentRuntime(\{
169
+ &#x20;mode: 'hosted',
170
+ &#x20;backendURL: 'https\://your-instance.c15t.dev',
171
+ &#x20;scripts: \[
172
+ &#x20;posthog(\{
173
+ &#x20;id: 'phc\_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
174
+ &#x20;region: 'eu',
175
+ &#x20;loadMode: 'after-consent',
176
+ &#x20;}),
177
+ &#x20;],
178
+ });
179
+
180
+ ### No PostHog request before consent
181
+
182
+ If your policy requires PostHog to be completely absent until the user grants measurement consent, use `loadMode: 'after-consent'`:
183
+
184
+ ```ts
185
+ import { posthog } from '@c15t/scripts/posthog';
186
+
187
+ const scripts = [
188
+ posthog({
189
+ id: 'phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
190
+ region: 'eu',
191
+ loadMode: 'after-consent',
192
+ }),
193
+ ];
194
+ ```
195
+
196
+ With this mode, c15t does not inject the PostHog script until `measurement` consent is granted. PostHog cannot record cookieless rejected-consent events because the SDK has not loaded.
197
+
198
+ For PostHog Cloud US, switch the region:
199
+
200
+ ```ts
201
+ posthog({
202
+ id: 'phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
203
+ region: 'us',
204
+ });
205
+ ```
206
+
207
+ ## How c15t loads it
208
+
209
+ * **Category:** `measurement` (Analytics)
210
+ * **SDK pattern:** your app loads `posthog-js`; c15t synchronizes
211
+ measurement consent with PostHog opt-in and opt-out APIs.
212
+ * **Script helper pattern:** by default, c15t loads PostHog on page start with
213
+ [`alwaysLoad`](/docs/frameworks/react/script-loader#always-load), then
214
+ switches PostHog between cookie-based and cookieless capture as consent
215
+ changes. Set `loadMode: 'after-consent'` to block the script request until
216
+ measurement consent is granted.
217
+
218
+ ## Tracking events in your app
219
+
220
+ The behavior depends on which pattern you chose:
221
+
222
+ * **SDK Implementation** — your app loaded `posthog-js` itself, so `posthog.capture(...)` is available once your SDK setup has run. c15t calls `opt_in_capturing()` / `opt_out_capturing()` for you. Pending events before c15t syncs consent may be dropped; after denial, PostHog captures cookieless events.
223
+ * **Script Implementation with `loadMode: 'always'`** — `window.posthog` is defined early. c15t calls `opt_in_capturing()` / `opt_out_capturing()` based on consent. Pending events before the PostHog bootstrap finishes may be dropped; after denial, PostHog captures cookieless events when your PostHog project supports cookieless mode.
224
+ * **Script Implementation with `loadMode: 'after-consent'`** — PostHog is unavailable until measurement consent is granted. Guard `posthog.capture(...)` calls or call them only after consent.
225
+
226
+ > ⚠️ **Warning:**
227
+ > PostHog may start a new session when a user moves between cookieless and cookie-based capture. This can split pre-consent and post-consent activity into separate sessions, which may inflate session counts or affect funnels around the consent boundary. Treat this as a PostHog analytics limitation, not a c15t consent sync issue. See the upstream PostHog session continuity issue.
228
+
229
+ ```ts
230
+ posthog.capture('signup');
231
+ ```
232
+
233
+ You do not need to guard these calls with `useConsentManager().has('measurement')` when cookieless measurement after rejection is acceptable. Add your own guard if denied consent should mean no PostHog event capture at all.
234
+
235
+ ## Consent and privacy
236
+
237
+ PostHog's GDPR guidance recommends using PostHog Cloud EU for robust GDPR compliance, configuring consent clearly, and limiting what personal data is collected. Cookieless mode helps avoid browser persistence when measurement consent is rejected, but it does not replace your own legal basis, consent language, data minimization, IP capture settings, or right-to-be-forgotten process.
238
+
111
239
  ## Types
112
240
 
113
241
  ### PosthogConsentOptions
@@ -115,8 +243,11 @@ By default c15t will always load the script regardless of consent. This is becau
115
243
  |Property|Type|Description|Default|Required|
116
244
  |:--|:--|:--|:--|:--:|
117
245
  |id|string|Your posthog id, begins with 'phc\_'.|-|✅ Required|
246
+ |region|PosthogRegion \|undefined|PostHog Cloud region used to derive hosts when explicit host options are not provided.|'eu'|Optional|
118
247
  |apiHost|string \|undefined|Your posthog api host.|'https\://eu.i.posthog.com'|Optional|
248
+ |uiHost|string \|undefined|Your PostHog UI host. Defaults to the UI host for the selected region or inferred API host region.|-|Optional|
119
249
  |scriptUrl|string \|undefined|The PostHog array loader URL.|-|Optional|
250
+ |loadMode|PosthogLoadMode \|undefined|How c15t should load the PostHog script. Options: \`always\`: load immediately and synchronize consent through PostHog APIs.; \`after-consent\`: wait for measurement consent before loading PostHog.; \`disabled\`: return an inert callback-only script with no network request.|'always'|Optional|
120
251
  |initOptions|Record\<string, unknown> \|undefined|PostHog init options passed to \`posthog.init(...)\`.|-|Optional|
121
252
 
122
253
  ### Script
@@ -0,0 +1,187 @@
1
+ ---
2
+ title: Promptwatch
3
+ description: Promptwatch analyzes traffic on your site for Artificial Intelligence (AI) traffic and usage insights. Data is stored in the EU without user-identifiable information.
4
+ lastModified: 2026-05-10
5
+ icon: promptwatch
6
+ ---
7
+ [Promptwatch](https://promptwatch.com) provides analytics focused on AI-related traffic and usage. The official embed loads a single script with your `data-project-id`. By default, c15t loads this script when `measurement` consent is granted.
8
+
9
+ ## Integrate with c15t
10
+
11
+ **React**
12
+
13
+ ```tsx
14
+ import { type ReactNode } from 'react';
15
+ import { ConsentManagerProvider } from '@c15t/react';
16
+ import { promptwatch } from '@c15t/scripts/promptwatch';
17
+
18
+ const scripts = [
19
+ promptwatch({
20
+ projectId: '7d60345b-27bb-4779-a385-d4fc19ce732c',
21
+ }),
22
+ ];
23
+
24
+ export function ConsentProvider({ children }: { children: ReactNode }) {
25
+ return (
26
+ <ConsentManagerProvider
27
+ options={{
28
+ mode: 'hosted',
29
+ backendURL: 'https://your-instance.c15t.dev',
30
+ scripts,
31
+ }}
32
+ >
33
+ {children}
34
+ </ConsentManagerProvider>
35
+ );
36
+ }
37
+ ```
38
+
39
+ **Next.js**
40
+
41
+ ```tsx
42
+ 'use client';
43
+
44
+ import { type ReactNode } from 'react';
45
+ import { ConsentManagerProvider } from '@c15t/nextjs';
46
+ import { promptwatch } from '@c15t/scripts/promptwatch';
47
+
48
+ const scripts = [
49
+ promptwatch({
50
+ projectId: '7d60345b-27bb-4779-a385-d4fc19ce732c',
51
+ }),
52
+ ];
53
+
54
+ export function ConsentProvider({ children }: { children: ReactNode }) {
55
+ return (
56
+ <ConsentManagerProvider
57
+ options={{
58
+ mode: 'hosted',
59
+ backendURL: '/api/c15t',
60
+ scripts,
61
+ }}
62
+ >
63
+ {children}
64
+ </ConsentManagerProvider>
65
+ );
66
+ }
67
+ ```
68
+
69
+ **JavaScript**
70
+
71
+ ```ts
72
+ import { getOrCreateConsentRuntime } from 'c15t';
73
+ import { promptwatch } from '@c15t/scripts/promptwatch';
74
+
75
+ getOrCreateConsentRuntime({
76
+ mode: 'hosted',
77
+ backendURL: 'https://your-instance.c15t.dev',
78
+ scripts: [
79
+ promptwatch({
80
+ projectId: '7d60345b-27bb-4779-a385-d4fc19ce732c',
81
+ }),
82
+ ],
83
+ });
84
+ ```
85
+
86
+ ## How c15t loads it
87
+
88
+ * **Category:** `measurement` (Analytics)
89
+ * **Loads when:** measurement consent is granted
90
+ * **On revocation:** unloaded - c15t removes the script from the DOM and pauses Promptwatch data collection until consent is granted again.
91
+
92
+ To use a custom loader URL:
93
+
94
+ ```ts
95
+ promptwatch({
96
+ projectId: '7d60345b-27bb-4779-a385-d4fc19ce732c',
97
+ scriptUrl: 'https://cdn.example.com/promptwatch.js',
98
+ });
99
+ ```
100
+
101
+ ## Types
102
+
103
+ ### PromptwatchOptions
104
+
105
+ |Property|Type|Description|Default|Required|
106
+ |:--|:--|:--|:--|:--:|
107
+ |projectId|string|Your Promptwatch project id (UUID from the Promptwatch dashboard).|-|✅ Required|
108
+ |scriptUrl|string \|undefined|Promptwatch client script URL.|-|Optional|
109
+
110
+ ### Script
111
+
112
+ |Property|Type|Description|Default|Required|
113
+ |:--|:--|:--|:--|:--:|
114
+ |id|string|Unique identifier for the script|-|✅ Required|
115
+ |src|string \|undefined|URL of the script to load|-|Optional|
116
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
117
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
118
+ |callbackOnly|boolean \|undefined|Whether this is a callback-only script that doesn't need to load an external resource. When true, no script tag will be added to the DOM, only callbacks will be executed.|false|Optional|
119
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
120
+ |alwaysLoad|boolean \|undefined|Whether the script should always load regardless of consent state. This is useful for scripts like Google Tag Manager or PostHog that manage their own consent state internally. The script will load immediately and never be unloaded based on consent changes. Note: When using this option, you are responsible for ensuring the script itself respects user consent preferences through its own consent management.|false|Optional|
121
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
122
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
123
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
124
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
125
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
126
+ |anonymizeId|boolean \|undefined|Whether to use an anonymized ID for the script element, this helps ensure the script is not blocked by ad blockers|true|Optional|
127
+ |target|"head" \|"body" \|undefined|Where to inject the script element in the DOM. Options: \`'head'\`: Scripts are appended to \`\<head>\` (default); \`'body'\`: Scripts are appended to \`\<body>\`|'head'|Optional|
128
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
129
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
130
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
131
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
132
+ |vendorId|string \|number \|undefined|IAB TCF vendor ID - links script to a registered vendor. When in IAB mode, the script will only load if this vendor has consent. Takes precedence over \`category\` when in IAB mode. Use custom vendor IDs (string or number) to gate non-IAB vendors too.|-|Optional|
133
+ |iabPurposes|number\[] \|undefined|IAB TCF purpose IDs this script requires consent for. When in IAB mode and no vendorId is set, the script will only load if ALL specified purposes have consent.|-|Optional|
134
+ |iabLegIntPurposes|number\[] \|undefined|IAB TCF legitimate interest purpose IDs. These purposes can operate under legitimate interest instead of consent. The script loads if all iabPurposes have consent OR all iabLegIntPurposes have legitimate interest established.|-|Optional|
135
+ |iabSpecialFeatures|number\[] \|undefined|IAB TCF special feature IDs this script requires. Options: 1: Use precise geolocation data; 2: Actively scan device characteristics for identification|-|Optional|
136
+
137
+ #### `onBeforeLoad`
138
+
139
+ Callback executed before the script is loaded
140
+
141
+ |Property|Type|Description|Default|Required|
142
+ |:--|:--|:--|:--|:--:|
143
+ |id|string|The original script ID|-|✅ Required|
144
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
145
+ |hasConsent|boolean|Has consent|-|✅ Required|
146
+ |consents|ConsentState|The current consent state|-|✅ Required|
147
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
148
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
149
+
150
+ #### `onLoad`
151
+
152
+ Callback executed when the script loads successfully
153
+
154
+ |Property|Type|Description|Default|Required|
155
+ |:--|:--|:--|:--|:--:|
156
+ |id|string|The original script ID|-|✅ Required|
157
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
158
+ |hasConsent|boolean|Has consent|-|✅ Required|
159
+ |consents|ConsentState|The current consent state|-|✅ Required|
160
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
161
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
162
+
163
+ #### `onError`
164
+
165
+ Callback executed if the script fails to load
166
+
167
+ |Property|Type|Description|Default|Required|
168
+ |:--|:--|:--|:--|:--:|
169
+ |id|string|The original script ID|-|✅ Required|
170
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
171
+ |hasConsent|boolean|Has consent|-|✅ Required|
172
+ |consents|ConsentState|The current consent state|-|✅ Required|
173
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
174
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
175
+
176
+ #### `onConsentChange`
177
+
178
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
179
+
180
+ |Property|Type|Description|Default|Required|
181
+ |:--|:--|:--|:--|:--:|
182
+ |id|string|The original script ID|-|✅ Required|
183
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
184
+ |hasConsent|boolean|Has consent|-|✅ Required|
185
+ |consents|ConsentState|The current consent state|-|✅ Required|
186
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
187
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|