@c15t/nextjs 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 (32) hide show
  1. package/dist/version.cjs +1 -1
  2. package/dist/version.js +1 -1
  3. package/dist-types/version.d.ts +1 -1
  4. package/docs/integrations/ahrefs-analytics.md +224 -0
  5. package/docs/integrations/cloudflare-web-analytics.md +194 -0
  6. package/docs/integrations/crisp.md +214 -0
  7. package/docs/integrations/databuddy.md +136 -65
  8. package/docs/integrations/fathom-analytics.md +221 -0
  9. package/docs/integrations/google-tag-manager.md +84 -15
  10. package/docs/integrations/google-tag.md +89 -8
  11. package/docs/integrations/hotjar.md +211 -0
  12. package/docs/integrations/intercom.md +214 -0
  13. package/docs/integrations/linkedin-insights.md +130 -11
  14. package/docs/integrations/matomo-analytics.md +246 -0
  15. package/docs/integrations/meta-pixel.md +377 -24
  16. package/docs/integrations/microsoft-clarity.md +241 -0
  17. package/docs/integrations/microsoft-uet.md +120 -9
  18. package/docs/integrations/mixpanel-analytics.md +198 -0
  19. package/docs/integrations/overview.md +69 -74
  20. package/docs/integrations/plausible-analytics.md +237 -0
  21. package/docs/integrations/posthog.md +172 -41
  22. package/docs/integrations/promptwatch.md +187 -0
  23. package/docs/integrations/reddit-pixel.md +336 -0
  24. package/docs/integrations/rybbit-analytics.md +222 -0
  25. package/docs/integrations/segment.md +213 -0
  26. package/docs/integrations/snapchat-pixel.md +244 -0
  27. package/docs/integrations/tiktok-pixel.md +88 -10
  28. package/docs/integrations/umami-analytics.md +220 -0
  29. package/docs/integrations/vercel-analytics.md +213 -0
  30. package/docs/integrations/x-pixel.md +99 -10
  31. package/docs/script-loader.md +261 -63
  32. package/package.json +4 -4
@@ -1,105 +1,100 @@
1
1
  ---
2
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: 2026-04-10
3
+ description: "Load analytics, pixels, tag managers, and widgets through c15t so consent state controls when they run, update, and appear in your consent UI."
4
+ lastModified: 2026-05-12
5
5
 
6
6
  ---
7
- c15t supports two integration styles:
7
+ Third-party tools are easy to paste into app code, but consent makes them part
8
+ of your privacy runtime. Analytics SDKs, ad pixels, tag managers, and chat
9
+ widgets can load remote code, store identifiers, send events, and keep running
10
+ after the first page view.
8
11
 
9
- * use a prebuilt helper from `@c15t/scripts`
10
- * build your own script or manifest-backed helper
12
+ > ℹ️ **Info:**
13
+ > Put consent-sensitive vendor tools in c15t instead of scattering script tags across your codebase. c15t becomes the place that decides when they can load, when they must stop, and which consent categories your UI needs to show.
11
14
 
12
- If you are building something reusable or contributing to `@c15t/scripts`, start with the [custom integration guide](/docs/integrations/building-integrations).
15
+ ## Why Manage Tools In c15t
13
16
 
14
- ## General Pattern
17
+ When you install a vendor directly in your app, your consent logic has to chase
18
+ that vendor everywhere it appears: page layouts, route handlers, event helpers,
19
+ tag-manager snippets, and cleanup code.
15
20
 
16
- Every integration provides a script configuration function. Pass it to your framework's setup:
21
+ Register the vendor with c15t instead. The integration becomes a declarative
22
+ `Script` that the consent runtime can reason about:
17
23
 
18
- **JavaScript**
24
+ * c15t registers the tool with the runtime and evaluates it against the current
25
+ consent state;
26
+ * c15t automatically adds the tool's consent category to the active categories,
27
+ so GDPR-style consent UIs include `measurement`, `marketing`, or
28
+ `functionality` when an enabled integration needs them;
29
+ * c15t blocks the script until consent is granted, or loads it with denied
30
+ defaults when the vendor has its own consent mode;
31
+ * c15t handles revocation by unloading the script or calling the vendor's
32
+ consent API;
33
+ * c15t runs vendor setup in the right order, including queue stubs, global
34
+ functions, data attributes, default page-view events, and consent updates.
19
35
 
