@c15t/nextjs 2.0.0-rc.4 → 2.0.0-rc.6

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 (87) hide show
  1. package/dist/headless.cjs +1 -1
  2. package/dist/iab/styles.css +1 -0
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/libs/browser-initial-data.cjs +1 -0
  6. package/dist/libs/browser-initial-data.js +1 -0
  7. package/dist/libs/initial-data.cjs +1 -1
  8. package/dist/libs/initial-data.js +1 -1
  9. package/dist/styles.css +1 -0
  10. package/dist/types.cjs +1 -1
  11. package/dist/version.cjs +1 -1
  12. package/dist/version.js +1 -1
  13. package/dist-types/headless.d.ts +1 -0
  14. package/{dist → dist-types}/index.d.ts +4 -3
  15. package/dist-types/libs/browser-initial-data.d.ts +9 -0
  16. package/{dist → dist-types}/libs/initial-data.d.ts +1 -2
  17. package/dist-types/types.d.ts +38 -0
  18. package/dist-types/version.d.ts +1 -0
  19. package/docs/README.md +73 -0
  20. package/docs/building-headless-components.md +250 -0
  21. package/docs/callbacks.md +117 -0
  22. package/docs/components/consent-banner.md +174 -0
  23. package/docs/components/consent-dialog-link.md +59 -0
  24. package/docs/components/consent-dialog-trigger.md +103 -0
  25. package/docs/components/consent-dialog.md +137 -0
  26. package/docs/components/consent-manager-provider.md +423 -0
  27. package/docs/components/consent-widget.md +78 -0
  28. package/docs/components/dev-tools.md +63 -0
  29. package/docs/components/frame.md +73 -0
  30. package/docs/concepts/client-modes.md +163 -0
  31. package/docs/concepts/consent-categories.md +97 -0
  32. package/docs/concepts/consent-models.md +116 -0
  33. package/docs/concepts/cookie-management.md +122 -0
  34. package/docs/concepts/glossary.md +23 -0
  35. package/docs/concepts/initialization-flow.md +141 -0
  36. package/docs/concepts/policy-packs.md +229 -0
  37. package/docs/headless.md +184 -0
  38. package/docs/hooks/use-color-scheme.md +40 -0
  39. package/docs/hooks/use-consent-manager/checking-consent.md +94 -0
  40. package/docs/hooks/use-consent-manager/location-info.md +95 -0
  41. package/docs/hooks/use-consent-manager/overview.md +390 -0
  42. package/docs/hooks/use-consent-manager/setting-consent.md +92 -0
  43. package/docs/hooks/use-draggable.md +57 -0
  44. package/docs/hooks/use-focus-trap.md +41 -0
  45. package/docs/hooks/use-reduced-motion.md +35 -0
  46. package/docs/hooks/use-ssr-status.md +31 -0
  47. package/docs/hooks/use-text-direction.md +49 -0
  48. package/docs/hooks/use-translations.md +117 -0
  49. package/docs/iab/consent-banner.md +95 -0
  50. package/docs/iab/consent-dialog.md +135 -0
  51. package/docs/iab/overview.md +119 -0
  52. package/docs/iab/use-gvl-data.md +208 -0
  53. package/docs/iframe-blocking.md +107 -0
  54. package/docs/integrations/databuddy.md +186 -0
  55. package/docs/integrations/google-tag-manager.md +153 -0
  56. package/docs/integrations/google-tag.md +149 -0
  57. package/docs/integrations/linkedin-insights.md +109 -0
  58. package/docs/integrations/meta-pixel.md +342 -0
  59. package/docs/integrations/microsoft-uet.md +112 -0
  60. package/docs/integrations/overview.md +89 -0
  61. package/docs/integrations/posthog.md +177 -0
  62. package/docs/integrations/tiktok-pixel.md +113 -0
  63. package/docs/integrations/x-pixel.md +143 -0
  64. package/docs/internationalization.md +197 -0
  65. package/docs/network-blocker.md +178 -0
  66. package/docs/optimization.md +156 -0
  67. package/docs/policy-packs.md +246 -0
  68. package/docs/quickstart.md +155 -0
  69. package/docs/script-loader.md +300 -0
  70. package/docs/server-side.md +171 -0
  71. package/docs/styling/classnames.md +84 -0
  72. package/docs/styling/color-scheme.md +82 -0
  73. package/docs/styling/css-variables.md +92 -0
  74. package/docs/styling/overview.md +312 -0
  75. package/docs/styling/slots.md +93 -0
  76. package/docs/styling/tailwind.md +115 -0
  77. package/docs/styling/tokens.md +214 -0
  78. package/docs/troubleshooting.md +146 -0
  79. package/package.json +20 -13
  80. package/dist/headless.d.ts +0 -2
  81. package/dist/headless.d.ts.map +0 -1
  82. package/dist/index.d.ts.map +0 -1
  83. package/dist/libs/initial-data.d.ts.map +0 -1
  84. package/dist/types.d.ts +0 -16
  85. package/dist/types.d.ts.map +0 -1
  86. package/dist/version.d.ts +0 -2
  87. package/dist/version.d.ts.map +0 -1
