@c15t/nextjs 2.1.0 → 2.2.1
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.
- package/AGENTS.md +155 -0
- package/README.md +31 -15
- package/client/components/integrations.js +3 -0
- package/dist/components/integrations/index.cjs +1 -0
- package/dist/components/integrations/index.js +1 -0
- package/dist/headless.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/libs/browser-initial-data.cjs +1 -1
- package/dist/libs/initial-data.cjs +1 -1
- package/dist/styles.tw3.css +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist-types/components/integrations/index.d.ts +1 -0
- package/dist-types/libs/browser-initial-data.d.ts +1 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +155 -73
- package/docs/{building-headless-components.md → frameworks/next/building-headless-components.md} +3 -1
- package/docs/{callbacks.md → frameworks/next/callbacks.md} +3 -1
- package/docs/{components → frameworks/next/components}/consent-banner.md +10 -21
- package/docs/{components → frameworks/next/components}/consent-dialog-link.md +8 -5
- package/docs/frameworks/next/components/consent-dialog-trigger.md +202 -0
- package/docs/{components → frameworks/next/components}/consent-dialog.md +7 -15
- package/docs/frameworks/next/components/consent-manager-provider.md +327 -0
- package/docs/{components → frameworks/next/components}/consent-widget.md +8 -6
- package/docs/{components → frameworks/next/components}/dev-tools.md +9 -6
- package/docs/{components → frameworks/next/components}/frame.md +8 -9
- package/docs/{concepts → frameworks/next/concepts}/client-modes.md +4 -2
- package/docs/{concepts → frameworks/next/concepts}/consent-categories.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/consent-models.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/cookie-management.md +3 -3
- package/docs/{concepts → frameworks/next/concepts}/glossary.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/initialization-flow.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/policy-packs.md +1 -0
- package/docs/{headless.md → frameworks/next/headless.md} +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-color-scheme.md +1 -0
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/checking-consent.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/location-info.md +3 -1
- package/docs/frameworks/next/hooks/use-consent-manager/overview.md +185 -0
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/setting-consent.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-draggable.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-focus-trap.md +1 -0
- package/docs/{hooks → frameworks/next/hooks}/use-reduced-motion.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-ssr-status.md +6 -5
- package/docs/{hooks → frameworks/next/hooks}/use-text-direction.md +1 -0
- package/docs/frameworks/next/hooks/use-translations.md +55 -0
- package/docs/{iab → frameworks/next/iab}/consent-banner.md +9 -12
- package/docs/{iab → frameworks/next/iab}/consent-dialog.md +9 -14
- package/docs/{iab → frameworks/next/iab}/overview.md +4 -2
- package/docs/{iab → frameworks/next/iab}/use-gvl-data.md +3 -2
- package/docs/{iframe-blocking.md → frameworks/next/iframe-blocking.md} +8 -9
- package/docs/{internationalization.md → frameworks/next/internationalization.md} +13 -3
- package/docs/{network-blocker.md → frameworks/next/network-blocker.md} +13 -51
- package/docs/{optimization.md → frameworks/next/optimization.md} +5 -4
- package/docs/{policy-packs.md → frameworks/next/policy-packs.md} +3 -1
- package/docs/{quickstart.md → frameworks/next/quickstart.md} +26 -42
- package/docs/{script-loader.md → frameworks/next/script-loader.md} +72 -90
- package/docs/{server-side.md → frameworks/next/server-side.md} +12 -15
- package/docs/{styling → frameworks/next/styling}/classnames.md +3 -1
- package/docs/{styling → frameworks/next/styling}/color-scheme.md +3 -1
- package/docs/frameworks/next/styling/css-variables.md +53 -0
- package/docs/frameworks/next/styling/overview.md +299 -0
- package/docs/frameworks/next/styling/slots.md +94 -0
- package/docs/{styling → frameworks/next/styling}/tailwind.md +3 -1
- package/docs/frameworks/next/styling/tokens.md +156 -0
- package/docs/{troubleshooting.md → frameworks/next/troubleshooting.md} +3 -1
- package/docs/integrations/adobe-analytics.md +160 -0
- package/docs/integrations/ahrefs-analytics.md +15 -82
- package/docs/integrations/amplitude.md +230 -0
- package/docs/integrations/building-integrations.md +15 -181
- package/docs/integrations/clearbit.md +130 -0
- package/docs/integrations/cloudflare-web-analytics.md +15 -83
- package/docs/integrations/crisp.md +13 -87
- package/docs/integrations/databuddy.md +16 -85
- package/docs/integrations/fathom-analytics.md +15 -86
- package/docs/integrations/google-maps.md +263 -0
- package/docs/integrations/google-tag-manager.md +18 -86
- package/docs/integrations/google-tag.md +15 -84
- package/docs/integrations/heap.md +219 -0
- package/docs/integrations/hightouch.md +199 -0
- package/docs/integrations/hotjar.md +15 -83
- package/docs/integrations/intercom.md +13 -83
- package/docs/integrations/linkedin-insights.md +15 -82
- package/docs/integrations/logrocket.md +175 -0
- package/docs/integrations/matomo-analytics.md +13 -88
- package/docs/integrations/meta-pixel.md +33 -316
- package/docs/integrations/microsoft-clarity.md +15 -83
- package/docs/integrations/microsoft-uet.md +16 -83
- package/docs/integrations/mixpanel-analytics.md +15 -83
- package/docs/integrations/overview.md +55 -6
- package/docs/integrations/pirsch.md +142 -0
- package/docs/integrations/plausible-analytics.md +14 -97
- package/docs/integrations/posthog.md +26 -98
- package/docs/integrations/promptwatch.md +16 -82
- package/docs/integrations/reddit-pixel.md +27 -122
- package/docs/integrations/rudderstack.md +271 -0
- package/docs/integrations/rybbit-analytics.md +15 -94
- package/docs/integrations/segment.md +15 -82
- package/docs/integrations/snapchat-pixel.md +21 -102
- package/docs/integrations/tiktok-pixel.md +13 -81
- package/docs/integrations/umami-analytics.md +16 -88
- package/docs/integrations/vercel-analytics.md +13 -85
- package/docs/integrations/x-pixel.md +27 -102
- package/docs/integrations/youtube.md +193 -0
- package/docs/shared/concepts/client-modes.md +103 -0
- package/docs/shared/concepts/consent-categories.md +41 -0
- package/docs/shared/concepts/consent-models.md +72 -0
- package/docs/shared/concepts/cookie-management.md +88 -0
- package/docs/shared/concepts/glossary.md +24 -0
- package/docs/shared/concepts/initialization-flow.md +105 -0
- package/docs/shared/concepts/policy-packs.md +225 -0
- package/docs/shared/react/components/consent-banner.md +242 -0
- package/docs/shared/react/components/consent-dialog-link.md +45 -0
- package/docs/shared/react/components/consent-dialog-trigger.md +185 -0
- package/docs/shared/react/components/consent-dialog.md +119 -0
- package/docs/shared/react/components/consent-manager-provider.md +225 -0
- package/docs/shared/react/components/consent-widget.md +121 -0
- package/docs/shared/react/components/dev-tools.md +81 -0
- package/docs/shared/react/components/frame.md +52 -0
- package/docs/shared/react/guides/building-headless-components.md +110 -0
- package/docs/shared/react/guides/callbacks.md +89 -0
- package/docs/shared/react/guides/headless.md +31 -0
- package/docs/shared/react/guides/iframe-blocking.md +65 -0
- package/docs/shared/react/guides/internationalization.md +123 -0
- package/docs/shared/react/guides/network-blocker.md +72 -0
- package/docs/shared/react/guides/optimization.md +44 -0
- package/docs/shared/react/guides/policy-packs.md +173 -0
- package/docs/shared/react/guides/script-loader.md +311 -0
- package/docs/shared/react/hooks/use-color-scheme.md +31 -0
- package/docs/shared/react/hooks/use-consent-manager/checking-consent.md +95 -0
- package/docs/shared/react/hooks/use-consent-manager/location-info.md +96 -0
- package/docs/shared/react/hooks/use-consent-manager/overview.md +74 -0
- package/docs/shared/react/hooks/use-consent-manager/setting-consent.md +93 -0
- package/docs/shared/react/hooks/use-draggable.md +30 -0
- package/docs/shared/react/hooks/use-focus-trap.md +20 -0
- package/docs/shared/react/hooks/use-reduced-motion.md +33 -0
- package/docs/shared/react/hooks/use-ssr-status.md +16 -0
- package/docs/shared/react/hooks/use-text-direction.md +38 -0
- package/docs/shared/react/hooks/use-translations.md +15 -0
- package/docs/shared/react/iab/consent-banner.md +60 -0
- package/docs/shared/react/iab/consent-dialog.md +76 -0
- package/docs/shared/react/iab/overview.md +80 -0
- package/docs/shared/react/iab/use-gvl-data.md +21 -0
- package/docs/shared/react/styling/classnames.md +93 -0
- package/docs/shared/react/styling/color-scheme.md +35 -0
- package/docs/shared/react/styling/css-variables.md +53 -0
- package/docs/shared/react/styling/overview.md +261 -0
- package/docs/shared/react/styling/slots.md +93 -0
- package/docs/shared/react/styling/stylesheet-entrypoint.md +8 -0
- package/docs/shared/react/styling/tailwind.md +88 -0
- package/docs/shared/react/styling/tokens.md +155 -0
- package/docs/shared/troubleshooting.md +82 -0
- package/package.json +19 -10
- package/readme.json +14 -8
- package/docs/ai-agents.md +0 -111
- package/docs/components/consent-dialog-trigger.md +0 -103
- package/docs/components/consent-manager-provider.md +0 -425
- package/docs/hooks/use-consent-manager/overview.md +0 -420
- package/docs/hooks/use-translations.md +0 -118
- package/docs/styling/css-variables.md +0 -92
- package/docs/styling/overview.md +0 -457
- package/docs/styling/slots.md +0 -128
- package/docs/styling/tokens.md +0 -216
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Adobe Analytics
|
|
3
|
+
description: Adobe Analytics loaded through an Adobe Experience Platform Data
|
|
4
|
+
Collection Tags embed URL.
|
|
5
|
+
group: integrations
|
|
6
|
+
icon: adobe-analytics
|
|
7
|
+
---
|
|
8
|
+
[Adobe Analytics](https://business.adobe.com/products/analytics/adobe-analytics.html) is commonly deployed through an Adobe Experience Platform Data Collection web property. Data Collection generates a property-specific Tags embed script, often hosted on `assets.adobedtm.com`, and that script can load Adobe Analytics, Web SDK, or other configured extensions and rules.
|
|
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 { adobeAnalytics } from '@c15t/scripts/adobe-analytics';
|
|
18
|
+
|
|
19
|
+
const scripts = [
|
|
20
|
+
adobeAnalytics({
|
|
21
|
+
scriptUrl:
|
|
22
|
+
'https://assets.adobedtm.com/YOUR_ORG/YOUR_PROPERTY/launch-production.min.js',
|
|
23
|
+
}),
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
27
|
+
return (
|
|
28
|
+
<ConsentManagerProvider
|
|
29
|
+
options={{
|
|
30
|
+
mode: 'hosted',
|
|
31
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
32
|
+
scripts,
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</ConsentManagerProvider>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Next.js**
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
'use client';
|
|
45
|
+
|
|
46
|
+
import { type ReactNode } from 'react';
|
|
47
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
48
|
+
import { adobeAnalytics } from '@c15t/scripts/adobe-analytics';
|
|
49
|
+
|
|
50
|
+
const scripts = [
|
|
51
|
+
adobeAnalytics({
|
|
52
|
+
scriptUrl:
|
|
53
|
+
'https://assets.adobedtm.com/YOUR_ORG/YOUR_PROPERTY/launch-production.min.js',
|
|
54
|
+
}),
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
58
|
+
return (
|
|
59
|
+
<ConsentManagerProvider
|
|
60
|
+
options={{
|
|
61
|
+
mode: 'hosted',
|
|
62
|
+
backendURL: '/api/c15t',
|
|
63
|
+
scripts,
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</ConsentManagerProvider>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**JavaScript**
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
76
|
+
import { adobeAnalytics } from '@c15t/scripts/adobe-analytics';
|
|
77
|
+
|
|
78
|
+
getOrCreateConsentRuntime({
|
|
79
|
+
mode: 'hosted',
|
|
80
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
81
|
+
scripts: [
|
|
82
|
+
adobeAnalytics({
|
|
83
|
+
scriptUrl:
|
|
84
|
+
'https://assets.adobedtm.com/YOUR_ORG/YOUR_PROPERTY/launch-production.min.js',
|
|
85
|
+
}),
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Find Your Embed URL
|
|
91
|
+
|
|
92
|
+
Open Adobe Data Collection, choose your Tags property, then open **Environments**. Select the install action for the environment you want to deploy and copy the web property embed script URL from the generated code.
|
|
93
|
+
|
|
94
|
+
Each Adobe environment has its own embed code. Use the production URL in production, and keep development or staging URLs limited to test environments. The URL is typically shaped like:
|
|
95
|
+
|
|
96
|
+
```txt
|
|
97
|
+
https://assets.adobedtm.com/{org}/{property}/launch-{env}.min.js
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Self-hosted Data Collection builds are supported too. c15t only requires a full `https:` URL.
|
|
101
|
+
|
|
102
|
+
## How c15t loads it
|
|
103
|
+
|
|
104
|
+
* **Category:** `measurement` (Analytics)
|
|
105
|
+
* **Loads when:** measurement consent is granted
|
|
106
|
+
* **On revocation:** unloaded - c15t removes the Adobe Tags script element from the DOM.
|
|
107
|
+
|
|
108
|
+
The helper blocks the Adobe Tags library until measurement consent is granted. When measurement consent is revoked, c15t unloads the script element. Adobe rules, extensions, cookies, and downstream tags that already ran may have their own state, so configure Data Collection rules and extensions to respect your consent model as well.
|
|
109
|
+
|
|
110
|
+
This is the same caveat as tag managers: a Tags property can load more than Adobe Analytics. Keep non-measurement tags behind Adobe-side rule conditions, consent checks, or separate properties so they do not run from a measurement-only grant.
|
|
111
|
+
|
|
112
|
+
By default, c15t also seeds the Adobe Client Data Layer queue before loading:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
adobeAnalytics({
|
|
116
|
+
scriptUrl:
|
|
117
|
+
'https://assets.adobedtm.com/YOUR_ORG/YOUR_PROPERTY/launch-production.min.js',
|
|
118
|
+
seedAdobeDataLayer: true,
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
This creates `window.adobeDataLayer = []` only when it is still undefined. Adobe's Client Data Layer extension uses `adobeDataLayer` as the default object name, and the pre-seed is harmless for properties that do not use that extension.
|
|
123
|
+
|
|
124
|
+
Adobe's `_satellite` object becomes available after the Tags library loads:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
if (window._satellite) {
|
|
128
|
+
// Adobe Tags runtime is available.
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Use synchronous deployment only when a legacy Tags setup requires it:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
adobeAnalytics({
|
|
136
|
+
scriptUrl:
|
|
137
|
+
'https://assets.adobedtm.com/YOUR_ORG/YOUR_PROPERTY/launch-production.min.js',
|
|
138
|
+
async: false,
|
|
139
|
+
})
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Types
|
|
143
|
+
|
|
144
|
+
### AdobeAnalyticsOptions
|
|
145
|
+
|
|
146
|
+
|Property|Value|
|
|
147
|
+
|:--|:--|
|
|
148
|
+
|Type Name|\`AdobeAnalyticsOptions\`|
|
|
149
|
+
|Source Path|\`./packages/scripts/src/vendors/analytics/adobe-analytics.ts\`|
|
|
150
|
+
|
|
151
|
+
\*ExtractedTypeTable: Could not extract "AdobeAnalyticsOptions" from "./packages/scripts/src/vendors/analytics/adobe-analytics.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
152
|
+
|
|
153
|
+
### Script
|
|
154
|
+
|
|
155
|
+
|Property|Value|
|
|
156
|
+
|:--|:--|
|
|
157
|
+
|Type Name|\`Script\`|
|
|
158
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
159
|
+
|
|
160
|
+
\*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.\*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Ahrefs Analytics
|
|
3
|
-
description: Cookieless web analytics from Ahrefs with a prebuilt helper that
|
|
4
|
-
|
|
3
|
+
description: Cookieless web analytics from Ahrefs with a prebuilt helper that
|
|
4
|
+
wires the project key into a c15t-managed script.
|
|
5
|
+
group: integrations
|
|
5
6
|
icon: ahrefs
|
|
6
7
|
---
|
|
7
8
|
Ahrefs Web Analytics is a cookieless analytics product configured with a single project key. The `ahrefsAnalytics()` helper wires that key into the `data-key` attribute that Ahrefs' loader reads at startup.
|
|
@@ -139,86 +140,18 @@ if (consentStore.getState().has('measurement')) {
|
|
|
139
140
|
|
|
140
141
|
### AhrefsAnalyticsOptions
|
|
141
142
|
|
|
142
|
-
|Property|
|
|
143
|
-
|
|
144
|
-
|
|
|
145
|
-
|
|
|
143
|
+
|Property|Value|
|
|
144
|
+
|:--|:--|
|
|
145
|
+
|Type Name|\`AhrefsAnalyticsOptions\`|
|
|
146
|
+
|Source Path|\`./packages/scripts/src/vendors/analytics/ahrefs-analytics.ts\`|
|
|
147
|
+
|
|
148
|
+
\*ExtractedTypeTable: Could not extract "AhrefsAnalyticsOptions" from "./packages/scripts/src/vendors/analytics/ahrefs-analytics.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
146
149
|
|
|
147
150
|
### Script
|
|
148
151
|
|
|
149
|
-
|Property|
|
|
150
|
-
|
|
151
|
-
|
|
|
152
|
-
|src
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|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|
|
|
156
|
-
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
|
|
157
|
-
|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|
|
|
158
|
-
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
159
|
-
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
160
|
-
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
161
|
-
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
162
|
-
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
163
|
-
|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|
|
|
164
|
-
|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|
|
|
165
|
-
|onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
166
|
-
|onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
167
|
-
|onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
168
|
-
|onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
169
|
-
|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|
|
|
170
|
-
|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|
|
|
171
|
-
|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|
|
|
172
|
-
|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|
|
|
173
|
-
|
|
174
|
-
#### `onBeforeLoad`
|
|
175
|
-
|
|
176
|
-
Callback executed before the script is loaded
|
|
177
|
-
|
|
178
|
-
|Property|Type|Description|Default|Required|
|
|
179
|
-
|:--|:--|:--|:--|:--:|
|
|
180
|
-
|id|string|The original script ID|-|✅ Required|
|
|
181
|
-
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
182
|
-
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
183
|
-
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
184
|
-
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
185
|
-
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
186
|
-
|
|
187
|
-
#### `onLoad`
|
|
188
|
-
|
|
189
|
-
Callback executed when the script loads successfully
|
|
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
|
-
#### `onError`
|
|
201
|
-
|
|
202
|
-
Callback executed if the script fails to load
|
|
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
|
-
#### `onConsentChange`
|
|
214
|
-
|
|
215
|
-
Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
|
|
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|
|
|
152
|
+
|Property|Value|
|
|
153
|
+
|:--|:--|
|
|
154
|
+
|Type Name|\`Script\`|
|
|
155
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
156
|
+
|
|
157
|
+
\*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,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Amplitude
|
|
3
|
+
description: Load Amplitude Browser SDK 2 with c15t and gate product analytics
|
|
4
|
+
behind measurement consent.
|
|
5
|
+
group: integrations
|
|
6
|
+
icon: amplitude
|
|
7
|
+
---
|
|
8
|
+
[Amplitude](https://amplitude.com/) provides product analytics for tracking user behavior, funnels, retention, and feature adoption. The `amplitude()` helper creates the Browser SDK 2 snippet queue, queues `amplitude.init(apiKey, initOptions)`, and loads Amplitude only when `measurement` 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 { amplitude } from '@c15t/scripts/amplitude';
|
|
18
|
+
|
|
19
|
+
const scripts = [
|
|
20
|
+
amplitude({
|
|
21
|
+
apiKey: 'AMPLITUDE_API_KEY',
|
|
22
|
+
initOptions: {
|
|
23
|
+
autocapture: false,
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
29
|
+
return (
|
|
30
|
+
<ConsentManagerProvider
|
|
31
|
+
options={{
|
|
32
|
+
mode: 'hosted',
|
|
33
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
34
|
+
scripts,
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{children}
|
|
38
|
+
</ConsentManagerProvider>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Next.js**
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
'use client';
|
|
47
|
+
|
|
48
|
+
import { type ReactNode } from 'react';
|
|
49
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
50
|
+
import { amplitude } from '@c15t/scripts/amplitude';
|
|
51
|
+
|
|
52
|
+
const scripts = [
|
|
53
|
+
amplitude({
|
|
54
|
+
apiKey: 'AMPLITUDE_API_KEY',
|
|
55
|
+
initOptions: {
|
|
56
|
+
autocapture: false,
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
62
|
+
return (
|
|
63
|
+
<ConsentManagerProvider
|
|
64
|
+
options={{
|
|
65
|
+
mode: 'hosted',
|
|
66
|
+
backendURL: '/api/c15t',
|
|
67
|
+
scripts,
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</ConsentManagerProvider>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**JavaScript**
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
80
|
+
import { amplitude } from '@c15t/scripts/amplitude';
|
|
81
|
+
|
|
82
|
+
getOrCreateConsentRuntime({
|
|
83
|
+
mode: 'hosted',
|
|
84
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
85
|
+
scripts: [
|
|
86
|
+
amplitude({
|
|
87
|
+
apiKey: 'AMPLITUDE_API_KEY',
|
|
88
|
+
initOptions: {
|
|
89
|
+
autocapture: false,
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## How c15t loads it
|
|
97
|
+
|
|
98
|
+
* **Category:** `measurement` (Analytics)
|
|
99
|
+
* **Loads when:** measurement consent is granted
|
|
100
|
+
* **On revocation:** c15t calls `amplitude.setOptOut(true)` through the lifecycle callback and unloads the script by default.
|
|
101
|
+
|
|
102
|
+
The helper maps Amplitude Browser SDK 2's script-loader contract into the manifest engine:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
amplitude({
|
|
106
|
+
apiKey: 'AMPLITUDE_API_KEY',
|
|
107
|
+
initOptions: {
|
|
108
|
+
autocapture: false,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
It creates `window.amplitude` with:
|
|
114
|
+
|
|
115
|
+
* `invoked: true`
|
|
116
|
+
* `_q: []` for queued `{ name, args, resolve }` method calls
|
|
117
|
+
* `_iq: {}` for the named-instance registry expected by the SDK
|
|
118
|
+
* `Identify` for queued pre-load identify operations
|
|
119
|
+
* core queue methods for `init`, `track`, `identify`, `setUserId`, `setOptOut`, and `flush`
|
|
120
|
+
|
|
121
|
+
Then it queues:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
window.amplitude.init('AMPLITUDE_API_KEY', {
|
|
125
|
+
autocapture: false,
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
and loads:
|
|
130
|
+
|
|
131
|
+
```txt
|
|
132
|
+
https://cdn.amplitude.com/libs/analytics-browser-2.44.4-min.js.gz
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`apiKey` is required and must be a non-empty string after trimming.
|
|
136
|
+
|
|
137
|
+
## Configure initialization
|
|
138
|
+
|
|
139
|
+
Pass `initOptions` to provide Amplitude Browser SDK 2 initialization options. Values must be JSON-serializable: plain objects, arrays, strings, numbers, booleans, and `null`.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { amplitude } from '@c15t/scripts/amplitude';
|
|
143
|
+
|
|
144
|
+
amplitude({
|
|
145
|
+
apiKey: 'AMPLITUDE_API_KEY',
|
|
146
|
+
initOptions: {
|
|
147
|
+
autocapture: false,
|
|
148
|
+
fetchRemoteConfig: false,
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Do not pass functions, Dates, Maps, Sets, class instances, symbols, or other non-JSON values in `initOptions`.
|
|
154
|
+
|
|
155
|
+
## Configure the loader URL
|
|
156
|
+
|
|
157
|
+
Amplitude's Browser SDK 2 CDN bundle path is versioned. c15t pins a tested default version and lets you override the URL if you self-host or proxy the bundle.
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
amplitude({
|
|
161
|
+
apiKey: 'AMPLITUDE_API_KEY',
|
|
162
|
+
scriptUrl: 'https://analytics.example.com/analytics-browser.js',
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Consent behavior
|
|
167
|
+
|
|
168
|
+
Amplitude should not load before analytics consent. c15t gates the SDK on `measurement` consent and queues `init()` only when the script is allowed to load.
|
|
169
|
+
|
|
170
|
+
After the SDK has loaded, the generated lifecycle callback maps consent changes to Amplitude's runtime opt-out API:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
window.amplitude.setOptOut(false); // measurement granted
|
|
174
|
+
window.amplitude.setOptOut(true); // measurement denied
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The script still uses c15t's default unload behavior when measurement consent is revoked.
|
|
178
|
+
|
|
179
|
+
## Tracking events in your app
|
|
180
|
+
|
|
181
|
+
c15t gates the Amplitude browser SDK from loading until `measurement` consent is granted. Your application code that calls Amplitude's runtime API (`window.amplitude.track`, `identify`, etc.) is **not** automatically gated - `window.amplitude` does not exist until the script is loaded, so unguarded calls before consent throw.
|
|
182
|
+
|
|
183
|
+
Guard event calls by checking consent state. From React:
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import { useCallback } from 'react';
|
|
187
|
+
import { useConsentManager } from '@c15t/react';
|
|
188
|
+
|
|
189
|
+
function SignupExample() {
|
|
190
|
+
const { has } = useConsentManager();
|
|
191
|
+
|
|
192
|
+
const trackSignup = useCallback(() => {
|
|
193
|
+
if (has('measurement')) {
|
|
194
|
+
window.amplitude?.track('Signup Completed', { plan: 'pro' });
|
|
195
|
+
}
|
|
196
|
+
}, [has]);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
From plain JavaScript:
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
204
|
+
|
|
205
|
+
const { consentStore } = getOrCreateConsentRuntime();
|
|
206
|
+
|
|
207
|
+
if (consentStore.getState().has('measurement')) {
|
|
208
|
+
window.amplitude?.track('Signup Completed', { plan: 'pro' });
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Types
|
|
213
|
+
|
|
214
|
+
### AmplitudeOptions
|
|
215
|
+
|
|
216
|
+
|Property|Value|
|
|
217
|
+
|:--|:--|
|
|
218
|
+
|Type Name|\`AmplitudeOptions\`|
|
|
219
|
+
|Source Path|\`./packages/scripts/src/vendors/analytics/amplitude.ts\`|
|
|
220
|
+
|
|
221
|
+
\*ExtractedTypeTable: Could not extract "AmplitudeOptions" from "./packages/scripts/src/vendors/analytics/amplitude.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
222
|
+
|
|
223
|
+
### Script
|
|
224
|
+
|
|
225
|
+
|Property|Value|
|
|
226
|
+
|:--|:--|
|
|
227
|
+
|Type Name|\`Script\`|
|
|
228
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
229
|
+
|
|
230
|
+
\*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.\*
|