20
- ```ts
21
- import { getOrCreateConsentRuntime } from 'c15t';
22
- import { yourScript } from '@c15t/scripts/your-script';
36
+ That gives your app one consent lifecycle instead of many scattered vendor
37
+ lifecycles.
23
38
 
24
- getOrCreateConsentRuntime({
25
- mode: 'hosted',
26
- scripts: [
27
- yourScript({ /* options */ }),
28
- ],
29
- });
30
- ```
39
+ ## Built-In Helpers
31
40
 
32
- **React**
41
+ c15t ships prebuilt helpers in
42
+ [`@c15t/scripts`](https://www.npmjs.com/package/@c15t/scripts) for the
43
+ third-party tools developers integrate most often. Prefer them over copied
44
+ vendor snippets whenever c15t already supports the vendor.
33
45
 
34
- ```tsx
35
- import { yourScript } from '@c15t/scripts/your-script';
36
- import { ConsentManagerProvider } from '@c15t/react';
46
+ Every helper returns a regular `Script` object, so it works anywhere the c15t
47
+ [script loader](/docs/frameworks/javascript/script-loader) accepts scripts. You
48
+ usually choose the helper, provide the vendor ID, and pass the result to your
49
+ provider's `scripts` option. The vendor page explains anything else that still
50
+ matters, such as custom events, region settings, privacy modes, or ecommerce
51
+ payloads.
37
52
 
38
- export function App({ children }: { children: React.ReactNode }) {
39
- return (
40
- <ConsentManagerProvider
41
- options={{
42
- scripts: [
43
- yourScript({ /* options */ }),
44
- ],
45
- }}
46
- >
47
- {children}
48
- </ConsentManagerProvider>
49
- );
50
- }
51
- ```
53
+ ## Choose An Integration Style
52
54
 
53
- **Next.js**
55
+ Most apps mix more than one style. Pick the smallest one that keeps consent behavior obvious.
54
56
 
55
- ```tsx
56
- import { yourScript } from '@c15t/scripts/your-script';
57
- import { ConsentManagerProvider } from '@c15t/nextjs';
57
+ |Style|Use when|
58
+ |--|--|
59
+ |**Built-in helper** from `@c15t/scripts`|The vendor is listed below — start here.|
60
+ |**Plain `Script`**|One-off app code with simple load and callback behavior.|
61
+ |**Manifest-backed helper**|Reusable vendor integration with structured setup phases, queues, stubs, or a vendor consent API.|
62
+ |**Iframe / renderable integration**|Vendor exposes an iframe or React component, not just a script tag.|
58
63
 
59
- export function App({ children }: { children: React.ReactNode }) {
60
- return (
61
- <ConsentManagerProvider
62
- options={{
63
- scripts: [
64
- yourScript({ /* options */ }),
65
- ],
66
- }}
67
- >
68
- {children}
69
- </ConsentManagerProvider>
70
- );
71
- }
72
- ```
64
+ Setup is the same shape in every framework: import the helper, call it with vendor options, and pass the result to the consent runtime through your provider's `scripts` option. See the framework guides for end-to-end snippets — [JavaScript](/docs/frameworks/javascript/script-loader), [React](/docs/frameworks/react/script-loader), [Next.js](/docs/frameworks/next/script-loader).
73
65
 
74
- ## Script Loader
66
+ ## Analytics
75
67
 
76
- 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.
68
+ Analytics integrations usually require `measurement` consent. Some vendors can run in a consent-aware or cookieless mode; others should stay fully blocked until measurement consent is granted.
77
69
 
78
- c15t's script loader allows you to easily integrate your tools that require consent with c15t. The prebuilt integrations in `@c15t/scripts` are the recommended starting point, and the custom integration guide explains how to build your own when you need something more specialized.
70
+ ## Functional
79
71
 
80
- * [JavaScript](/docs/frameworks/javascript/script-loader)
81
- * [React](/docs/frameworks/react/script-loader)
82
- * [Next.js](/docs/frameworks/next/script-loader)
72
+ Functional integrations usually require `functionality` consent. They add optional user-facing capabilities, such as chat widgets, that should only run after the user allows them.
83
73
 
84
- ## Building Your Own
74
+ ## Ads & Pixels
85
75
 
86
- If you need a vendor we do not ship yet:
76
+ Advertising pixels usually require `marketing` consent. Many of them need startup stubs so events can be queued safely before the remote SDK loads — built-in helpers handle this for you.
87
77
 
88
- * build a one-off `Script` directly in your app for simple cases
89
- * build a reusable manifest-backed helper for shared or package-level integrations
78
+ ## Tag Managers
90
79
 
91
- Read the [custom integration guide](/docs/integrations/building-integrations) for the manifest phases, structured step model, testing checklist, and devtools debugging flow.
80
+ Tag managers can load other scripts, so they deserve extra care. Prefer vendor consent modes and denied defaults before any tags are allowed to run.
92
81
 
93
- ## has() method
82
+ ## Build Your Own
94
83
 
95
- 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).
84
+ If c15t does not ship the vendor you need, drop down a level:
96
85
 
