@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
@@ -0,0 +1,246 @@
1
+ ---
2
+ title: Matomo Analytics
3
+ description: Load Matomo with c15t and keep Matomo's queue aligned with measurement consent.
4
+ lastModified: 2026-05-10
5
+ icon: matomo
6
+ ---
7
+ Matomo gives you privacy-focused web analytics with self-hosted and cloud deployment options. The `matomoAnalytics()` helper sets up Matomo's `_paq` queue, points it at your tracker, and can queue consent-aware commands before the vendor bundle 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 { matomoAnalytics } from '@c15t/scripts/matomo-analytics';
17
+
18
+ const scripts = [
19
+ matomoAnalytics({
20
+ matomoUrl: 'https://analytics.example.com',
21
+ siteId: 1,
22
+ }),
23
+ ];
24
+
25
+ export function ConsentProvider({ children }: { children: ReactNode }) {
26
+ return (
27
+ <ConsentManagerProvider
28
+ options={{
29
+ mode: 'hosted',
30
+ backendURL: 'https://your-instance.c15t.dev',
31
+ scripts,
32
+ }}
33
+ >
34
+ {children}
35
+ </ConsentManagerProvider>
36
+ );
37
+ }
38
+ ```
39
+
40
+ **Next.js**
41
+
42
+ ```tsx
43
+ 'use client';
44
+
45
+ import { type ReactNode } from 'react';
46
+ import { ConsentManagerProvider } from '@c15t/nextjs';
47
+ import { matomoAnalytics } from '@c15t/scripts/matomo-analytics';
48
+
49
+ const scripts = [
50
+ matomoAnalytics({
51
+ matomoUrl: 'https://analytics.example.com',
52
+ siteId: 1,
53
+ }),
54
+ ];
55
+
56
+ export function ConsentProvider({ children }: { children: ReactNode }) {
57
+ return (
58
+ <ConsentManagerProvider
59
+ options={{
60
+ mode: 'hosted',
61
+ backendURL: '/api/c15t',
62
+ scripts,
63
+ }}
64
+ >
65
+ {children}
66
+ </ConsentManagerProvider>
67
+ );
68
+ }
69
+ ```
70
+
71
+ **JavaScript**
72
+
73
+ ```ts
74
+ import { getOrCreateConsentRuntime } from 'c15t';
75
+ import { matomoAnalytics } from '@c15t/scripts/matomo-analytics';
76
+
77
+ getOrCreateConsentRuntime({
78
+ mode: 'hosted',
79
+ backendURL: 'https://your-instance.c15t.dev',
80
+ scripts: [
81
+ matomoAnalytics({
82
+ matomoUrl: 'https://analytics.example.com',
83
+ siteId: 1,
84
+ }),
85
+ ],
86
+ });
87
+ ```
88
+
89
+ ## How c15t loads it
90
+
91
+ * **Category:** `measurement` (Analytics)
92
+ * **Loads when:** measurement consent is granted by default
93
+ * **Consent mode option:** with `defaultConsent`, the helper switches to `alwaysLoad: true` and uses Matomo queue commands to grant/forget consent without unloading the SDK.
94
+
95
+ ## Configure the integration
96
+
97
+ If you want Matomo to manage consent internally, set `defaultConsent` to one
98
+ of these values:
99
+
100
+ * `'required'` queues Matomo's `requireConsent` command so no tracking runs
101
+ until consent is granted.
102
+ * `'given'` queues Matomo's `setConsentGiven` command so tracking starts as
103
+ granted by default.
104
+
105
+ When `defaultConsent` is omitted, c15t uses the standard script-loader flow:
106
+ Matomo only loads after `measurement` consent is granted.
107
+
108
+ ```ts
109
+ import { matomoAnalytics } from '@c15t/scripts/matomo-analytics';
110
+
111
+ matomoAnalytics({
112
+ matomoUrl: 'https://analytics.example.com',
113
+ siteId: 1,
114
+ defaultConsent: 'required',
115
+ });
116
+ ```
117
+
118
+ ## Tracking events in your app
119
+
120
+ Matomo's runtime API is queue-based (`window._paq`). When the script is not loaded yet, pushing to `_paq` is still safe as long as the queue exists. The helper creates `_paq` during setup.
121
+
122
+ From React:
123
+
124
+ ```tsx
125
+ import { useCallback } from 'react';
126
+ import { useConsentManager } from '@c15t/react';
127
+
128
+ function SignupExample() {
129
+ const { has } = useConsentManager();
130
+
131
+ const trackSignup = useCallback(() => {
132
+ if (has('measurement')) {
133
+ window._paq?.push(['trackEvent', 'signup', 'completed']);
134
+ }
135
+ }, [has]);
136
+
137
+ return <button onClick={trackSignup}>Sign up</button>;
138
+ }
139
+ ```
140
+
141
+ From plain JavaScript:
142
+
143
+ ```ts
144
+ import { getOrCreateConsentRuntime } from 'c15t';
145
+
146
+ const { consentStore } = getOrCreateConsentRuntime();
147
+
148
+ if (consentStore.getState().has('measurement')) {
149
+ window._paq?.push(['trackEvent', 'signup', 'completed']);
150
+ }
151
+ ```
152
+
153
+ ## Types
154
+
155
+ ### MatomoAnalyticsOptions
156
+
157
+ |Property|Type|Description|Default|Required|
158
+ |:--|:--|:--|:--|:--:|
159
+ |siteId|string \|number \|undefined|Your Matomo site ID.|-|Optional|
160
+ |matomoUrl|string \|undefined|Your Matomo base URL, for example \`https\://analytics.example.com\`.|-|Optional|
161
+ |cloudId|string \|undefined|Your Matomo Cloud identifier, for example \`my-site.matomo.cloud\`.|-|Optional|
162
+ |trackerUrl|string \|undefined|Optional explicit tracker endpoint override.|-|Optional|
163
+ |scriptUrl|string \|undefined|Optional explicit script URL override.|-|Optional|
164
+ |enableLinkTracking|boolean \|undefined|Queue \`enableLinkTracking\`.|-|Optional|
165
+ |disableCookies|boolean \|undefined|Queue \`disableCookies\`.|-|Optional|
166
+ |trackPageView|boolean \|undefined|Queue an initial \`trackPageView\`.|-|Optional|
167
+ |defaultConsent|"required" \|"given" \|undefined|Default Matomo consent state (\`required\` blocks, \`given\` starts enabled).|-|Optional|
168
+
169
+ ### Script
170
+
171
+ |Property|Type|Description|Default|Required|
172
+ |:--|:--|:--|:--|:--:|
173
+ |id|string|Unique identifier for the script|-|✅ Required|
174
+ |src|string \|undefined|URL of the script to load|-|Optional|
175
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
176
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
177
+ |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|
178
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
179
+ |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|
180
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
181
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
182
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
183
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
184
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
185
+ |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|
186
+ |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|
187
+ |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
188
+ |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
189
+ |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
190
+ |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
191
+ |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|
192
+ |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|
193
+ |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|
194
+ |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|
195
+
196
+ #### `onBeforeLoad`
197
+
198
+ Callback executed before the script is loaded
199
+
200
+ |Property|Type|Description|Default|Required|
201
+ |:--|:--|:--|:--|:--:|
202
+ |id|string|The original script ID|-|✅ Required|
203
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
204
+ |hasConsent|boolean|Has consent|-|✅ Required|
205
+ |consents|ConsentState|The current consent state|-|✅ Required|
206
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
207
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
208
+
209
+ #### `onLoad`
210
+
211
+ Callback executed when the script loads successfully
212
+
213
+ |Property|Type|Description|Default|Required|
214
+ |:--|:--|:--|:--|:--:|
215
+ |id|string|The original script ID|-|✅ Required|
216
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
217
+ |hasConsent|boolean|Has consent|-|✅ Required|
218
+ |consents|ConsentState|The current consent state|-|✅ Required|
219
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
220
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
221
+
222
+ #### `onError`
223
+
224
+ Callback executed if the script fails to load
225
+
226
+ |Property|Type|Description|Default|Required|
227
+ |:--|:--|:--|:--|:--:|
228
+ |id|string|The original script ID|-|✅ Required|
229
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
230
+ |hasConsent|boolean|Has consent|-|✅ Required|
231
+ |consents|ConsentState|The current consent state|-|✅ Required|
232
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
233
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
234
+
235
+ #### `onConsentChange`
236
+
237
+ Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
238
+
239
+ |Property|Type|Description|Default|Required|
240
+ |:--|:--|:--|:--|:--:|
241
+ |id|string|The original script ID|-|✅ Required|
242
+ |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
243
+ |hasConsent|boolean|Has consent|-|✅ Required|
244
+ |consents|ConsentState|The current consent state|-|✅ Required|
245
+ |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
246
+ |error|Error \|undefined|Error information (for error callbacks)|-|Optional|