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
@@ -0,0 +1,241 @@
1
+ ---
2
+ title: Microsoft Clarity
3
+ description: Session replay and behavior analytics with a prebuilt helper that keeps Clarity consent synchronized with c15t measurement state.
4
+ lastModified: 2026-05-10
5
+ icon: microsoft-clarity
6
+ ---
7
+ Microsoft Clarity gives you session recordings, heatmaps, and behavioral insights. The `clarity()` helper sets up Clarity's queue stub, loads the vendor bundle, and keeps Clarity's consent state in sync as c15t measurement consent changes.
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 { clarity } from '@c15t/scripts/microsoft-clarity';
17
+
18
+ const scripts = [
19
+ clarity({
20
+ id: 'abcdef1234',
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 { clarity } from '@c15t/scripts/microsoft-clarity';
47
+
48
+ const scripts = [
49
+ clarity({
50
+ id: 'abcdef1234',
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 { clarity } from '@c15t/scripts/microsoft-clarity';
74
+
75
+ getOrCreateConsentRuntime({
76
+ mode: 'hosted',
77
+ backendURL: 'https://your-instance.c15t.dev',
78
+ scripts: [
79
+ clarity({
80
+ id: 'abcdef1234',
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:** stays loaded (`persistAfterConsentRevoked: true`) and receives `clarity('consent', false)` so Clarity transitions into denied mode without tearing down the script.
91
+
92
+ ## Configure the integration
93
+
94
+ You can queue an initial Clarity consent value before the script loads.
95
+
96
+ ```ts
97
+ import { clarity } from '@c15t/scripts/microsoft-clarity';
98
+
99
+ clarity({
100
+ id: 'abcdef1234',
101
+ defaultConsent: false,
102
+ });
103
+ ```
104
+
105
+ Use an object when you need to map granular consent categories into Clarity's boot-time consent payload:
106
+
107
+ ```ts
108
+ clarity({
109
+ id: 'abcdef1234',
110
+ defaultConsent: {
111
+ marketing: false,
112
+ analytics: true,
113
+ },
114
+ });
115
+ ```
116
+
117
+ c15t queues that exact `defaultConsent` object during boot. Later consent changes are mapped to simple `true` or `false` values when c15t updates Clarity.
118
+
119
+ ## Tracking events in your app
120
+
121
+ c15t gates the Clarity script from loading until `measurement` consent is granted. Your application code that calls Clarity's runtime API (`window.clarity(...)`) is **not** automatically gated - `window.clarity` does not exist until the script is loaded, so unguarded calls before consent throw.
122
+
123
+ Guard event calls by checking consent state. From React:
124
+
125
+ ```tsx
126
+ import { useCallback } from 'react';
127
+ import { useConsentManager } from '@c15t/react';
128
+
129
+ function SignupExample() {
130
+ const { has } = useConsentManager();
131
+
132
+ const trackSignup = useCallback(() => {
133
+ if (has('measurement')) {
134
+ window.clarity?.('event', 'signup');
135
+ }
136
+ }, [has]);
137
+
138
+ // Call trackSignup() from an event handler after signup succeeds.
139
+ }
140
+ ```
141
+
142
+ From plain JavaScript:
143
+
144
+ ```ts
145
+ import { getOrCreateConsentRuntime } from 'c15t';
146
+
147
+ const { consentStore } = getOrCreateConsentRuntime();
148
+
149
+ if (consentStore.getState().has('measurement')) {
150
+ window.clarity?.('event', 'signup');
151
+ }
152
+ ```
153
+
154
+ ## Types
155
+
156
+ ### ClarityOptions
157
+
158
+ |Property|Type|Description|Default|Required|
159
+ |:--|:--|:--|:--|:--:|
160
+ |id|string|Your Microsoft Clarity project ID.|-|✅ Required|
161
+ |defaultConsent|ClarityConsentValue \|undefined|Optional initial consent value queued before the script loads. Object-shaped advanced consent vectors are supported only for this initial boot-time value. Later c15t consent changes are mapped to simple booleans.|-|Optional|
162
+ |scriptUrl|string \|undefined|Clarity loader URL.|-|Optional|
163
+
164
+ ### Script
165
+
166
+ |Property|Type|Description|Default|Required|
167
+ |:--|:--|:--|:--|:--:|
168
+ |id|string|Unique identifier for the script|-|✅ Required|
169
+ |src|string \|undefined|URL of the script to load|-|Optional|
170
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
171
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
172
+ |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|
173
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
174
+ |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|
175
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
176
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
177
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
178
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
179
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
180
+ |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|
181
+ |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|
182
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
183
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
184
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
185
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
186
+ |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|
187
+ |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|
188
+ |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|
189
+ |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|
190
+
191
+ #### `onBeforeLoad`
192
+
193
+ Callback executed before the script is loaded
194
+
195
+ |Property|Type|Description|Default|Required|
196
+ |:--|:--|:--|:--|:--:|
197
+ |id|string|The original script ID|-|✅ Required|
198
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
199
+ |hasConsent|boolean|Has consent|-|✅ Required|
200
+ |consents|ConsentState|The current consent state|-|✅ Required|
201
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
202
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
203
+
204
+ #### `onLoad`
205
+
206
+ Callback executed when the script loads successfully
207
+
208
+ |Property|Type|Description|Default|Required|
209
+ |:--|:--|:--|:--|:--:|
210
+ |id|string|The original script ID|-|✅ Required|
211
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
212
+ |hasConsent|boolean|Has consent|-|✅ Required|
213
+ |consents|ConsentState|The current consent state|-|✅ Required|
214
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
215
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
216
+
217
+ #### `onError`
218
+
219
+ Callback executed if the script fails to load
220
+
221
+ |Property|Type|Description|Default|Required|
222
+ |:--|:--|:--|:--|:--:|
223
+ |id|string|The original script ID|-|✅ Required|
224
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
225
+ |hasConsent|boolean|Has consent|-|✅ Required|
226
+ |consents|ConsentState|The current consent state|-|✅ Required|
227
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
228
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
229
+
230
+ #### `onConsentChange`
231
+
232
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
233
+
234
+ |Property|Type|Description|Default|Required|
235
+ |:--|:--|:--|:--|:--:|
236
+ |id|string|The original script ID|-|✅ Required|
237
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
238
+ |hasConsent|boolean|Has consent|-|✅ Required|
239
+ |consents|ConsentState|The current consent state|-|✅ Required|
240
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
241
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
@@ -1,26 +1,137 @@
1
1
  ---
2
2
  title: Microsoft UET
3
3
  description: Track conversions and measure performance for Microsoft Advertising and Bing Ads.
4
- lastModified: 2025-09-24
5
-
4
+ lastModified: 2026-05-11
6
5
  icon: microsoft
7
6
  ---
8
- Microsoft UET (Universal Event Tracking) is Microsoft's conversion tracking tag for Microsoft Advertising. It tracks user actions, measures campaign effectiveness, and enables remarketing campaigns. By default, c15t loads this script based on `marketing` consent.
7
+ Microsoft UET (Universal Event Tracking) is Microsoft's conversion tracking tag
8
+ for Microsoft Advertising. It tracks user actions, measures campaign
9
+ effectiveness, and enables remarketing campaigns.
10
+
11
+ ## Official Microsoft documentation
12
+
13
+ * [Universal Event Tracking](https://learn.microsoft.com/en-us/advertising/guides/universal-event-tracking?view=bingads-13)
14
+ * [UET tag data object](https://learn.microsoft.com/en-us/advertising/campaign-management-service/uettag?view=bingads-13)
15
+ * [FAQ: Universal Event Tracking](https://help.ads.microsoft.com/#apex/3/en/53056/2)
16
+ * [FAQ: Remarketing](https://help.ads.microsoft.com/#apex/3/en/56727/1)
9
17
 
10
18
  > ℹ️ **Info:**
11
19
  > UET can also load Microsoft Clarity (if enabled in your UET tag settings). Since Clarity is an analytics tool, we recommend loading it separately with measurement consent instead.
12
20
 
13
- ## Adding Microsoft UET to c15t
21
+ ## Integrate with c15t
14
22
 
15
- > ℹ️ **Info:**
16
- > See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
23
+ **React**
24
+
25
+ ```tsx
26
+ import { type ReactNode } from 'react';
27
+ import { ConsentManagerProvider } from '@c15t/react';
28
+ import { microsoftUet } from '@c15t/scripts/microsoft-uet';
29
+
30
+ const scripts = [microsoftUet({ id: '123456789012345' })];
31
+
32
+ export function ConsentProvider({ children }: { children: ReactNode }) {
33
+ return (
34
+ <ConsentManagerProvider
35
+ options={{
36
+ mode: 'hosted',
37
+ backendURL: 'https://your-instance.c15t.dev',
38
+ scripts,
39
+ }}
40
+ >
41
+ {children}
42
+ </ConsentManagerProvider>
43
+ );
44
+ }
45
+ ```
46
+
47
+ **Next.js**
48
+
49
+ ```tsx
50
+ 'use client';
51
+
52
+ import { type ReactNode } from 'react';
53
+ import { ConsentManagerProvider } from '@c15t/nextjs';
54
+ import { microsoftUet } from '@c15t/scripts/microsoft-uet';
55
+
56
+ const scripts = [microsoftUet({ id: '123456789012345' })];
57
+
58
+ export function ConsentProvider({ children }: { children: ReactNode }) {
59
+ return (
60
+ <ConsentManagerProvider
61
+ options={{
62
+ mode: 'hosted',
63
+ backendURL: '/api/c15t',
64
+ scripts,
65
+ }}
66
+ >
67
+ {children}
68
+ </ConsentManagerProvider>
69
+ );
70
+ }
71
+ ```
72
+
73
+ **JavaScript**
17
74
 
18
75
  ```ts
76
+ import { getOrCreateConsentRuntime } from 'c15t';
19
77
  import { microsoftUet } from '@c15t/scripts/microsoft-uet';
20
78
 
21
- microsoftUet({
22
- id: '123456789012345',
23
- })
79
+ getOrCreateConsentRuntime({
80
+ mode: 'hosted',
81
+ backendURL: 'https://your-instance.c15t.dev',
82
+ scripts: [microsoftUet({ id: '123456789012345' })],
83
+ });
84
+ ```
85
+
86
+ ## How c15t loads it
87
+
88
+ * **Category:** `marketing` (Ads & Pixels)
89
+ * **Loads when:** immediately, with Microsoft consent mode enabled
90
+ * **Default consent:** c15t pushes `ad_storage: 'denied'` before loading UET unless marketing consent is already granted
91
+ * **On grant/revocation:** c15t pushes the new consent state to `uetq` so UET can switch between granted and denied mode without removing the script
92
+
93
+ Use the UET tag ID as `id`. Microsoft recommends creating one UET tag and
94
+ adding it across your site; that tag can then support conversion goals and
95
+ remarketing lists.
96
+
97
+ ## Tracking events in your app
98
+
99
+ c15t loads Microsoft UET in consent mode, so `window.uetq` is created before
100
+ consent is granted. Your own event calls are **not** automatically gated. Guard
101
+ them if you only want to send custom conversion events after marketing consent
102
+ is granted.
103
+
104
+ Microsoft's custom event syntax uses
105
+ `window.uetq.push('event', action, parameters)`. Conversion goals can match page
106
+ visits and custom events, and event payloads can include revenue fields such as
107
+ `revenue_value` and `currency`.
108
+
109
+ ```tsx
110
+ import { useCallback } from 'react';
111
+ import { useConsentManager } from '@c15t/react';
112
+
113
+ function useTrackPurchase() {
114
+ const { has } = useConsentManager();
115
+
116
+ return useCallback(() => {
117
+ if (has('marketing')) {
118
+ window.uetq?.push('event', 'purchase', {
119
+ revenue_value: 10,
120
+ currency: 'USD',
121
+ });
122
+ }
123
+ }, [has]);
124
+ }
125
+
126
+ function CheckoutButton() {
127
+ const trackPurchase = useTrackPurchase();
128
+
129
+ return (
130
+ <button type="button" onClick={trackPurchase}>
131
+ Complete purchase
132
+ </button>
133
+ );
134
+ }
24
135
  ```
25
136
 
26
137
  ## Types
@@ -0,0 +1,198 @@
1
+ ---
2
+ title: Mixpanel Analytics
3
+ description: Load Mixpanel with c15t and let Mixpanel's own opt-in and opt-out APIs follow measurement consent.
4
+ lastModified: 2026-05-10
5
+ icon: mixpanel
6
+ ---
7
+ Mixpanel helps you track product usage, funnels, and retention. The `mixpanelAnalytics()` helper always loads the Mixpanel library, initializes it after the bundle is ready, and uses Mixpanel's own `opt_in_tracking()` and `opt_out_tracking()` methods to keep tracking aligned with `measurement` consent.
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 { mixpanelAnalytics } from '@c15t/scripts/mixpanel-analytics';
17
+
18
+ const scripts = [
19
+ mixpanelAnalytics({
20
+ token: '1234567890abcdef1234567890abcdef',
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 { mixpanelAnalytics } from '@c15t/scripts/mixpanel-analytics';
47
+
48
+ const scripts = [
49
+ mixpanelAnalytics({
50
+ token: '1234567890abcdef1234567890abcdef',
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 { mixpanelAnalytics } from '@c15t/scripts/mixpanel-analytics';
74
+
75
+ getOrCreateConsentRuntime({
76
+ mode: 'hosted',
77
+ backendURL: 'https://your-instance.c15t.dev',
78
+ scripts: [
79
+ mixpanelAnalytics({
80
+ token: '1234567890abcdef1234567890abcdef',
81
+ }),
82
+ ],
83
+ });
84
+ ```
85
+
86
+ ## How c15t loads it
87
+
88
+ * **Category:** `measurement` (Analytics)
89
+ * **Loads when:** immediately (`alwaysLoad: true`)
90
+ * **Consent behavior:** c15t keeps the SDK loaded and toggles tracking by calling Mixpanel's opt-in and opt-out APIs when consent changes.
91
+
92
+ ## Configure the integration
93
+
94
+ You can pass serializable init options through to `mixpanel.init(...)`.
95
+
96
+ ```ts
97
+ import { mixpanelAnalytics } from '@c15t/scripts/mixpanel-analytics';
98
+
99
+ mixpanelAnalytics({
100
+ token: '1234567890abcdef1234567890abcdef',
101
+ initOptions: {
102
+ debug: true,
103
+ },
104
+ });
105
+ ```
106
+
107
+ ## Tracking events in your app
108
+
109
+ Because Mixpanel is configured with `alwaysLoad: true`, `window.mixpanel` is available as soon as the script loads, even before `measurement` consent is granted. You can still call `window.mixpanel.track(...)` from app code; consent suppression is handled by Mixpanel's opt-in/opt-out methods that c15t triggers on consent updates.
110
+
111
+ ## Types
112
+
113
+ ### MixpanelAnalyticsOptions
114
+
115
+ |Property|Type|Description|Default|Required|
116
+ |:--|:--|:--|:--|:--:|
117
+ |token|string|Your Mixpanel project token.|-|✅ Required|
118
+ |initOptions|Record\<string, unknown> \|undefined|Mixpanel init options passed after the library loads. The manifest engine serializes this object as a template variable, so use JSON-serializable values only (no functions, class instances, prototypes, \`Map\`, \`Set\`, or other non-JSON types). Named instances and nested \`people.\*\` queue helpers are intentionally out of scope for this helper.|-|Optional|
119
+ |scriptUrl|string \|undefined|Mixpanel loader URL.|-|Optional|
120
+
121
+ ### Script
122
+
123
+ |Property|Type|Description|Default|Required|
124
+ |:--|:--|:--|:--|:--:|
125
+ |id|string|Unique identifier for the script|-|✅ Required|
126
+ |src|string \|undefined|URL of the script to load|-|Optional|
127
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
128
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
129
+ |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|
130
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
131
+ |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|
132
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
133
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
134
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
135
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
136
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
137
+ |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|
138
+ |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|
139
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
140
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
141
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
142
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
143
+ |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|
144
+ |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|
145
+ |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|
146
+ |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|
147
+
148
+ #### `onBeforeLoad`
149
+
150
+ Callback executed before the script is loaded
151
+
152
+ |Property|Type|Description|Default|Required|
153
+ |:--|:--|:--|:--|:--:|
154
+ |id|string|The original script ID|-|✅ Required|
155
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
156
+ |hasConsent|boolean|Has consent|-|✅ Required|
157
+ |consents|ConsentState|The current consent state|-|✅ Required|
158
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
159
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
160
+
161
+ #### `onLoad`
162
+
163
+ Callback executed when the script loads successfully
164
+
165
+ |Property|Type|Description|Default|Required|
166
+ |:--|:--|:--|:--|:--:|
167
+ |id|string|The original script ID|-|✅ Required|
168
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
169
+ |hasConsent|boolean|Has consent|-|✅ Required|
170
+ |consents|ConsentState|The current consent state|-|✅ Required|
171
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
172
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
173
+
174
+ #### `onError`
175
+
176
+ Callback executed if the script fails to load
177
+
178
+ |Property|Type|Description|Default|Required|
179
+ |:--|:--|:--|:--|:--:|
180
+ |id|string|The original script ID|-|✅ Required|
181
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
182
+ |hasConsent|boolean|Has consent|-|✅ Required|
183
+ |consents|ConsentState|The current consent state|-|✅ Required|
184
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
185
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
186
+
187
+ #### `onConsentChange`
188
+
189
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
190
+
191
+ |Property|Type|Description|Default|Required|
192
+ |:--|:--|:--|:--|:--:|
193
+ |id|string|The original script ID|-|✅ Required|
194
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
195
+ |hasConsent|boolean|Has consent|-|✅ Required|
196
+ |consents|ConsentState|The current consent state|-|✅ Required|
197
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
198
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|