97
- ```ts
86
+ * build a one-off `Script` directly in your app for simple cases,
87
+ * build a reusable manifest-backed helper for shared or package-level integrations,
88
+ * or combine the script loader with iframe gating for visible media and widget integrations.
98
89
 
90
+ ### Build a Custom Integration
99
91
 
100
- const hasAnalytics = has('measurement');
92
+ Learn when to use a raw `Script`, when to use a manifest, and how to debug and test custom integrations.
101
93
 
102
- if (hasAnalytics) {
103
- myAnalyticsLibrary.track('checkout_completed');
104
- }
105
- ```
94
+ [Read the guide →](/docs/integrations/building-integrations)
95
+
96
+ ## Where To Next
97
+
98
+ * Read the script loader guide for your framework: [JavaScript](/docs/frameworks/javascript/script-loader), [React](/docs/frameworks/react/script-loader), [Next.js](/docs/frameworks/next/script-loader).
99
+ * See the [iframe blocking](/docs/frameworks/react/iframe-blocking) pattern for visible embeds (YouTube, maps, calendars).
100
+ * Use [`has()`](/docs/frameworks/javascript/store/checking-consent) to conditionally run app code based on consent state.
@@ -0,0 +1,237 @@
1
+ ---
2
+ title: Plausible Analytics
3
+ description: Privacy-friendly cookieless analytics with a prebuilt helper that preserves Plausible's queue bootstrap and loader attributes.
4
+ lastModified: 2026-05-10
5
+ icon: plausible
6
+ ---
7
+ Plausible Analytics is a privacy-friendly, cookieless analytics product with a lightweight script loader. The `plausibleAnalytics()` helper models Plausible's queue bootstrap and script attributes as a c15t-managed script so early `window.plausible(...)` calls are buffered safely until the tracker loads.
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 { plausibleAnalytics } from '@c15t/scripts/plausible-analytics';
17
+
18
+ const scripts = [plausibleAnalytics({ domain: 'example.com' })];
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 { plausibleAnalytics } from '@c15t/scripts/plausible-analytics';
43
+
44
+ const scripts = [plausibleAnalytics({ domain: 'example.com' })];
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 { plausibleAnalytics } from '@c15t/scripts/plausible-analytics';
66
+
67
+ getOrCreateConsentRuntime({
68
+ mode: 'hosted',
69
+ backendURL: 'https://your-instance.c15t.dev',
70
+ scripts: [plausibleAnalytics({ domain: 'example.com' })],
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 element from the DOM. Plausible is cookieless, so no client-side state needs clearing.
79
+
80
+ If you need script extensions or hash-based routing support, pass them through the helper:
81
+
82
+ ```ts
83
+ plausibleAnalytics({
84
+ domain: 'example.com',
85
+ extension: ['file-downloads', 'outbound-links'],
86
+ hashBasedRouting: true,
87
+ })
88
+ ```
89
+
90
+ The helper seeds a `window.plausible` queue stub during `onBeforeLoad`, so any calls made between the consent grant and the real script attaching get buffered into `plausible.q` and replayed. It also maps the legacy `data-domain` / `data-api` attributes and the new `scriptId`-based loader URL automatically.
91
+
92
+ ## Tracking events in your app
93
+
94
+ c15t gates the Plausible script from loading until `measurement` consent is granted. Your application code that calls Plausible is **not** automatically gated — `window.plausible` does not exist until the script is loaded, so unguarded calls before consent throw.
95
+
96
+ Guard event calls by checking consent state. From React:
97
+
98
+ ```tsx
99
+ import { useCallback } from 'react';
100
+ import { useConsentManager } from '@c15t/react';
101
+
102
+ function useTrackSignup() {
103
+ const { has } = useConsentManager();
104
+
105
+ return useCallback(() => {
106
+ if (has('measurement')) {
107
+ window.plausible?.('Signup');
108
+ }
109
+ }, [has]);
110
+ }
111
+
112
+ function SignupButton() {
113
+ const trackSignup = useTrackSignup();
114
+
115
+ return (
116
+ <button type="button" onClick={trackSignup}>
117
+ Sign up
118
+ </button>
119
+ );
120
+ }
121
+ ```
122
+
123
+ From plain JavaScript:
124
+
125
+ ```ts
126
+ import { getOrCreateConsentRuntime } from 'c15t';
127
+
128
+ const { consentStore } = getOrCreateConsentRuntime();
129
+
130
+ if (consentStore.getState().has('measurement')) {
131
+ window.plausible?.('Signup');
132
+ }
133
+ ```
134
+
135
+ ## Types
136
+
137
+ ### PlausibleAnalyticsOptions
138
+
139
+ |Property|Type|Description|Default|Required|
140
+ |:--|:--|:--|:--|:--:|
141
+ |scriptId|string \|undefined|Unique Plausible script ID for the new script format.|-|Optional|
142
+ |domain|string \|undefined|Legacy domain-based site identifier.|-|Optional|
143
+ |extension|PlausibleExtension \|undefined|Legacy script extensions.|-|Optional|
144
+ |customProperties|Record\<string, unknown> \|undefined|Properties tracked with each pageview.|-|Optional|
145
+ |endpoint|string \|undefined|Custom tracking endpoint.|-|Optional|
146
+ |fileDownloads|Object \|undefined|File download tracking configuration.|-|Optional|
147
+ |hashBasedRouting|boolean \|undefined|Enable hash-based routing support.|-|Optional|
148
+ |autoCapturePageviews|boolean \|undefined|Disable automatic pageview capture when set to \`false\`.|-|Optional|
149
+ |captureOnLocalhost|boolean \|undefined|Enable tracking on localhost.|-|Optional|
150
+ |scriptUrl|string \|undefined|Custom loader URL.|-|Optional|
151
+
152
+ #### `fileDownloads`
153
+
154
+ File download tracking configuration.
155
+
156
+ |Property|Type|Description|Default|Required|
157
+ |:--|:--|:--|:--|:--:|
158
+ |fileExtensions|string\[] \|undefined|-|-|Optional|
159
+
160
+ ### Script
161
+
162
+ |Property|Type|Description|Default|Required|
163
+ |:--|:--|:--|:--|:--:|
164
+ |id|string|Unique identifier for the script|-|✅ Required|
165
+ |src|string \|undefined|URL of the script to load|-|Optional|
166
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
167
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
168
+ |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|
169
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
170
+ |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|
171
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
172
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
173
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
174
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
175
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
176
+ |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|
177
+ |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|
178
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
179
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
180
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
181
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
182
+ |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|
183
+ |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|
184
+ |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|
185
+ |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|
186
+
187
+ #### `onBeforeLoad`
188
+
189
+ Callback executed before the script is 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|
199
+
200
+ #### `onLoad`
201
+
202
+ Callback executed when the script loads successfully
203
+
204
+ |Property|Type|Description|Default|Required|
205
+ |:--|:--|:--|:--|:--:|
206
+ |id|string|The original script ID|-|✅ Required|
207
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
208
+ |hasConsent|boolean|Has consent|-|✅ Required|
209
+ |consents|ConsentState|The current consent state|-|✅ Required|
210
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
211
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
212
+
213
+ #### `onError`
214
+
215
+ Callback executed if the script fails to load
216
+
217
+ |Property|Type|Description|Default|Required|
218
+ |:--|:--|:--|:--|:--:|
219
+ |id|string|The original script ID|-|✅ Required|
220
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
221
+ |hasConsent|boolean|Has consent|-|✅ Required|
222
+ |consents|ConsentState|The current consent state|-|✅ Required|
223
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
224
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
225
+
226
+ #### `onConsentChange`
227
+
228
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
229
+
230
+ |Property|Type|Description|Default|Required|
231
+ |:--|:--|:--|:--|:--:|
232
+ |id|string|The original script ID|-|✅ Required|
233
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
234
+ |hasConsent|boolean|Has consent|-|✅ Required|
235
+ |consents|ConsentState|The current consent state|-|✅ Required|
236
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
237
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|