@@ -0,0 +1,112 @@
1
+ ---
2
+ title: Microsoft UET
3
+ description: Track conversions and measure performance for Microsoft Advertising and Bing Ads.
4
+ lastModified: 2025-09-24
5
+
6
+ icon: microsoft
7
+ ---
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.
9
+
10
+ > ℹ️ **Info:**
11
+ > 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
+
13
+ ## Adding Microsoft UET to c15t
14
+
15
+ > ℹ️ **Info:**
16
+ > See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
17
+
18
+ ```ts
19
+ import { microsoftUet } from '@c15t/scripts/microsoft-uet';
20
+
21
+ microsoftUet({
22
+ id: '123456789012345',
23
+ })
24
+ ```
25
+
26
+ ## Types
27
+
28
+ ### MicrosoftUetOptions
29
+
30
+ |Property|Type|Description|Default|Required|
31
+ |:--|:--|:--|:--|:--:|
32
+ |id|string|Your Microsoft UET ID|-|✅ Required|
33
+ |script|Script \|undefined|Override or extend the default script values. Options: \`id\`: 'microsoft-uet'; \`src\`: \`//bat.bing.com/bat.js\`; \`category\`: 'marketing'|-|Optional|
34
+
35
+ ### Script
36
+
37
+ |Property|Type|Description|Default|Required|
38
+ |:--|:--|:--|:--|:--:|
39
+ |id|string|Unique identifier for the script|-|✅ Required|
40
+ |src|string \|undefined|URL of the script to load|-|Optional|
41
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
42
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
43
+ |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|
44
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
45
+ |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|
46
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
47
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
48
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
49
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
50
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
51
+ |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|
52
+ |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|
53
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
54
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
55
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
56
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
57
+ |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|
58
+ |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|
59
+ |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|
60
+ |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|
61
+
62
+ #### `onBeforeLoad`
63
+
64
+ Callback executed before the script is loaded
65
+
66
+ |Property|Type|Description|Default|Required|
67
+ |:--|:--|:--|:--|:--:|
68
+ |id|string|The original script ID|-|✅ Required|
69
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
70
+ |hasConsent|boolean|Has consent|-|✅ Required|
71
+ |consents|ConsentState|The current consent state|-|✅ Required|
72
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
73
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
74
+
75
+ #### `onLoad`
76
+
77
+ Callback executed when the script loads successfully
78
+
79
+ |Property|Type|Description|Default|Required|
80
+ |:--|:--|:--|:--|:--:|
81
+ |id|string|The original script ID|-|✅ Required|
82
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
83
+ |hasConsent|boolean|Has consent|-|✅ Required|
84
+ |consents|ConsentState|The current consent state|-|✅ Required|
85
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
86
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
87
+
88
+ #### `onError`
89
+
90
+ Callback executed if the script fails to load
91
+
92
+ |Property|Type|Description|Default|Required|
93
+ |:--|:--|:--|:--|:--:|
94
+ |id|string|The original script ID|-|✅ Required|
95
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
96
+ |hasConsent|boolean|Has consent|-|✅ Required|
97
+ |consents|ConsentState|The current consent state|-|✅ Required|
98
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
99
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
100
+
101
+ #### `onConsentChange`
102
+
103
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
104
+
105
+ |Property|Type|Description|Default|Required|
106
+ |:--|:--|:--|:--|:--:|
107
+ |id|string|The original script ID|-|✅ Required|
108
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
109
+ |hasConsent|boolean|Has consent|-|✅ Required|
110
+ |consents|ConsentState|The current consent state|-|✅ Required|
111
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
112
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
@@ -0,0 +1,89 @@
1
+ ---
2
+ title: Integrations
3
+ description: "Many of your tools may require consent to be given before they can be used. This is especially true for analytics and marketing tools. \nc15t has various ways to integrate with your tools, depending on the tool you are using."
4
+ lastModified: 2025-10-02
5
+
6
+ ---
7
+ ## General Pattern
8
+
9
+ Every integration provides a script configuration function. Pass it to your framework's setup:
10
+
11
+ **JavaScript**
12
+
13
+ ```ts
14
+ import { getOrCreateConsentRuntime } from 'c15t';
15
+ import { yourScript } from '@c15t/scripts/your-script';
16
+
17
+ getOrCreateConsentRuntime({
18
+ mode: 'hosted',
19
+ scripts: [
20
+ yourScript({ /* options */ }),
21
+ ],
22
+ });
23
+ ```
24
+
25
+ **React**
26
+
27
+ ```tsx
28
+ import { yourScript } from '@c15t/scripts/your-script';
29
+ import { ConsentManagerProvider } from '@c15t/react';
30
+
31
+ export function App({ children }: { children: React.ReactNode }) {
32
+ return (
33
+ <ConsentManagerProvider
34
+ options={{
35
+ scripts: [
36
+ yourScript({ /* options */ }),
37
+ ],
38
+ }}
39
+ >
40
+ {children}
41
+ </ConsentManagerProvider>
42
+ );
43
+ }
44
+ ```
45
+
46
+ **Next.js**
47
+
48
+ ```tsx
49
+ import { yourScript } from '@c15t/scripts/your-script';
50
+ import { ConsentManagerProvider } from '@c15t/nextjs';
51
+
52
+ export function App({ children }: { children: React.ReactNode }) {
53
+ return (
54
+ <ConsentManagerProvider
55
+ options={{
56
+ scripts: [
57
+ yourScript({ /* options */ }),
58
+ ],
59
+ }}
60
+ >
61
+ {children}
62
+ </ConsentManagerProvider>
63
+ );
64
+ }
65
+ ```
66
+
67
+ ## Script Loader
68
+
69
+ Many marketing and analytics tools are commonly loaded using a script tag, such as Google Tag Manager (GTM), Google Tag (gtag.js), Meta Pixel and TikTok Pixel.
70
+
71
+ c15t's script loader allows you to easily integrate your tools that require consent with c15t, to make this even easier we have provided a set of prebuilt scripts for you to use.
72
+
73
+ * [JavaScript](/docs/frameworks/javascript/script-loader)
74
+ * [React](/docs/frameworks/react/script-loader)
75
+ * [Next.js](/docs/frameworks/next/script-loader)
76
+
77
+ ## has() method
78
+
79
+ The `has()` method allows you to check if the user has given consent for a specific purpose. You can learn more about the `has()` method [here](/docs/frameworks/javascript/store/checking-consent).
80
+
81
+ ```ts
82
+
83
+
84
+ const hasAnalytics = has('measurement');
85
+
86
+ if (hasAnalytics) {
87
+ myAnalyticsLibrary.track('checkout_completed');
88
+ }
89
+ ```
@@ -0,0 +1,177 @@
1
+ ---
2
+ title: PostHog
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: 2025-09-19
5
+
6
+ icon: posthog
7
+ ---
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.
9
+
10
+ ## PostHog SDK Implementation
11
+
12
+ This is the recommended approach if you're using the Posthog JS SDK, this is commonly used in React projects.
13
+
14
+ ### Adding the PostHog SDK to c15t
15
+
16
+ 1. **Initialize Posthog** When you initialize posthog make sure to set cookieless\_mode to on\_reject.
17
+
18
+ ```ts
19
+ posthog.init("phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", {
20
+ api_host: "https://eu.i.posthog.com",
21
+ defaults: "2025-05-24",
22
+ cookieless_mode: 'on_reject'
23
+ })
24
+
25
+ posthog.opt_out_capturing() // Avoids accidental tracking without consent till c15t has loaded
26
+ ```
27
+
28
+ 2. **Adding the SDK callback to c15t** The PostHog SDK approach uses callbacks.onConsentSet instead of scripts. This lets you toggle PostHog's opt-in/opt-out based on the user's consent choice.
29
+
30
+ > ℹ️ Info:
31
+ >
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.
33
+
34
+ ```ts
35
+ import { getOrCreateConsentRuntime } from 'c15t';
36
+ import { posthog } from 'posthog-js';
37
+
38
+ getOrCreateConsentRuntime({
39
+ mode: 'hosted',
40
+ callbacks: {
41
+ onConsentSet({ preferences }) {
42
+ if (preferences.measurement) {
43
+ posthog.opt_in_capturing();
44
+ } else {
45
+ posthog.opt_out_capturing();
46
+ }
47
+ }
48
+ }
49
+ });
50
+ ```
51
+
52
+ ## PostHog Script Implementation
53
+
54
+ If you want to load posthog via a script tag it's recommended to use this approach.
55
+
56
+ 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.
57
+
58
+ 1. **Initialize Posthog** This script does not load the Posthog script, it only syncs the consent state with Posthog via the Posthog JS SDK.
59
+
60
+ This is due to Posthog's use of cookieless tracking. However, you need to set cookieless\_mode to on\_reject when initializing Posthog.
61
+
62
+ ```ts
63
+ posthog.init("phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", {
64
+ api_host: "https://eu.i.posthog.com",
65
+ defaults: "2025-05-24",
66
+ // PostHog will not set any cookies until the user has given consent
67
+ cookieless_mode: 'on_reject'
68
+ })
69
+ ```
70
+
71
+ 2. **Adding the script to c15t**
72
+
73
+ > ℹ️ Info:
74
+ >
75
+ > See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
76
+
77
+ ```ts
78
+ import { posthog } from '@c15t/scripts/posthog';
79
+
80
+ posthog({
81
+ id: 'phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
82
+ apiHost: 'https://eu.i.posthog.com',
83
+ defaults: '2025-05-24',
84
+ options: { person_profiles: 'identified_only' }
85
+ })
86
+ ```
87
+
88
+ ## Types
89
+
90
+ ### PosthogConsentOptions
91
+
92
+ |Property|Type|Description|Default|Required|
93
+ |:--|:--|:--|:--|:--:|
94
+ |id|string|Your posthog id, begins with 'phc\_'.|-|✅ Required|
95
+ |apiHost|string|Your posthog api host.|'https\://eu.i.posthog.com'|✅ Required|
96
+ |defaults|string|The defaults for the posthog script.|-|✅ Required|
97
+ |options|Record\<string, unknown>|Other optional options for the posthog script.|-|✅ Required|
98
+ |script|Script \|undefined|Override or extend the default script values. Options: \`id\`: 'posthog-consent'; \`category\`: 'measurement'|-|Optional|
99
+
100
+ ### Script
101
+
102
+ |Property|Type|Description|Default|Required|
103
+ |:--|:--|:--|:--|:--:|
104
+ |id|string|Unique identifier for the script|-|✅ Required|
105
+ |src|string \|undefined|URL of the script to load|-|Optional|
106
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
107
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
108
+ |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|
109
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
110
+ |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|
111
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
112
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
113
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
114
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
115
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
116
+ |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|
117
+ |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|
118
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
119
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
120
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
121
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
122
+ |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|
123
+ |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|
124
+ |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|
125
+ |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|
126
+
127
+ #### `onBeforeLoad`
128
+
129
+ Callback executed before the script is loaded
130
+
131
+ |Property|Type|Description|Default|Required|
132
+ |:--|:--|:--|:--|:--:|
133
+ |id|string|The original script ID|-|✅ Required|
134
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
135
+ |hasConsent|boolean|Has consent|-|✅ Required|
136
+ |consents|ConsentState|The current consent state|-|✅ Required|
137
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
138
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
139
+
140
+ #### `onLoad`
141
+
142
+ Callback executed when the script loads successfully
143
+
144
+ |Property|Type|Description|Default|Required|
145
+ |:--|:--|:--|:--|:--:|
146
+ |id|string|The original script ID|-|✅ Required|
147
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
148
+ |hasConsent|boolean|Has consent|-|✅ Required|
149
+ |consents|ConsentState|The current consent state|-|✅ Required|
150
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
151
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
152
+
153
+ #### `onError`
154
+
155
+ Callback executed if the script fails to load
156
+
157
+ |Property|Type|Description|Default|Required|
158
+ |:--|:--|:--|:--|:--:|
159
+ |id|string|The original script ID|-|✅ Required|
160
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
161
+ |hasConsent|boolean|Has consent|-|✅ Required|
162
+ |consents|ConsentState|The current consent state|-|✅ Required|
163
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
164
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
165
+
166
+ #### `onConsentChange`
167
+
168
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
169
+
170
+ |Property|Type|Description|Default|Required|
171
+ |:--|:--|:--|:--|:--:|
172
+ |id|string|The original script ID|-|✅ Required|
173
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
174
+ |hasConsent|boolean|Has consent|-|✅ Required|
175
+ |consents|ConsentState|The current consent state|-|✅ Required|
176
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
177
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
@@ -0,0 +1,113 @@
1
+ ---
2
+ title: TikTok Pixel
3
+ description: Measure ad performance and build audiences for TikTok advertising campaigns.
4
+ lastModified: 2025-09-24
5
+
6
+ icon: tiktok
7
+ ---
8
+ TikTok Pixel is TikTok's conversion tracking and audience targeting tool. It measures ad effectiveness, tracks user actions, and helps optimize your TikTok advertising campaigns. By default, c15t loads this script based on `marketing` consent.
9
+
10
+ This script persists after consent is revoked because it has built-in consent management. When consent changes, c15t updates TikTok's internal consent state rather than removing the script entirely.
11
+
12
+ ## Implementation
13
+
14
+ ### Adding the script to c15t
15
+
16
+ > ℹ️ **Info:**
17
+ > See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
18
+
19
+ ```ts
20
+ import { tiktokPixel } from '@c15t/scripts/tiktok-pixel';
21
+
22
+ tiktokPixel({
23
+ pixelId: '123456789012345',
24
+ })
25
+ ```
26
+
27
+ ## Types
28
+
29
+ ### TikTokPixelOptions
30
+
31
+ |Property|Type|Description|Default|Required|
32
+ |:--|:--|:--|:--|:--:|
33
+ |pixelId|string|Your TikTok Pixel ID|-|✅ Required|
34
+ |script|Script \|undefined|Override or extend the default script values. Options: \`id\`: 'tiktok-pixel'; \`src\`: \`https\://analytics.tiktok.com/i18n/pixel/events.js\`; \`category\`: 'marketing'|-|Optional|
35
+
36
+ ### Script
37
+
38
+ |Property|Type|Description|Default|Required|
39
+ |:--|:--|:--|:--|:--:|
40
+ |id|string|Unique identifier for the script|-|✅ Required|
41
+ |src|string \|undefined|URL of the script to load|-|Optional|
42
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
43
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
44
+ |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|
45
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
46
+ |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|
47
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
48
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
49
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
50
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
51
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
52
+ |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|
53
+ |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|
54
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
55
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
56
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
57
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
58
+ |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|
59
+ |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|
60
+ |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|
61
+ |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|
62
+
63
+ #### `onBeforeLoad`
64
+
65
+ Callback executed before the script is loaded
66
+
67
+ |Property|Type|Description|Default|Required|
68
+ |:--|:--|:--|:--|:--:|
69
+ |id|string|The original script ID|-|✅ Required|
70
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
71
+ |hasConsent|boolean|Has consent|-|✅ Required|
72
+ |consents|ConsentState|The current consent state|-|✅ Required|
73
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
74
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
75
+
76
+ #### `onLoad`
77
+
78
+ Callback executed when the script loads successfully
79
+
80
+ |Property|Type|Description|Default|Required|
81
+ |:--|:--|:--|:--|:--:|
82
+ |id|string|The original script ID|-|✅ Required|
83
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
84
+ |hasConsent|boolean|Has consent|-|✅ Required|
85
+ |consents|ConsentState|The current consent state|-|✅ Required|
86
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
87
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
88
+
89
+ #### `onError`
90
+
91
+ Callback executed if the script fails to load
92
+
93
+ |Property|Type|Description|Default|Required|
94
+ |:--|:--|:--|:--|:--:|
95
+ |id|string|The original script ID|-|✅ Required|
96
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
97
+ |hasConsent|boolean|Has consent|-|✅ Required|
98
+ |consents|ConsentState|The current consent state|-|✅ Required|
99
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
100
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
101
+
102
+ #### `onConsentChange`
103
+
104
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
105
+
106
+ |Property|Type|Description|Default|Required|
107
+ |:--|:--|:--|:--|:--:|
108
+ |id|string|The original script ID|-|✅ Required|
109
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
110
+ |hasConsent|boolean|Has consent|-|✅ Required|
111
+ |consents|ConsentState|The current consent state|-|✅ Required|
112
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
113
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
@@ -0,0 +1,143 @@
1
+ ---
2
+ title: X Pixel (Twitter Pixel)
3
+ description: Track conversions and build audiences for advertising campaigns on X (formerly Twitter).
4
+ lastModified: 2025-09-24
5
+
6
+ icon: x
7
+ ---
8
+ X Pixel (formerly Twitter Pixel) is X's conversion tracking and audience building tool. It helps you measure ad performance, retarget website visitors, and optimize campaigns on the X platform. By default, c15t loads this script based on `marketing` consent.
9
+
10
+ ## Implementation
11
+
12
+ > ℹ️ **Info:**
13
+ > See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
14
+
15
+ ```ts
16
+ import { xPixel } from '@c15t/scripts/x-pixel';
17
+
18
+ xPixel({
19
+ id: '123456789012345',
20
+ })
21
+ ```
22
+
23
+ ## xPixelEvent
24
+
25
+ You can use the `xPixelEvent` function to track events. This is a wrapper around the `twq` function that the X Pixel script uses.
26
+
27
+ ```ts
28
+ import { xPixelEvent } from '@c15t/scripts/x-pixel';
29
+
30
+ xPixelEvent('tw-xxxx-xxxx', { value: 10.00, currency: 'USD' });
31
+ ```
32
+
33
+ ## Types
34
+
35
+ ### XPixelOptions
36
+
37
+ |Property|Type|Description|Default|Required|
38
+ |:--|:--|:--|:--|:--:|
39
+ |pixelId|string|Your X Pixel ID|-|✅ Required|
40
+ |script|Script \|undefined|Override or extend the default script values. Options: \`id\`: 'x-pixel'; \`src\`: \`https\://static.ads-twitter.com/uwt.js\`; \`category\`: 'marketing'|-|Optional|
41
+
42
+ ### Script
43
+
44
+ |Property|Type|Description|Default|Required|
45
+ |:--|:--|:--|:--|:--:|
46
+ |id|string|Unique identifier for the script|-|✅ Required|
47
+ |src|string \|undefined|URL of the script to load|-|Optional|
48
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
49
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
50
+ |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|
51
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
52
+ |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|
53
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
54
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
55
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
56
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
57
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
58
+ |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|
59
+ |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|
60
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
61
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
62
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
63
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
64
+ |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|
65
+ |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|
66
+ |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|
67
+ |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|
68
+
69
+ #### `onBeforeLoad`
70
+
71
+ Callback executed before the script is loaded
72
+
73
+ |Property|Type|Description|Default|Required|
74
+ |:--|:--|:--|:--|:--:|
75
+ |id|string|The original script ID|-|✅ Required|
76
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
77
+ |hasConsent|boolean|Has consent|-|✅ Required|
78
+ |consents|ConsentState|The current consent state|-|✅ Required|
79
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
80
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
81
+
82
+ #### `onLoad`
83
+
84
+ Callback executed when the script loads successfully
85
+
86
+ |Property|Type|Description|Default|Required|
87
+ |:--|:--|:--|:--|:--:|
88
+ |id|string|The original script ID|-|✅ Required|
89
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
90
+ |hasConsent|boolean|Has consent|-|✅ Required|
91
+ |consents|ConsentState|The current consent state|-|✅ Required|
92
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
93
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
94
+
95
+ #### `onError`
96
+
97
+ Callback executed if the script fails to load
98
+
99
+ |Property|Type|Description|Default|Required|
100
+ |:--|:--|:--|:--|:--:|
101
+ |id|string|The original script ID|-|✅ Required|
102
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
103
+ |hasConsent|boolean|Has consent|-|✅ Required|
104
+ |consents|ConsentState|The current consent state|-|✅ Required|
105
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
106
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
107
+
108
+ #### `onConsentChange`
109
+
110
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
111
+
112
+ |Property|Type|Description|Default|Required|
113
+ |:--|:--|:--|:--|:--:|
114
+ |id|string|The original script ID|-|✅ Required|
115
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
116
+ |hasConsent|boolean|Has consent|-|✅ Required|
117
+ |consents|ConsentState|The current consent state|-|✅ Required|
118
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
119
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
120
+
121
+ ### XPixelEvent
122
+
123
+ |Property|Type|Description|Default|Required|
124
+ |:--|:--|:--|:--|:--:|
125
+ |value|number \|undefined|Total value of the conversion event (ex: $ value of the transaction in case of a purchase, etc.)|-|Optional|
126
+ |currency|string \|undefined|Currency of the conversion event ISO 4217 code (ex: USD, EUR, JPY, etc.)|-|Optional|
127
+ |conversion\_id|string \|undefined|Unique identifier for the event that can be used for deduplication purposes|-|Optional|
128
+ |search\_string|string \|undefined|Search string of the conversion event|-|Optional|
129
+ |description|string \|undefined|Description of the conversion event|-|Optional|
130
+ |twclid|string \|undefined|twclid of the conversion event The X Pixel already automatically passes twclid from URL or first-party cookie. This parameter can be optionally used to force attribution to a certain ad click.|-|Optional|
131
+ |status|boolean \|undefined|Status of the conversion event|-|Optional|
132
+ |contents|XPixelContent \|undefined|Content/products associated with the conversion event|-|Optional|
133
+
134
+ ### XPixelContent
135
+
136
+ |Property|Type|Description|Default|Required|
137
+ |:--|:--|:--|:--|:--:|
138
+ |content\_type|[string \|undefined](https://www.google.com/basepages/producttype/taxonomy.en-US.txt)|Type of the content|-|Optional|
139
+ |content\_id|string|ID of the content For product catalog users: please pass SKU For all other users: Please pass Global Trade Item Number (GTIN) if available, otherwise pass SKU|-|✅ Required|
140
+ |content\_name|string \|undefined|Name of a product or service|-|Optional|
141
+ |content\_price|number \|undefined|Price of a product or service|-|Optional|
142
+ |num\_items|number \|undefined|Quantity of the content|-|Optional|
143
+ |content\_group\_id|string \|undefined|ID associated with a group of product variants|-|Optional|