c15t 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.
- package/CHANGELOG.md +36 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist-types/index.d.ts +1 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/integrations/ahrefs-analytics.md +224 -0
- package/docs/integrations/cloudflare-web-analytics.md +194 -0
- package/docs/integrations/crisp.md +214 -0
- package/docs/integrations/databuddy.md +136 -65
- package/docs/integrations/fathom-analytics.md +221 -0
- package/docs/integrations/google-tag-manager.md +84 -15
- package/docs/integrations/google-tag.md +89 -8
- package/docs/integrations/hotjar.md +211 -0
- package/docs/integrations/intercom.md +214 -0
- package/docs/integrations/linkedin-insights.md +130 -11
- package/docs/integrations/matomo-analytics.md +246 -0
- package/docs/integrations/meta-pixel.md +377 -24
- package/docs/integrations/microsoft-clarity.md +241 -0
- package/docs/integrations/microsoft-uet.md +120 -9
- package/docs/integrations/mixpanel-analytics.md +198 -0
- package/docs/integrations/overview.md +69 -74
- package/docs/integrations/plausible-analytics.md +237 -0
- package/docs/integrations/posthog.md +172 -41
- package/docs/integrations/promptwatch.md +187 -0
- package/docs/integrations/reddit-pixel.md +336 -0
- package/docs/integrations/rybbit-analytics.md +222 -0
- package/docs/integrations/segment.md +213 -0
- package/docs/integrations/snapchat-pixel.md +244 -0
- package/docs/integrations/tiktok-pixel.md +88 -10
- package/docs/integrations/umami-analytics.md +220 -0
- package/docs/integrations/vercel-analytics.md +213 -0
- package/docs/integrations/x-pixel.md +99 -10
- package/docs/script-loader.md +168 -51
- package/package.json +3 -3
|
@@ -2,19 +2,91 @@
|
|
|
2
2
|
title: Google Tag Manager
|
|
3
3
|
description: Deploy and manage marketing tags centrally with automatic consent state synchronization.
|
|
4
4
|
lastModified: 2026-02-10
|
|
5
|
-
|
|
6
5
|
icon: google-tag-manager
|
|
7
6
|
---
|
|
8
7
|
Google Tag Manager (GTM) is Google's tag management system that lets you deploy and manage marketing tags, analytics scripts, and conversion pixels without modifying your codebase. Instead of hardcoding multiple scripts, you configure them through GTM's web interface.
|
|
9
8
|
|
|
10
|
-
c15t automatically injects the GTM script into your page and syncs consent state with GTM using Consent Mode v2.
|
|
9
|
+
c15t automatically injects the GTM script into your page and syncs consent state with GTM using Consent Mode v2. GTM manages its own internal consent state and only fires tags when appropriate consent is granted, which means it can safely load before consent is collected.
|
|
11
10
|
|
|
12
11
|
This prevents GTM-managed scripts from loading without proper consent while giving you centralized control over your marketing stack.
|
|
13
12
|
|
|
14
13
|
> ℹ️ **Info:**
|
|
15
14
|
> Use GTM if your team manages many tags centrally in the GTM UI. Use gtag.js if you only need GA4/Google Ads directly in code. Don't run both for the same destination unless intentional, or you may duplicate events.
|
|
16
15
|
|
|
17
|
-
##
|
|
16
|
+
## Integrate with c15t
|
|
17
|
+
|
|
18
|
+
Use your GTM container ID, which begins with `GTM-`.
|
|
19
|
+
|
|
20
|
+
**React**
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { type ReactNode } from 'react';
|
|
24
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
25
|
+
import { googleTagManager } from '@c15t/scripts/google-tag-manager';
|
|
26
|
+
|
|
27
|
+
const scripts = [googleTagManager({ id: 'GTM-XXXXXXX' })];
|
|
28
|
+
|
|
29
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
30
|
+
return (
|
|
31
|
+
<ConsentManagerProvider
|
|
32
|
+
options={{
|
|
33
|
+
mode: 'hosted',
|
|
34
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
35
|
+
scripts,
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</ConsentManagerProvider>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Next.js**
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
'use client';
|
|
48
|
+
|
|
49
|
+
import { type ReactNode } from 'react';
|
|
50
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
51
|
+
import { googleTagManager } from '@c15t/scripts/google-tag-manager';
|
|
52
|
+
|
|
53
|
+
const scripts = [googleTagManager({ id: 'GTM-XXXXXXX' })];
|
|
54
|
+
|
|
55
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
56
|
+
return (
|
|
57
|
+
<ConsentManagerProvider
|
|
58
|
+
options={{
|
|
59
|
+
mode: 'hosted',
|
|
60
|
+
backendURL: '/api/c15t',
|
|
61
|
+
scripts,
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</ConsentManagerProvider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**JavaScript**
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
74
|
+
import { googleTagManager } from '@c15t/scripts/google-tag-manager';
|
|
75
|
+
|
|
76
|
+
getOrCreateConsentRuntime({
|
|
77
|
+
mode: 'hosted',
|
|
78
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
79
|
+
scripts: [googleTagManager({ id: 'GTM-XXXXXXX' })],
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## How c15t loads it
|
|
84
|
+
|
|
85
|
+
* **Category:** `necessary` (Tag Managers)
|
|
86
|
+
* **Loads when:** [`alwaysLoad`](/docs/frameworks/react/script-loader#always-load) — runs on page start with Consent Mode v2 defaults set to denied
|
|
87
|
+
* **On consent change:** c15t pushes a Consent Mode v2 `update` to the data layer; GTM-managed tags re-evaluate against the new state
|
|
88
|
+
|
|
89
|
+
## Configure the integration
|
|
18
90
|
|
|
19
91
|
1. **Creating a Tag Manager Container**
|
|
20
92
|
|
|
@@ -37,25 +109,22 @@ This prevents GTM-managed scripts from loading without proper consent while givi
|
|
|
37
109
|
|
|
38
110
|
Create trigger
|
|
39
111
|
|
|
40
|
-
3. **
|
|
112
|
+
3. **Update tags** Now for your existing tags, you can add the "consent-update" trigger to the tag, this will fire the update event when the consent state is updated & it has the appropriate consent state.
|
|
41
113
|
|
|
42
114
|
Update tags
|
|
43
115
|
|
|
44
|
-
|
|
116
|
+
## Tracking events in your app
|
|
45
117
|
|
|
46
|
-
|
|
47
|
-
>
|
|
48
|
-
> See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
|
|
118
|
+
GTM is `alwaysLoad: true`, so the GTM container and `window.dataLayer` are present from page start regardless of consent. Calls like `dataLayer.push({ event: 'signup' })` are **safe at any time** — Consent Mode v2 defaults are set to denied before the user makes a choice, and GTM-managed tags only fire when the matching consent has been granted.
|
|
49
119
|
|
|
50
|
-
|
|
51
|
-
|
|
120
|
+
```ts
|
|
121
|
+
window.dataLayer = window.dataLayer || [];
|
|
122
|
+
window.dataLayer.push({ event: 'signup' });
|
|
123
|
+
```
|
|
52
124
|
|
|
53
|
-
|
|
54
|
-
id: 'GTM-XXXXXXX',
|
|
55
|
-
})
|
|
56
|
-
```
|
|
125
|
+
You do not need to wrap `dataLayer.push(...)` in a `useConsentManager().has(...)` check — the consent gate happens inside GTM, not inside c15t.
|
|
57
126
|
|
|
58
|
-
##
|
|
127
|
+
## Verify setup
|
|
59
128
|
|
|
60
129
|
1. Open GTM Preview mode and confirm your container (`GTM-...`) loads on page load.
|
|
61
130
|
2. Before giving consent, confirm non-essential tags do not fire in GTM Preview.
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
title: GA4 + Google Ads (gtag.js)
|
|
3
3
|
description: Send data to Google Analytics 4 and Google Ads with automatic Consent Mode v2 support.
|
|
4
4
|
lastModified: 2026-02-10
|
|
5
|
-
|
|
6
5
|
icon: google-analytics
|
|
7
6
|
---
|
|
8
7
|
Google Tag (`gtag.js`) is Google's unified tracking script for sending data to Google Analytics 4 (GA4), Google Ads, and Floodlight. It measures user behavior, tracks conversions, and powers Google's advertising ecosystem.
|
|
@@ -17,20 +16,102 @@ c15t initializes Google Tag with Consent Mode v2 defaults set to denied and auto
|
|
|
17
16
|
* Use `category: 'measurement'` for analytics-only tracking (GA4 events)
|
|
18
17
|
* Use `category: 'marketing'` for advertising and conversion tracking (Google Ads)
|
|
19
18
|
|
|
20
|
-
##
|
|
19
|
+
## Integrate with c15t
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
**React**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { type ReactNode } from 'react';
|
|
25
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
26
|
+
import { gtag } from '@c15t/scripts/google-tag';
|
|
27
|
+
|
|
28
|
+
const scripts = [
|
|
29
|
+
gtag({
|
|
30
|
+
id: 'G-XXXXXXXXXX',
|
|
31
|
+
category: 'measurement', // or 'marketing'
|
|
32
|
+
}),
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
36
|
+
return (
|
|
37
|
+
<ConsentManagerProvider
|
|
38
|
+
options={{
|
|
39
|
+
mode: 'hosted',
|
|
40
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
41
|
+
scripts,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</ConsentManagerProvider>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Next.js**
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
'use client';
|
|
54
|
+
|
|
55
|
+
import { type ReactNode } from 'react';
|
|
56
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
57
|
+
import { gtag } from '@c15t/scripts/google-tag';
|
|
58
|
+
|
|
59
|
+
const scripts = [
|
|
60
|
+
gtag({
|
|
61
|
+
id: 'G-XXXXXXXXXX',
|
|
62
|
+
category: 'measurement', // or 'marketing'
|
|
63
|
+
}),
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
67
|
+
return (
|
|
68
|
+
<ConsentManagerProvider
|
|
69
|
+
options={{
|
|
70
|
+
mode: 'hosted',
|
|
71
|
+
backendURL: '/api/c15t',
|
|
72
|
+
scripts,
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</ConsentManagerProvider>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**JavaScript**
|
|
24
82
|
|
|
25
83
|
```ts
|
|
84
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
26
85
|
import { gtag } from '@c15t/scripts/google-tag';
|
|
27
86
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
87
|
+
getOrCreateConsentRuntime({
|
|
88
|
+
mode: 'hosted',
|
|
89
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
90
|
+
scripts: [
|
|
91
|
+
gtag({
|
|
92
|
+
id: 'G-XXXXXXXXXX',
|
|
93
|
+
category: 'measurement', // or 'marketing'
|
|
94
|
+
}),
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## How c15t loads it
|
|
100
|
+
|
|
101
|
+
* **Category:** configurable — `measurement` (default, Analytics) or `marketing`
|
|
102
|
+
* **Loads when:** [`alwaysLoad`](/docs/frameworks/react/script-loader#always-load) — runs on page start regardless of consent state, with Consent Mode v2 defaults set to denied
|
|
103
|
+
* **On consent change:** [persists](/docs/frameworks/react/script-loader#persist-after-revocation) — c15t pushes a Consent Mode v2 `update` to gtag instead of removing the script
|
|
104
|
+
|
|
105
|
+
## Tracking events in your app
|
|
106
|
+
|
|
107
|
+
`gtag.js` is `alwaysLoad: true`, so `window.gtag` is present from page start regardless of consent. Calls like `gtag('event', 'sign_up')` are **safe at any time** — c15t sets Consent Mode v2 defaults to denied before the user makes a choice, and Google's SDK suppresses transmission of events while the relevant consent is denied. When consent later changes, c15t emits a Consent Mode v2 `update` so events fire correctly going forward.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
window.gtag?.('event', 'sign_up', { method: 'email' });
|
|
32
111
|
```
|
|
33
112
|
|
|
113
|
+
You do not need to wrap `gtag(...)` calls in a `useConsentManager().has(...)` check — Consent Mode handles the suppression for you.
|
|
114
|
+
|
|
34
115
|
## Types
|
|
35
116
|
|
|
36
117
|
### GtagOptions
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Hotjar
|
|
3
|
+
description: Product analytics and behavior insights with a prebuilt helper that seeds Hotjar globals before loading the vendor bundle.
|
|
4
|
+
lastModified: 2026-05-10
|
|
5
|
+
icon: hotjar
|
|
6
|
+
---
|
|
7
|
+
Hotjar helps you understand behavior with heatmaps, session recordings, and feedback tools. The `hotjar()` helper sets up Hotjar's `_hjSettings` global and `hj` queue stub, then loads the vendor script once `measurement` consent is granted.
|
|
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 { hotjar } from '@c15t/scripts/hotjar';
|
|
17
|
+
|
|
18
|
+
const scripts = [hotjar({ siteId: 1234567, version: 6 })];
|
|
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 { hotjar } from '@c15t/scripts/hotjar';
|
|
43
|
+
|
|
44
|
+
const scripts = [hotjar({ siteId: 1234567, version: 6 })];
|
|
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 { hotjar } from '@c15t/scripts/hotjar';
|
|
66
|
+
|
|
67
|
+
getOrCreateConsentRuntime({
|
|
68
|
+
mode: 'hosted',
|
|
69
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
70
|
+
scripts: [hotjar({ siteId: 1234567, version: 6 })],
|
|
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 loader script element from the DOM, which prevents further loader-driven network requests. Existing Hotjar requests, timers, event listeners, and globals may continue until they finish or are cleared by Hotjar-specific APIs.
|
|
79
|
+
|
|
80
|
+
To load Hotjar from a custom URL:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
hotjar({
|
|
84
|
+
siteId: 1234567,
|
|
85
|
+
scriptUrl: 'https://cdn.example.com/hotjar.js',
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Tracking events in your app
|
|
90
|
+
|
|
91
|
+
c15t gates loading of the Hotjar script until `measurement` consent is granted. The `hotjar()` helper initializes Hotjar globals by creating a pre-load queue stub at `window.hj`, so calls to Hotjar's runtime API (`window.hj(...)`) can be queued before the real script loads. After the helper runs, `window.hj` exists as that queue stub; once Hotjar's script loads, it is replaced by Hotjar's real implementation.
|
|
92
|
+
|
|
93
|
+
Guard event calls by checking consent state. From React:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import { useCallback } from 'react';
|
|
97
|
+
import { useConsentManager } from '@c15t/react';
|
|
98
|
+
|
|
99
|
+
function SignupExample() {
|
|
100
|
+
const { has } = useConsentManager();
|
|
101
|
+
|
|
102
|
+
const trackSignup = useCallback(() => {
|
|
103
|
+
if (has('measurement')) {
|
|
104
|
+
window.hj?.('event', 'signup');
|
|
105
|
+
}
|
|
106
|
+
}, [has]);
|
|
107
|
+
|
|
108
|
+
// Call trackSignup() from an event handler after signup succeeds.
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
From plain JavaScript:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
116
|
+
|
|
117
|
+
const { consentStore } = getOrCreateConsentRuntime();
|
|
118
|
+
|
|
119
|
+
if (consentStore.getState().has('measurement')) {
|
|
120
|
+
window.hj?.('event', 'signup');
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Types
|
|
125
|
+
|
|
126
|
+
### HotjarOptions
|
|
127
|
+
|
|
128
|
+
|Property|Type|Description|Default|Required|
|
|
129
|
+
|:--|:--|:--|:--|:--:|
|
|
130
|
+
|siteId|string \|number|Your Hotjar site ID.|-|✅ Required|
|
|
131
|
+
|version|number \|undefined|Hotjar script version.|6|Optional|
|
|
132
|
+
|scriptUrl|string \|undefined|Hotjar loader URL.|-|Optional|
|
|
133
|
+
|
|
134
|
+
### Script
|
|
135
|
+
|
|
136
|
+
|Property|Type|Description|Default|Required|
|
|
137
|
+
|:--|:--|:--|:--|:--:|
|
|
138
|
+
|id|string|Unique identifier for the script|-|✅ Required|
|
|
139
|
+
|src|string \|undefined|URL of the script to load|-|Optional|
|
|
140
|
+
|textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
|
|
141
|
+
|category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
|
|
142
|
+
|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|
|
|
143
|
+
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
|
|
144
|
+
|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|
|
|
145
|
+
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
146
|
+
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
147
|
+
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
148
|
+
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
149
|
+
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
150
|
+
|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|
|
|
151
|
+
|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|
|
|
152
|
+
|onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
153
|
+
|onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
154
|
+
|onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
155
|
+
|onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
156
|
+
|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|
|
|
157
|
+
|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|
|
|
158
|
+
|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|
|
|
159
|
+
|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|
|
|
160
|
+
|
|
161
|
+
#### `onBeforeLoad`
|
|
162
|
+
|
|
163
|
+
Callback executed before the script is loaded
|
|
164
|
+
|
|
165
|
+
|Property|Type|Description|Default|Required|
|
|
166
|
+
|:--|:--|:--|:--|:--:|
|
|
167
|
+
|id|string|The original script ID|-|✅ Required|
|
|
168
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
169
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
170
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
171
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
172
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
173
|
+
|
|
174
|
+
#### `onLoad`
|
|
175
|
+
|
|
176
|
+
Callback executed when the script loads successfully
|
|
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
|
+
#### `onError`
|
|
188
|
+
|
|
189
|
+
Callback executed if the script fails to load
|
|
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
|
+
#### `onConsentChange`
|
|
201
|
+
|
|
202
|
+
Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
|
|
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|
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Intercom
|
|
3
|
+
description: Bootstrap Intercom settings and load the messenger widget bundle.
|
|
4
|
+
lastModified: 2026-05-12
|
|
5
|
+
icon: intercom
|
|
6
|
+
---
|
|
7
|
+
Intercom adds the Intercom messenger widget and queues early `Intercom(...)`
|
|
8
|
+
calls until the widget bundle loads.
|
|
9
|
+
|
|
10
|
+
## Official Intercom documentation
|
|
11
|
+
|
|
12
|
+
* [Install Intercom Messenger](https://developers.intercom.com/installing-intercom/web/installation)
|
|
13
|
+
* [Secure your Messenger](https://developers.intercom.com/installing-intercom/web/identity-verification)
|
|
14
|
+
* [JavaScript API](https://developers.intercom.com/installing-intercom/web/methods)
|
|
15
|
+
* [Attributes and objects](https://developers.intercom.com/installing-intercom/web/attributes-objects)
|
|
16
|
+
|
|
17
|
+
## Integrate with c15t
|
|
18
|
+
|
|
19
|
+
**React**
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { type ReactNode } from 'react';
|
|
23
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
24
|
+
import { intercom } from '@c15t/scripts/intercom';
|
|
25
|
+
|
|
26
|
+
const scripts = [intercom({ appId: 'abc123' })];
|
|
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 { intercom } from '@c15t/scripts/intercom';
|
|
51
|
+
|
|
52
|
+
const scripts = [intercom({ appId: 'abc123' })];
|
|
53
|
+
|
|
54
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
55
|
+
return (
|
|
56
|
+
<ConsentManagerProvider
|
|
57
|
+
options={{
|
|
58
|
+
mode: 'hosted',
|
|
59
|
+
backendURL: '/api/c15t',
|
|
60
|
+
scripts,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</ConsentManagerProvider>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**JavaScript**
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
73
|
+
import { intercom } from '@c15t/scripts/intercom';
|
|
74
|
+
|
|
75
|
+
getOrCreateConsentRuntime({
|
|
76
|
+
mode: 'hosted',
|
|
77
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
78
|
+
scripts: [intercom({ appId: 'abc123' })],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## How c15t loads it
|
|
83
|
+
|
|
84
|
+
* **Category:** `functionality` (Functional)
|
|
85
|
+
* **Loads when:** functionality consent is granted
|
|
86
|
+
* **Before load:** c15t seeds `window.intercomSettings` and a queueing
|
|
87
|
+
`Intercom` stub
|
|
88
|
+
* **On revocation:** c15t follows the default script loader behavior for
|
|
89
|
+
non-persistent scripts
|
|
90
|
+
|
|
91
|
+
## Configure the integration
|
|
92
|
+
|
|
93
|
+
Intercom's default regional API base is `https://api-iam.intercom.io`. If your
|
|
94
|
+
workspace uses the EU or Australia data host, pass the matching `apiBase`.
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
intercom({
|
|
98
|
+
appId: 'abc123',
|
|
99
|
+
apiBase: 'https://api-iam.eu.intercom.io',
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Runtime options
|
|
104
|
+
|
|
105
|
+
Pass additional Intercom settings through `settings`. The helper always writes
|
|
106
|
+
the provided `appId` to `app_id` and `apiBase` to `api_base`.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
intercom({
|
|
110
|
+
appId: 'abc123',
|
|
111
|
+
settings: {
|
|
112
|
+
name: 'Ada Lovelace',
|
|
113
|
+
user_id: 'user-123',
|
|
114
|
+
company: {
|
|
115
|
+
company_id: 'company-123',
|
|
116
|
+
name: 'Example Company Inc.',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
For logged-in users, Intercom recommends securing the Messenger with
|
|
123
|
+
server-generated identity data. Generate verification tokens on your backend and
|
|
124
|
+
only pass client-safe values through `settings`.
|
|
125
|
+
|
|
126
|
+
## Types
|
|
127
|
+
|
|
128
|
+
### IntercomOptions
|
|
129
|
+
|
|
130
|
+
|Property|Type|Description|Default|Required|
|
|
131
|
+
|:--|:--|:--|:--|:--:|
|
|
132
|
+
|appId|string|Your Intercom app ID.|-|✅ Required|
|
|
133
|
+
|apiBase|IntercomApiBase \|undefined|Regional Intercom API base.|'https\://api-iam.intercom.io'|Optional|
|
|
134
|
+
|settings|IntercomCustomSettings \|undefined|Additional serializable Intercom settings merged into \`window\.intercomSettings\`.|-|Optional|
|
|
135
|
+
|scriptSrc|string \|undefined|Intercom loader URL.|-|Optional|
|
|
136
|
+
|
|
137
|
+
### Script
|
|
138
|
+
|
|
139
|
+
|Property|Type|Description|Default|Required|
|
|
140
|
+
|:--|:--|:--|:--|:--:|
|
|
141
|
+
|id|string|Unique identifier for the script|-|✅ Required|
|
|
142
|
+
|src|string \|undefined|URL of the script to load|-|Optional|
|
|
143
|
+
|textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
|
|
144
|
+
|category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
|
|
145
|
+
|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|
|
|
146
|
+
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
|
|
147
|
+
|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|
|
|
148
|
+
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
149
|
+
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
150
|
+
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
151
|
+
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
152
|
+
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
153
|
+
|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|
|
|
154
|
+
|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|
|
|
155
|
+
|onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
156
|
+
|onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
157
|
+
|onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
158
|
+
|onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
159
|
+
|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|
|
|
160
|
+
|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|
|
|
161
|
+
|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|
|
|
162
|
+
|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|
|
|
163
|
+
|
|
164
|
+
#### `onBeforeLoad`
|
|
165
|
+
|
|
166
|
+
Callback executed before the script is loaded
|
|
167
|
+
|
|
168
|
+
|Property|Type|Description|Default|Required|
|
|
169
|
+
|:--|:--|:--|:--|:--:|
|
|
170
|
+
|id|string|The original script ID|-|✅ Required|
|
|
171
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
172
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
173
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
174
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
175
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
176
|
+
|
|
177
|
+
#### `onLoad`
|
|
178
|
+
|
|
179
|
+
Callback executed when the script loads successfully
|
|
180
|
+
|
|
181
|
+
|Property|Type|Description|Default|Required|
|
|
182
|
+
|:--|:--|:--|:--|:--:|
|
|
183
|
+
|id|string|The original script ID|-|✅ Required|
|
|
184
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
185
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
186
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
187
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
188
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
189
|
+
|
|
190
|
+
#### `onError`
|
|
191
|
+
|
|
192
|
+
Callback executed if the script fails to load
|
|
193
|
+
|
|
194
|
+
|Property|Type|Description|Default|Required|
|
|
195
|
+
|:--|:--|:--|:--|:--:|
|
|
196
|
+
|id|string|The original script ID|-|✅ Required|
|
|
197
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
198
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
199
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
200
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
201
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
202
|
+
|
|
203
|
+
#### `onConsentChange`
|
|
204
|
+
|
|
205
|
+
Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
|
|
206
|
+
|
|
207
|
+
|Property|Type|Description|Default|Required|
|
|
208
|
+
|:--|:--|:--|:--|:--:|
|
|
209
|
+
|id|string|The original script ID|-|✅ Required|
|
|
210
|
+
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
211
|
+
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
212
|
+
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
213
|
+
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
214
|
+
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|