@c15t/scripts 2.1.0 → 2.2.0-canary-20260804162155

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 (140) hide show
  1. package/AGENTS.md +62 -0
  2. package/README.md +32 -20
  3. package/dist/e2e-test-utils.cjs +51 -10
  4. package/dist/e2e-test-utils.js +37 -3
  5. package/dist/engine/compile.cjs +9 -5
  6. package/dist/engine/runtime.cjs +103 -17
  7. package/dist/engine/runtime.js +94 -12
  8. package/dist/registry.cjs +97 -12
  9. package/dist/registry.js +80 -0
  10. package/dist/resolve.cjs +9 -5
  11. package/dist/types.cjs +17 -13
  12. package/dist/vendors/_shared/attributes.cjs +13 -9
  13. package/dist/vendors/_shared/google-consent.cjs +14 -9
  14. package/dist/vendors/_shared/install-builders.cjs +12 -8
  15. package/dist/vendors/_shared/script-url.cjs +16 -12
  16. package/dist/vendors/ads-and-pixels/linkedin-insights.cjs +9 -5
  17. package/dist/vendors/ads-and-pixels/meta-pixel.cjs +13 -9
  18. package/dist/vendors/ads-and-pixels/microsoft-uet.cjs +11 -7
  19. package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +9 -5
  20. package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +11 -7
  21. package/dist/vendors/ads-and-pixels/tiktok-pixel.cjs +9 -5
  22. package/dist/vendors/ads-and-pixels/x-pixel.cjs +9 -5
  23. package/dist/vendors/analytics/adobe-analytics.cjs +90 -0
  24. package/dist/vendors/analytics/adobe-analytics.js +49 -0
  25. package/dist/vendors/analytics/ahrefs-analytics.cjs +11 -7
  26. package/dist/vendors/analytics/amplitude.cjs +193 -0
  27. package/dist/vendors/analytics/amplitude.js +134 -0
  28. package/dist/vendors/analytics/clearbit.cjs +69 -0
  29. package/dist/vendors/analytics/clearbit.js +28 -0
  30. package/dist/vendors/analytics/cloudflare-web-analytics.cjs +11 -7
  31. package/dist/vendors/analytics/databuddy.cjs +11 -7
  32. package/dist/vendors/analytics/fathom-analytics.cjs +11 -7
  33. package/dist/vendors/analytics/google-tag.cjs +11 -7
  34. package/dist/vendors/analytics/heap.cjs +181 -0
  35. package/dist/vendors/analytics/heap.js +134 -0
  36. package/dist/vendors/analytics/hightouch.cjs +153 -0
  37. package/dist/vendors/analytics/hightouch.js +109 -0
  38. package/dist/vendors/analytics/hotjar.cjs +11 -7
  39. package/dist/vendors/analytics/logrocket.cjs +99 -0
  40. package/dist/vendors/analytics/logrocket.js +58 -0
  41. package/dist/vendors/analytics/matomo-analytics.cjs +9 -5
  42. package/dist/vendors/analytics/microsoft-clarity.cjs +75 -47
  43. package/dist/vendors/analytics/microsoft-clarity.js +64 -40
  44. package/dist/vendors/analytics/mixpanel-analytics.cjs +31 -16
  45. package/dist/vendors/analytics/mixpanel-analytics.js +22 -11
  46. package/dist/vendors/analytics/pirsch.cjs +108 -0
  47. package/dist/vendors/analytics/pirsch.js +67 -0
  48. package/dist/vendors/analytics/plausible-analytics.cjs +9 -5
  49. package/dist/vendors/analytics/posthog.cjs +63 -27
  50. package/dist/vendors/analytics/posthog.js +52 -20
  51. package/dist/vendors/analytics/promptwatch.cjs +11 -7
  52. package/dist/vendors/analytics/rudderstack.cjs +227 -0
  53. package/dist/vendors/analytics/rudderstack.js +183 -0
  54. package/dist/vendors/analytics/rybbit-analytics.cjs +9 -5
  55. package/dist/vendors/analytics/segment.cjs +9 -5
  56. package/dist/vendors/analytics/umami-analytics.cjs +9 -5
  57. package/dist/vendors/analytics/vercel-analytics.cjs +11 -7
  58. package/dist/vendors/functional/crisp.cjs +9 -5
  59. package/dist/vendors/functional/intercom.cjs +11 -7
  60. package/dist/vendors/tag-managers/google-tag-manager.cjs +11 -7
  61. package/dist-types/registry.d.ts +313 -241
  62. package/dist-types/types.d.ts +46 -4
  63. package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +18 -18
  64. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +21 -21
  65. package/dist-types/vendors/ads-and-pixels/microsoft-uet.d.ts +32 -32
  66. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +19 -19
  67. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +16 -16
  68. package/dist-types/vendors/ads-and-pixels/tiktok-pixel.d.ts +28 -28
  69. package/dist-types/vendors/ads-and-pixels/x-pixel.d.ts +13 -13
  70. package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
  71. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +7 -7
  72. package/dist-types/vendors/analytics/amplitude.d.ts +234 -0
  73. package/dist-types/vendors/analytics/clearbit.d.ts +60 -0
  74. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +7 -7
  75. package/dist-types/vendors/analytics/databuddy.d.ts +25 -25
  76. package/dist-types/vendors/analytics/fathom-analytics.d.ts +11 -11
  77. package/dist-types/vendors/analytics/google-tag.d.ts +17 -17
  78. package/dist-types/vendors/analytics/heap.d.ts +316 -0
  79. package/dist-types/vendors/analytics/hightouch.d.ts +285 -0
  80. package/dist-types/vendors/analytics/hotjar.d.ts +14 -14
  81. package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
  82. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +42 -30
  83. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +40 -28
  84. package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
  85. package/dist-types/vendors/analytics/plausible-analytics.d.ts +13 -13
  86. package/dist-types/vendors/analytics/posthog.d.ts +63 -45
  87. package/dist-types/vendors/analytics/promptwatch.d.ts +7 -7
  88. package/dist-types/vendors/analytics/rudderstack.d.ts +330 -0
  89. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +18 -18
  90. package/dist-types/vendors/analytics/segment.d.ts +13 -13
  91. package/dist-types/vendors/analytics/umami-analytics.d.ts +12 -12
  92. package/dist-types/vendors/analytics/vercel-analytics.d.ts +16 -16
  93. package/dist-types/vendors/functional/crisp.d.ts +11 -11
  94. package/dist-types/vendors/functional/intercom.d.ts +16 -16
  95. package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +18 -18
  96. package/docs/README.md +62 -0
  97. package/docs/frameworks/javascript/script-loader.md +356 -0
  98. package/docs/frameworks/next/script-loader.md +501 -0
  99. package/docs/frameworks/react/script-loader.md +555 -0
  100. package/docs/integrations/adobe-analytics.md +160 -0
  101. package/docs/integrations/ahrefs-analytics.md +157 -0
  102. package/docs/integrations/amplitude.md +230 -0
  103. package/docs/integrations/building-integrations.md +239 -0
  104. package/docs/integrations/clearbit.md +130 -0
  105. package/docs/integrations/cloudflare-web-analytics.md +126 -0
  106. package/docs/integrations/crisp.md +140 -0
  107. package/docs/integrations/databuddy.md +205 -0
  108. package/docs/integrations/fathom-analytics.md +150 -0
  109. package/docs/integrations/google-maps.md +263 -0
  110. package/docs/integrations/google-tag-manager.md +154 -0
  111. package/docs/integrations/google-tag.md +134 -0
  112. package/docs/integrations/heap.md +219 -0
  113. package/docs/integrations/hightouch.md +199 -0
  114. package/docs/integrations/hotjar.md +143 -0
  115. package/docs/integrations/intercom.md +144 -0
  116. package/docs/integrations/linkedin-insights.md +161 -0
  117. package/docs/integrations/logrocket.md +175 -0
  118. package/docs/integrations/matomo-analytics.md +171 -0
  119. package/docs/integrations/meta-pixel.md +412 -0
  120. package/docs/integrations/microsoft-clarity.md +173 -0
  121. package/docs/integrations/microsoft-uet.md +156 -0
  122. package/docs/integrations/mixpanel-analytics.md +130 -0
  123. package/docs/integrations/overview.md +149 -0
  124. package/docs/integrations/pirsch.md +142 -0
  125. package/docs/integrations/plausible-analytics.md +154 -0
  126. package/docs/integrations/posthog.md +258 -0
  127. package/docs/integrations/promptwatch.md +121 -0
  128. package/docs/integrations/reddit-pixel.md +241 -0
  129. package/docs/integrations/rudderstack.md +271 -0
  130. package/docs/integrations/rybbit-analytics.md +143 -0
  131. package/docs/integrations/segment.md +146 -0
  132. package/docs/integrations/snapchat-pixel.md +163 -0
  133. package/docs/integrations/tiktok-pixel.md +123 -0
  134. package/docs/integrations/umami-analytics.md +148 -0
  135. package/docs/integrations/vercel-analytics.md +141 -0
  136. package/docs/integrations/x-pixel.md +157 -0
  137. package/docs/integrations/youtube.md +193 -0
  138. package/docs/shared/react/guides/script-loader.md +311 -0
  139. package/package.json +61 -7
  140. package/readme.json +8 -4
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: Segment
3
+ description: Load Segment Analytics.js with c15t and gate it behind measurement consent.
4
+ group: integrations
5
+ icon: segment
6
+ ---
7
+ Segment lets you collect analytics events in one place and forward them to downstream destinations. The `segment()` helper creates Segment's standard `window.analytics` queue, optionally queues the initial `page()` call, and loads Analytics.js when `measurement` consent is available.
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 { segment } from '@c15t/scripts/segment';
17
+
18
+ const scripts = [segment({ writeKey: 'abc123xyz456' })];
19
+
20
+ export function ConsentProvider({ children }: { children: ReactNode }) {
21
+ return (
22
+ <ConsentManagerProvider
23
+ options={{
24
+ mode: 'hosted',
25
+ backendURL: 'https://your-instance.c15t.dev',
26
+ scripts,
27
+ }}
28
+ >
29
+ {children}
30
+ </ConsentManagerProvider>
31
+ );
32
+ }
33
+ ```
34
+
35
+ **Next.js**
36
+
37
+ ```tsx
38
+ 'use client';
39
+
40
+ import { type ReactNode } from 'react';
41
+ import { ConsentManagerProvider } from '@c15t/nextjs';
42
+ import { segment } from '@c15t/scripts/segment';
43
+
44
+ const scripts = [segment({ writeKey: 'abc123xyz456' })];
45
+
46
+ export function ConsentProvider({ children }: { children: ReactNode }) {
47
+ return (
48
+ <ConsentManagerProvider
49
+ options={{
50
+ mode: 'hosted',
51
+ backendURL: '/api/c15t',
52
+ scripts,
53
+ }}
54
+ >
55
+ {children}
56
+ </ConsentManagerProvider>
57
+ );
58
+ }
59
+ ```
60
+
61
+ **JavaScript**
62
+
63
+ ```ts
64
+ import { getOrCreateConsentRuntime } from 'c15t';
65
+ import { segment } from '@c15t/scripts/segment';
66
+
67
+ getOrCreateConsentRuntime({
68
+ mode: 'hosted',
69
+ backendURL: 'https://your-instance.c15t.dev',
70
+ scripts: [segment({ writeKey: 'abc123xyz456' })],
71
+ });
72
+ ```
73
+
74
+ ## How c15t loads it
75
+
76
+ * **Category:** `measurement` (Analytics)
77
+ * **Loads when:** measurement consent is granted
78
+ * **On revocation:** unloaded - c15t removes the script from the DOM and clears Segment globals until consent is granted again.
79
+
80
+ c15t deliberately blocks the load rather than mapping consent into Segment's consent tooling: Segment's consent object and consent wrappers control which downstream destinations receive events, but Analytics.js itself still writes identifiers and delivers events to Segment once loaded. Gating the load is the only default that reliably honors missing or denied `measurement` consent. See the [RudderStack consent notes](/docs/integrations/rudderstack#consent-behavior) for the full reasoning behind this model versus vendor consent-API mapping (as used for Google Tag Manager).
81
+
82
+ ## Configure the integration
83
+
84
+ By default the helper queues `analytics.page()` before the vendor bundle loads. If you want to handle page views yourself, set `trackPageView` to `false`.
85
+
86
+ ```ts
87
+ import { segment } from '@c15t/scripts/segment';
88
+
89
+ segment({
90
+ writeKey: 'abc123xyz456',
91
+ trackPageView: false,
92
+ });
93
+ ```
94
+
95
+ ## Tracking events in your app
96
+
97
+ c15t gates the Segment script from loading until `measurement` consent is granted. Your application code that calls Segment's runtime API (`window.analytics.track`, `identify`, etc.) is **not** automatically gated - `window.analytics` does not exist until the script is loaded, so unguarded calls before consent throw.
98
+
99
+ Guard event calls by checking consent state. From React:
100
+
101
+ ```tsx
102
+ import { useCallback } from 'react';
103
+ import { useConsentManager } from '@c15t/react';
104
+
105
+ function SignupExample() {
106
+ const { has } = useConsentManager();
107
+
108
+ const trackSignup = useCallback(() => {
109
+ if (has('measurement')) {
110
+ window.analytics?.track('Signup Completed', { plan: 'pro' });
111
+ }
112
+ }, [has]);
113
+ }
114
+ ```
115
+
116
+ From plain JavaScript:
117
+
118
+ ```ts
119
+ import { getOrCreateConsentRuntime } from 'c15t';
120
+
121
+ const { consentStore } = getOrCreateConsentRuntime();
122
+
123
+ if (consentStore.getState().has('measurement')) {
124
+ window.analytics?.track('Signup Completed', { plan: 'pro' });
125
+ }
126
+ ```
127
+
128
+ ## Types
129
+
130
+ ### SegmentOptions
131
+
132
+ |Property|Value|
133
+ |:--|:--|
134
+ |Type Name|\`SegmentOptions\`|
135
+ |Source Path|\`./packages/scripts/src/vendors/analytics/segment.ts\`|
136
+
137
+ \*ExtractedTypeTable: Could not extract "SegmentOptions" from "./packages/scripts/src/vendors/analytics/segment.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
138
+
139
+ ### Script
140
+
141
+ |Property|Value|
142
+ |:--|:--|
143
+ |Type Name|\`Script\`|
144
+ |Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
145
+
146
+ \*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
@@ -0,0 +1,163 @@
1
+ ---
2
+ title: Snapchat Pixel
3
+ description: Measure Snapchat ad performance and build remarketing audiences
4
+ with a prebuilt pixel helper.
5
+ group: integrations
6
+ icon: snapchat
7
+ ---
8
+ Snapchat Pixel is Snapchat's website conversion tracking and audience-building tool. The `snapchatPixel()` helper seeds the `snaptr` queue, initializes your pixel, and by default tracks a `PAGE_VIEW` event as soon as `marketing` consent is available.
9
+
10
+ ## Integrate with c15t
11
+
12
+ **React**
13
+
14
+ ```tsx
15
+ import { type ReactNode } from 'react';
16
+ import { ConsentManagerProvider } from '@c15t/react';
17
+ import { snapchatPixel } from '@c15t/scripts/snapchat-pixel';
18
+
19
+ const scripts = [snapchatPixel({ pixelId: '123456789012345' })];
20
+
21
+ export function ConsentProvider({ children }: { children: ReactNode }) {
22
+ return (
23
+ <ConsentManagerProvider
24
+ options={{
25
+ mode: 'hosted',
26
+ backendURL: 'https://your-instance.c15t.dev',
27
+ scripts,
28
+ }}
29
+ >
30
+ {children}
31
+ </ConsentManagerProvider>
32
+ );
33
+ }
34
+ ```
35
+
36
+ **Next.js**
37
+
38
+ ```tsx
39
+ 'use client';
40
+
41
+ import { type ReactNode } from 'react';
42
+ import { ConsentManagerProvider } from '@c15t/nextjs';
43
+ import { snapchatPixel } from '@c15t/scripts/snapchat-pixel';
44
+
45
+ const scripts = [snapchatPixel({ pixelId: '123456789012345' })];
46
+
47
+ export function ConsentProvider({ children }: { children: ReactNode }) {
48
+ return (
49
+ <ConsentManagerProvider
50
+ options={{
51
+ mode: 'hosted',
52
+ backendURL: '/api/c15t',
53
+ scripts,
54
+ }}
55
+ >
56
+ {children}
57
+ </ConsentManagerProvider>
58
+ );
59
+ }
60
+ ```
61
+
62
+ **JavaScript**
63
+
64
+ ```ts
65
+ import { getOrCreateConsentRuntime } from 'c15t';
66
+ import { snapchatPixel } from '@c15t/scripts/snapchat-pixel';
67
+
68
+ getOrCreateConsentRuntime({
69
+ mode: 'hosted',
70
+ backendURL: 'https://your-instance.c15t.dev',
71
+ scripts: [snapchatPixel({ pixelId: '123456789012345' })],
72
+ });
73
+ ```
74
+
75
+ ## How c15t loads it
76
+
77
+ * **Category:** `marketing` (Ads & Pixels)
78
+ * **Loads when:** marketing consent is granted
79
+ * **On revocation:** unloaded - c15t removes the script from the DOM, so app code should guard `snaptr(...)` calls until consent is granted again.
80
+
81
+ You can pass extra init payload and disable the default page-view event when you need finer control:
82
+
83
+ ```ts
84
+ snapchatPixel({
85
+ pixelId: '123456789012345',
86
+ initOptions: {
87
+ user_email: 'hello@example.com',
88
+ },
89
+ trackPageView: false,
90
+ });
91
+ ```
92
+
93
+ ## Tracking events in your app
94
+
95
+ c15t gates the Snapchat Pixel script from loading until `marketing` consent is granted. Your application code that calls Snapchat's runtime API (`window.snaptr(...)`) is **not** automatically gated - `window.snaptr` does not exist until the script is loaded, so unguarded calls before consent throw.
96
+
97
+ Use `snapchatPixelEvent()` for typed standard and custom event tracking. Guard
98
+ event calls by checking consent state. From React:
99
+
100
+ ```tsx
101
+ import { useCallback } from 'react';
102
+ import { useConsentManager } from '@c15t/react';
103
+ import { snapchatPixelEvent } from '@c15t/scripts/snapchat-pixel';
104
+
105
+ function CheckoutExample() {
106
+ const { has } = useConsentManager();
107
+
108
+ const trackPurchase = useCallback(() => {
109
+ if (has('marketing')) {
110
+ snapchatPixelEvent('PURCHASE', {
111
+ price: 99,
112
+ currency: 'USD',
113
+ transaction_id: 'order-123',
114
+ client_dedup_id: 'event-123',
115
+ });
116
+ }
117
+ }, [has]);
118
+
119
+ // Call trackPurchase() from your conversion success path.
120
+ }
121
+ ```
122
+
123
+ From plain JavaScript:
124
+
125
+ ```ts
126
+ import { getOrCreateConsentRuntime } from 'c15t';
127
+ import { snapchatPixelEvent } from '@c15t/scripts/snapchat-pixel';
128
+
129
+ const { consentStore } = getOrCreateConsentRuntime();
130
+
131
+ if (consentStore.getState().has('marketing')) {
132
+ snapchatPixelEvent('PURCHASE', { price: 99, currency: 'USD' });
133
+ }
134
+ ```
135
+
136
+ ## Types
137
+
138
+ ### SnapchatPixelOptions
139
+
140
+ |Property|Value|
141
+ |:--|:--|
142
+ |Type Name|\`SnapchatPixelOptions\`|
143
+ |Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/snapchat-pixel.ts\`|
144
+
145
+ \*ExtractedTypeTable: Could not extract "SnapchatPixelOptions" from "./packages/scripts/src/vendors/ads-and-pixels/snapchat-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
146
+
147
+ ### SnapchatPixelEventProperties
148
+
149
+ |Property|Value|
150
+ |:--|:--|
151
+ |Type Name|\`SnapchatPixelEventProperties\`|
152
+ |Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/snapchat-pixel.ts\`|
153
+
154
+ \*ExtractedTypeTable: Could not extract "SnapchatPixelEventProperties" from "./packages/scripts/src/vendors/ads-and-pixels/snapchat-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
155
+
156
+ ### Script
157
+
158
+ |Property|Value|
159
+ |:--|:--|
160
+ |Type Name|\`Script\`|
161
+ |Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
162
+
163
+ \*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
@@ -0,0 +1,123 @@
1
+ ---
2
+ title: TikTok Pixel
3
+ description: Measure ad performance and build audiences for TikTok advertising campaigns.
4
+ icon: tiktok
5
+ group: integrations
6
+ ---
7
+ 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.
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 { tiktokPixel } from '@c15t/scripts/tiktok-pixel';
17
+
18
+ const scripts = [tiktokPixel({ pixelId: '123456789012345' })];
19
+
20
+ export function ConsentProvider({ children }: { children: ReactNode }) {
21
+ return (
22
+ <ConsentManagerProvider
23
+ options={{
24
+ mode: 'hosted',
25
+ backendURL: 'https://your-instance.c15t.dev',
26
+ scripts,
27
+ }}
28
+ >
29
+ {children}
30
+ </ConsentManagerProvider>
31
+ );
32
+ }
33
+ ```
34
+
35
+ **Next.js**
36
+
37
+ ```tsx
38
+ 'use client';
39
+
40
+ import { type ReactNode } from 'react';
41
+ import { ConsentManagerProvider } from '@c15t/nextjs';
42
+ import { tiktokPixel } from '@c15t/scripts/tiktok-pixel';
43
+
44
+ const scripts = [tiktokPixel({ pixelId: '123456789012345' })];
45
+
46
+ export function ConsentProvider({ children }: { children: ReactNode }) {
47
+ return (
48
+ <ConsentManagerProvider
49
+ options={{
50
+ mode: 'hosted',
51
+ backendURL: '/api/c15t',
52
+ scripts,
53
+ }}
54
+ >
55
+ {children}
56
+ </ConsentManagerProvider>
57
+ );
58
+ }
59
+ ```
60
+
61
+ **JavaScript**
62
+
63
+ ```ts
64
+ import { getOrCreateConsentRuntime } from 'c15t';
65
+ import { tiktokPixel } from '@c15t/scripts/tiktok-pixel';
66
+
67
+ getOrCreateConsentRuntime({
68
+ mode: 'hosted',
69
+ backendURL: 'https://your-instance.c15t.dev',
70
+ scripts: [tiktokPixel({ pixelId: '123456789012345' })],
71
+ });
72
+ ```
73
+
74
+ ## How c15t loads it
75
+
76
+ * **Category:** `marketing` (Ads & Pixels)
77
+ * **Loads when:** marketing consent is granted
78
+ * **On revocation:** [persists](/docs/frameworks/react/script-loader#persist-after-revocation) — c15t pushes the new consent state to `ttq` so TikTok stops tracking without removing the script
79
+
80
+ ## Tracking events in your app
81
+
82
+ c15t gates the TikTok Pixel script from loading until `marketing` consent is granted. After consent is granted the script stays in the DOM, and c15t pushes the new consent state to `ttq` if consent is later revoked.
83
+
84
+ This means `window.ttq` is only defined after the user has granted marketing consent at least once. Before that, unguarded calls throw. After that, calls are safe — TikTok's own consent state suppresses tracking when revoked.
85
+
86
+ ```tsx
87
+ import { useCallback } from 'react';
88
+ import { useConsentManager } from '@c15t/react';
89
+
90
+ function useTrackPurchase() {
91
+ const { has } = useConsentManager();
92
+ return useCallback(() => {
93
+ if (has('marketing')) {
94
+ window.ttq?.track('CompletePayment', { value: 10.0, currency: 'USD' });
95
+ }
96
+ }, [has]);
97
+ }
98
+
99
+ function PurchaseButton() {
100
+ const trackPurchase = useTrackPurchase();
101
+ return <button onClick={trackPurchase}>Complete purchase</button>;
102
+ }
103
+ ```
104
+
105
+ ## Types
106
+
107
+ ### TikTokPixelOptions
108
+
109
+ |Property|Value|
110
+ |:--|:--|
111
+ |Type Name|\`TikTokPixelOptions\`|
112
+ |Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/tiktok-pixel.ts\`|
113
+
114
+ \*ExtractedTypeTable: Could not extract "TikTokPixelOptions" from "./packages/scripts/src/vendors/ads-and-pixels/tiktok-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
115
+
116
+ ### Script
117
+
118
+ |Property|Value|
119
+ |:--|:--|
120
+ |Type Name|\`Script\`|
121
+ |Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
122
+
123
+ \*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
@@ -0,0 +1,148 @@
1
+ ---
2
+ title: Umami Analytics
3
+ description: Open-source, cookieless analytics with a prebuilt helper that maps
4
+ Umami's data attributes into a c15t-managed script.
5
+ group: integrations
6
+ icon: umami-analytics
7
+ ---
8
+ Umami is an open-source, cookieless analytics product configured entirely through `data-*` attributes on its loader. The `umamiAnalytics()` helper serializes your website ID, host override, and tracking options into those attributes and hands the result to c15t's script loader.
9
+
10
+ ## Integrate with c15t
11
+
12
+ **React**
13
+
14
+ ```tsx
15
+ import { type ReactNode } from 'react';
16
+ import { ConsentManagerProvider } from '@c15t/react';
17
+ import { umamiAnalytics } from '@c15t/scripts/umami-analytics';
18
+
19
+ const scripts = [umamiAnalytics({ websiteId: 'site-abc-123' })];
20
+
21
+ export function ConsentProvider({ children }: { children: ReactNode }) {
22
+ return (
23
+ <ConsentManagerProvider
24
+ options={{
25
+ mode: 'hosted',
26
+ backendURL: 'https://your-instance.c15t.dev',
27
+ scripts,
28
+ }}
29
+ >
30
+ {children}
31
+ </ConsentManagerProvider>
32
+ );
33
+ }
34
+ ```
35
+
36
+ **Next.js**
37
+
38
+ ```tsx
39
+ 'use client';
40
+
41
+ import { type ReactNode } from 'react';
42
+ import { ConsentManagerProvider } from '@c15t/nextjs';
43
+ import { umamiAnalytics } from '@c15t/scripts/umami-analytics';
44
+
45
+ const scripts = [umamiAnalytics({ websiteId: 'site-abc-123' })];
46
+
47
+ export function ConsentProvider({ children }: { children: ReactNode }) {
48
+ return (
49
+ <ConsentManagerProvider
50
+ options={{
51
+ mode: 'hosted',
52
+ backendURL: '/api/c15t',
53
+ scripts,
54
+ }}
55
+ >
56
+ {children}
57
+ </ConsentManagerProvider>
58
+ );
59
+ }
60
+ ```
61
+
62
+ **JavaScript**
63
+
64
+ ```ts
65
+ import { getOrCreateConsentRuntime } from 'c15t';
66
+ import { umamiAnalytics } from '@c15t/scripts/umami-analytics';
67
+
68
+ getOrCreateConsentRuntime({
69
+ mode: 'hosted',
70
+ backendURL: 'https://your-instance.c15t.dev',
71
+ scripts: [umamiAnalytics({ websiteId: 'site-abc-123' })],
72
+ });
73
+ ```
74
+
75
+ ## How c15t loads it
76
+
77
+ * **Category:** `measurement` (Analytics)
78
+ * **Loads when:** measurement consent is granted
79
+ * **On revocation:** unloaded — c15t removes the script element from the DOM. Umami is cookieless, so no client-side state needs clearing.
80
+
81
+ If you self-host Umami or need to restrict tracking to specific domains:
82
+
83
+ ```ts
84
+ umamiAnalytics({
85
+ websiteId: 'site-abc-123',
86
+ hostUrl: 'https://analytics.example.com',
87
+ domains: ['example.com', 'www.example.com'],
88
+ autoTrack: false,
89
+ tag: 'release-2025',
90
+ })
91
+ ```
92
+
93
+ Each option is mapped to Umami's published `data-*` attribute (`data-website-id`, `data-host-url`, `data-auto-track`, `data-domains`, `data-tag`, `data-before-send`) and the script uses `defer` so it matches Umami's recommended embed pattern.
94
+
95
+ > 📝 **Note:**
96
+ > beforeSend accepts a string referencing a global hook (e.g. 'window\.umamiBeforeSend'), not a function value. The c15t manifest runtime serializes script configuration, so inline callbacks cannot be passed through it.
97
+
98
+ ## Tracking events in your app
99
+
100
+ c15t gates the Umami script from loading until `measurement` consent is granted. Your application code that calls Umami's runtime API (`window.umami.track`, `window.umami.identify`) is **not** automatically gated — `window.umami` does not exist until the script is loaded, so unguarded calls before consent throw.
101
+
102
+ Guard event calls by checking consent state. From React:
103
+
104
+ ```tsx
105
+ import { useConsentManager } from '@c15t/react';
106
+
107
+ function useTrackSignup() {
108
+ const { has } = useConsentManager();
109
+
110
+ return () => {
111
+ if (has('measurement')) {
112
+ window.umami?.track('signup');
113
+ }
114
+ };
115
+ }
116
+ ```
117
+
118
+ From plain JavaScript:
119
+
120
+ ```ts
121
+ import { getOrCreateConsentRuntime } from 'c15t';
122
+
123
+ const { consentStore } = getOrCreateConsentRuntime();
124
+
125
+ if (consentStore.getState().has('measurement')) {
126
+ window.umami?.track('signup');
127
+ }
128
+ ```
129
+
130
+ ## Types
131
+
132
+ ### UmamiAnalyticsOptions
133
+
134
+ |Property|Value|
135
+ |:--|:--|
136
+ |Type Name|\`UmamiAnalyticsOptions\`|
137
+ |Source Path|\`./packages/scripts/src/vendors/analytics/umami-analytics.ts\`|
138
+
139
+ \*ExtractedTypeTable: Could not extract "UmamiAnalyticsOptions" from "./packages/scripts/src/vendors/analytics/umami-analytics.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
140
+
141
+ ### Script
142
+
143
+ |Property|Value|
144
+ |:--|:--|
145
+ |Type Name|\`Script\`|
146
+ |Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
147
+
148
+ \*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*