@c15t/scripts 2.1.0 → 2.2.0-canary-20260804162155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +62 -0
- package/README.md +32 -20
- package/dist/e2e-test-utils.cjs +51 -10
- package/dist/e2e-test-utils.js +37 -3
- package/dist/engine/compile.cjs +9 -5
- package/dist/engine/runtime.cjs +103 -17
- package/dist/engine/runtime.js +94 -12
- package/dist/registry.cjs +97 -12
- package/dist/registry.js +80 -0
- package/dist/resolve.cjs +9 -5
- package/dist/types.cjs +17 -13
- package/dist/vendors/_shared/attributes.cjs +13 -9
- package/dist/vendors/_shared/google-consent.cjs +14 -9
- package/dist/vendors/_shared/install-builders.cjs +12 -8
- package/dist/vendors/_shared/script-url.cjs +16 -12
- package/dist/vendors/ads-and-pixels/linkedin-insights.cjs +9 -5
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +13 -9
- package/dist/vendors/ads-and-pixels/microsoft-uet.cjs +11 -7
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +9 -5
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +11 -7
- package/dist/vendors/ads-and-pixels/tiktok-pixel.cjs +9 -5
- package/dist/vendors/ads-and-pixels/x-pixel.cjs +9 -5
- package/dist/vendors/analytics/adobe-analytics.cjs +90 -0
- package/dist/vendors/analytics/adobe-analytics.js +49 -0
- package/dist/vendors/analytics/ahrefs-analytics.cjs +11 -7
- package/dist/vendors/analytics/amplitude.cjs +193 -0
- package/dist/vendors/analytics/amplitude.js +134 -0
- package/dist/vendors/analytics/clearbit.cjs +69 -0
- package/dist/vendors/analytics/clearbit.js +28 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.cjs +11 -7
- package/dist/vendors/analytics/databuddy.cjs +11 -7
- package/dist/vendors/analytics/fathom-analytics.cjs +11 -7
- package/dist/vendors/analytics/google-tag.cjs +11 -7
- package/dist/vendors/analytics/heap.cjs +181 -0
- package/dist/vendors/analytics/heap.js +134 -0
- package/dist/vendors/analytics/hightouch.cjs +153 -0
- package/dist/vendors/analytics/hightouch.js +109 -0
- package/dist/vendors/analytics/hotjar.cjs +11 -7
- package/dist/vendors/analytics/logrocket.cjs +99 -0
- package/dist/vendors/analytics/logrocket.js +58 -0
- package/dist/vendors/analytics/matomo-analytics.cjs +9 -5
- package/dist/vendors/analytics/microsoft-clarity.cjs +75 -47
- package/dist/vendors/analytics/microsoft-clarity.js +64 -40
- package/dist/vendors/analytics/mixpanel-analytics.cjs +31 -16
- package/dist/vendors/analytics/mixpanel-analytics.js +22 -11
- package/dist/vendors/analytics/pirsch.cjs +108 -0
- package/dist/vendors/analytics/pirsch.js +67 -0
- package/dist/vendors/analytics/plausible-analytics.cjs +9 -5
- package/dist/vendors/analytics/posthog.cjs +63 -27
- package/dist/vendors/analytics/posthog.js +52 -20
- package/dist/vendors/analytics/promptwatch.cjs +11 -7
- package/dist/vendors/analytics/rudderstack.cjs +227 -0
- package/dist/vendors/analytics/rudderstack.js +183 -0
- package/dist/vendors/analytics/rybbit-analytics.cjs +9 -5
- package/dist/vendors/analytics/segment.cjs +9 -5
- package/dist/vendors/analytics/umami-analytics.cjs +9 -5
- package/dist/vendors/analytics/vercel-analytics.cjs +11 -7
- package/dist/vendors/functional/crisp.cjs +9 -5
- package/dist/vendors/functional/intercom.cjs +11 -7
- package/dist/vendors/tag-managers/google-tag-manager.cjs +11 -7
- package/dist-types/registry.d.ts +313 -241
- package/dist-types/types.d.ts +46 -4
- package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +18 -18
- package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +21 -21
- package/dist-types/vendors/ads-and-pixels/microsoft-uet.d.ts +32 -32
- package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +19 -19
- package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +16 -16
- package/dist-types/vendors/ads-and-pixels/tiktok-pixel.d.ts +28 -28
- package/dist-types/vendors/ads-and-pixels/x-pixel.d.ts +13 -13
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +7 -7
- package/dist-types/vendors/analytics/amplitude.d.ts +234 -0
- package/dist-types/vendors/analytics/clearbit.d.ts +60 -0
- package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +7 -7
- package/dist-types/vendors/analytics/databuddy.d.ts +25 -25
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +11 -11
- package/dist-types/vendors/analytics/google-tag.d.ts +17 -17
- package/dist-types/vendors/analytics/heap.d.ts +316 -0
- package/dist-types/vendors/analytics/hightouch.d.ts +285 -0
- package/dist-types/vendors/analytics/hotjar.d.ts +14 -14
- package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +42 -30
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +40 -28
- package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +13 -13
- package/dist-types/vendors/analytics/posthog.d.ts +63 -45
- package/dist-types/vendors/analytics/promptwatch.d.ts +7 -7
- package/dist-types/vendors/analytics/rudderstack.d.ts +330 -0
- package/dist-types/vendors/analytics/rybbit-analytics.d.ts +18 -18
- package/dist-types/vendors/analytics/segment.d.ts +13 -13
- package/dist-types/vendors/analytics/umami-analytics.d.ts +12 -12
- package/dist-types/vendors/analytics/vercel-analytics.d.ts +16 -16
- package/dist-types/vendors/functional/crisp.d.ts +11 -11
- package/dist-types/vendors/functional/intercom.d.ts +16 -16
- package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +18 -18
- package/docs/README.md +62 -0
- package/docs/frameworks/javascript/script-loader.md +356 -0
- package/docs/frameworks/next/script-loader.md +501 -0
- package/docs/frameworks/react/script-loader.md +555 -0
- package/docs/integrations/adobe-analytics.md +160 -0
- package/docs/integrations/ahrefs-analytics.md +157 -0
- package/docs/integrations/amplitude.md +230 -0
- package/docs/integrations/building-integrations.md +239 -0
- package/docs/integrations/clearbit.md +130 -0
- package/docs/integrations/cloudflare-web-analytics.md +126 -0
- package/docs/integrations/crisp.md +140 -0
- package/docs/integrations/databuddy.md +205 -0
- package/docs/integrations/fathom-analytics.md +150 -0
- package/docs/integrations/google-maps.md +263 -0
- package/docs/integrations/google-tag-manager.md +154 -0
- package/docs/integrations/google-tag.md +134 -0
- package/docs/integrations/heap.md +219 -0
- package/docs/integrations/hightouch.md +199 -0
- package/docs/integrations/hotjar.md +143 -0
- package/docs/integrations/intercom.md +144 -0
- package/docs/integrations/linkedin-insights.md +161 -0
- package/docs/integrations/logrocket.md +175 -0
- package/docs/integrations/matomo-analytics.md +171 -0
- package/docs/integrations/meta-pixel.md +412 -0
- package/docs/integrations/microsoft-clarity.md +173 -0
- package/docs/integrations/microsoft-uet.md +156 -0
- package/docs/integrations/mixpanel-analytics.md +130 -0
- package/docs/integrations/overview.md +149 -0
- package/docs/integrations/pirsch.md +142 -0
- package/docs/integrations/plausible-analytics.md +154 -0
- package/docs/integrations/posthog.md +258 -0
- package/docs/integrations/promptwatch.md +121 -0
- package/docs/integrations/reddit-pixel.md +241 -0
- package/docs/integrations/rudderstack.md +271 -0
- package/docs/integrations/rybbit-analytics.md +143 -0
- package/docs/integrations/segment.md +146 -0
- package/docs/integrations/snapchat-pixel.md +163 -0
- package/docs/integrations/tiktok-pixel.md +123 -0
- package/docs/integrations/umami-analytics.md +148 -0
- package/docs/integrations/vercel-analytics.md +141 -0
- package/docs/integrations/x-pixel.md +157 -0
- package/docs/integrations/youtube.md +193 -0
- package/docs/shared/react/guides/script-loader.md +311 -0
- package/package.json +61 -7
- package/readme.json +8 -4
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Matomo Analytics
|
|
3
|
+
description: Load Matomo with c15t and keep Matomo's queue aligned with measurement consent.
|
|
4
|
+
group: integrations
|
|
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|Value|
|
|
158
|
+
|:--|:--|
|
|
159
|
+
|Type Name|\`MatomoAnalyticsOptions\`|
|
|
160
|
+
|Source Path|\`./packages/scripts/src/vendors/analytics/matomo-analytics.ts\`|
|
|
161
|
+
|
|
162
|
+
\*ExtractedTypeTable: Could not extract "MatomoAnalyticsOptions" from "./packages/scripts/src/vendors/analytics/matomo-analytics.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
163
|
+
|
|
164
|
+
### Script
|
|
165
|
+
|
|
166
|
+
|Property|Value|
|
|
167
|
+
|:--|:--|
|
|
168
|
+
|Type Name|\`Script\`|
|
|
169
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
170
|
+
|
|
171
|
+
\*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,412 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Meta Pixel
|
|
3
|
+
description: Track conversions and build audiences for Facebook and Instagram
|
|
4
|
+
advertising campaigns.
|
|
5
|
+
icon: meta
|
|
6
|
+
group: integrations
|
|
7
|
+
---
|
|
8
|
+
Meta Pixel (formerly Facebook Pixel) is Meta's conversion tracking and audience targeting tool for Facebook and Instagram advertising. It tracks user actions, measures ad effectiveness, builds custom audiences, and optimizes ad delivery.
|
|
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 { metaPixel } from '@c15t/scripts/meta-pixel';
|
|
18
|
+
|
|
19
|
+
const scripts = [
|
|
20
|
+
metaPixel({
|
|
21
|
+
pixelId: '123456789012345',
|
|
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 { metaPixel } from '@c15t/scripts/meta-pixel';
|
|
48
|
+
|
|
49
|
+
const scripts = [
|
|
50
|
+
metaPixel({
|
|
51
|
+
pixelId: '123456789012345',
|
|
52
|
+
}),
|
|
53
|
+
];
|
|
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 { metaPixel } from '@c15t/scripts/meta-pixel';
|
|
75
|
+
|
|
76
|
+
getOrCreateConsentRuntime({
|
|
77
|
+
mode: 'hosted',
|
|
78
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
79
|
+
scripts: [
|
|
80
|
+
metaPixel({
|
|
81
|
+
pixelId: '123456789012345',
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## How c15t loads it
|
|
88
|
+
|
|
89
|
+
* **Category:** `marketing` (Ads & Pixels)
|
|
90
|
+
* **Loads when:** marketing consent is granted
|
|
91
|
+
* **Default install:** c15t queues `fbq('consent', 'grant')`, `fbq('init', pixelId)`, `fbq('track', 'PageView')`, then loads Meta's `fbevents.js`
|
|
92
|
+
* **On revocation:** [persists](/docs/frameworks/react/script-loader#persist-after-revocation) — c15t calls `fbq('consent', 'revoke')` so Meta stops tracking without removing the script
|
|
93
|
+
|
|
94
|
+
Meta recommends installing the base pixel on every page you want to measure. c15t injects scripts into the document head by default, which matches Meta's recommendation to load the pixel early.
|
|
95
|
+
|
|
96
|
+
## Configure the integration
|
|
97
|
+
|
|
98
|
+
Use the default setup when you want Meta's standard `PageView` event to fire as soon as the pixel loads after marketing consent.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
metaPixel({
|
|
102
|
+
pixelId: '123456789012345',
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For single-page applications, disable the automatic `PageView` and track route changes yourself.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
metaPixel({
|
|
110
|
+
pixelId: '123456789012345',
|
|
111
|
+
trackPageView: false,
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
You can pass optional init data as the third argument to `fbq('init', ...)`.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
metaPixel({
|
|
119
|
+
pixelId: '123456789012345',
|
|
120
|
+
initOptions: {
|
|
121
|
+
external_id: 'customer-123',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Tracking events in your app
|
|
127
|
+
|
|
128
|
+
c15t gates the Meta Pixel script from loading until `marketing` consent is
|
|
129
|
+
granted. After consent is granted the script stays in the DOM, and c15t calls
|
|
130
|
+
`fbq('consent', 'revoke')` if consent is later revoked so Meta stops tracking
|
|
131
|
+
without removing the script.
|
|
132
|
+
|
|
133
|
+
This means `window.fbq` and the `metaPixelEvent` helpers are only defined after
|
|
134
|
+
the user has granted marketing consent at least once. Before that, unguarded
|
|
135
|
+
calls throw.
|
|
136
|
+
|
|
137
|
+
### Standard events
|
|
138
|
+
|
|
139
|
+
Use `metaPixelEvent` to track Meta standard events. It is a typed wrapper around `fbq('track', ...)`.
|
|
140
|
+
|
|
141
|
+
Meta documents standard event tracking in its [conversion tracking guide](https://developers.facebook.com/docs/meta-pixel/implementation/conversion-tracking) and [Marketing API pixel examples](https://developers.facebook.com/docs/meta-pixel/implementation/marketing-api).
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { metaPixelEvent } from '@c15t/scripts/meta-pixel';
|
|
145
|
+
|
|
146
|
+
metaPixelEvent('Lead', {
|
|
147
|
+
value: 40,
|
|
148
|
+
currency: 'USD',
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
metaPixelEvent('AddToCart', {
|
|
152
|
+
content_ids: ['SKU-123'],
|
|
153
|
+
content_type: 'product',
|
|
154
|
+
value: 49.99,
|
|
155
|
+
currency: 'USD',
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
metaPixelEvent(
|
|
159
|
+
'Purchase',
|
|
160
|
+
{
|
|
161
|
+
contents: [
|
|
162
|
+
{ id: 'SKU-123', quantity: 2 },
|
|
163
|
+
{ id: 'SKU-456', quantity: 1 },
|
|
164
|
+
],
|
|
165
|
+
content_type: 'product',
|
|
166
|
+
value: 149.97,
|
|
167
|
+
currency: 'USD',
|
|
168
|
+
},
|
|
169
|
+
'browser-event-123'
|
|
170
|
+
);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The optional third argument can be an event ID string or an options object. c15t forwards string IDs as `{ eventID: '...' }`, which is the browser-side format used for Conversions API deduplication.
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
metaPixelEvent(
|
|
177
|
+
'Purchase',
|
|
178
|
+
{ value: 149.97, currency: 'USD' },
|
|
179
|
+
{ eventID: 'browser-event-123' }
|
|
180
|
+
);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Custom events
|
|
184
|
+
|
|
185
|
+
Use `metaPixelCustomEvent` when Meta's standard events do not fit the action you are measuring. Meta custom event names must be strings and cannot exceed 50 characters.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { metaPixelCustomEvent } from '@c15t/scripts/meta-pixel';
|
|
189
|
+
|
|
190
|
+
metaPixelCustomEvent('ShareDiscount', {
|
|
191
|
+
promotion: 'share_discount_10%',
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Custom events can also use an event ID for Conversions API deduplication.
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
metaPixelCustomEvent(
|
|
199
|
+
'ShareDiscount',
|
|
200
|
+
{ promotion: 'share_discount_10%' },
|
|
201
|
+
'browser-event-456'
|
|
202
|
+
);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Guard event calls with consent
|
|
206
|
+
|
|
207
|
+
The example below intentionally uses `useConsentManager().has('marketing')` as
|
|
208
|
+
a defensive policy so your app avoids calling `metaPixelEvent` whenever consent
|
|
209
|
+
is currently revoked, even though Meta also suppresses tracking after initial
|
|
210
|
+
load.
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
import { useConsentManager } from '@c15t/react';
|
|
214
|
+
import { metaPixelEvent } from '@c15t/scripts/meta-pixel';
|
|
215
|
+
|
|
216
|
+
function useTrackPurchase() {
|
|
217
|
+
const { has } = useConsentManager();
|
|
218
|
+
|
|
219
|
+
// Defensive pattern: only call metaPixelEvent while marketing consent is granted.
|
|
220
|
+
return () => {
|
|
221
|
+
if (has('marketing')) {
|
|
222
|
+
metaPixelEvent('Purchase', { value: 10.0, currency: 'USD' });
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function PurchaseButton() {
|
|
228
|
+
const trackPurchase = useTrackPurchase();
|
|
229
|
+
|
|
230
|
+
return <button onClick={trackPurchase}>Complete purchase</button>;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### SPA route changes
|
|
235
|
+
|
|
236
|
+
Meta's [SPA guidance](https://developers.facebook.com/docs/facebook-pixel/implementation/tag_spa) recommends tracking meaningful URL changes from your router. Disable the install-time `PageView`, then emit page views after navigation while marketing consent is granted.
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import { useConsentManager } from '@c15t/react';
|
|
240
|
+
import { metaPixelEvent } from '@c15t/scripts/meta-pixel';
|
|
241
|
+
import { useEffect } from 'react';
|
|
242
|
+
import { useLocation } from 'react-router-dom';
|
|
243
|
+
|
|
244
|
+
function MetaRouteTracking() {
|
|
245
|
+
const { has } = useConsentManager();
|
|
246
|
+
const location = useLocation();
|
|
247
|
+
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
if (has('marketing')) {
|
|
250
|
+
metaPixelEvent('PageView');
|
|
251
|
+
}
|
|
252
|
+
}, [has, location.pathname, location.search]);
|
|
253
|
+
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Consent and privacy
|
|
259
|
+
|
|
260
|
+
Meta's GDPR guidance documents `fbq('consent', 'revoke')` and `fbq('consent', 'grant')`. c15t handles those calls for you after the script has loaded once:
|
|
261
|
+
|
|
262
|
+
* Before marketing consent, c15t does not load Meta Pixel.
|
|
263
|
+
* When marketing consent is granted, c15t loads Meta Pixel and calls `fbq('consent', 'grant')`.
|
|
264
|
+
* When marketing consent is revoked later, c15t keeps the script in place and calls `fbq('consent', 'revoke')`.
|
|
265
|
+
|
|
266
|
+
For US state privacy rules, Meta supports [Data Processing Options](https://developers.facebook.com/docs/meta-pixel/implementation/data-processing-options). Pass `dataProcessingOptions` to queue `fbq('dataProcessingOptions', ...)` before `fbq('init', ...)`.
|
|
267
|
+
|
|
268
|
+
Let Meta geolocate Limited Data Use:
|
|
269
|
+
|
|
270
|
+
```ts
|
|
271
|
+
metaPixel({
|
|
272
|
+
pixelId: '123456789012345',
|
|
273
|
+
dataProcessingOptions: {
|
|
274
|
+
options: ['LDU'],
|
|
275
|
+
country: 0,
|
|
276
|
+
state: 0,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Enable Limited Data Use for California:
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
metaPixel({
|
|
285
|
+
pixelId: '123456789012345',
|
|
286
|
+
dataProcessingOptions: {
|
|
287
|
+
options: ['LDU'],
|
|
288
|
+
country: 1,
|
|
289
|
+
state: 1000,
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Explicitly disable Limited Data Use:
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
metaPixel({
|
|
298
|
+
pixelId: '123456789012345',
|
|
299
|
+
dataProcessingOptions: {
|
|
300
|
+
options: [],
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Catalog and collaborative ads
|
|
306
|
+
|
|
307
|
+
For Advantage+ catalog ads, Meta requires `ViewContent`, `AddToCart`, and `Purchase` events to include either `content_ids` or `contents`. IDs must match your product catalog. See Meta's [Advantage+ catalog ads guide](https://developers.facebook.com/docs/meta-pixel/get-started/advantage-catalog-ads).
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
metaPixelEvent('ViewContent', {
|
|
311
|
+
content_ids: ['SKU-123'],
|
|
312
|
+
content_type: 'product',
|
|
313
|
+
value: 49.99,
|
|
314
|
+
currency: 'USD',
|
|
315
|
+
});
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
For collaborative ads, Meta requires `content_type: 'product'`; `AddToCart` and `Purchase` also require `contents`, `currency`, and `value`. See Meta's [collaborative ads pixel guide](https://developers.facebook.com/docs/meta-pixel/implementation/pixel-for-collaborative-ads).
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
metaPixelEvent('AddToCart', {
|
|
322
|
+
contents: [{ id: 'SKU-123', quantity: 2 }],
|
|
323
|
+
content_type: 'product',
|
|
324
|
+
value: 99.98,
|
|
325
|
+
currency: 'USD',
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Movies
|
|
330
|
+
|
|
331
|
+
Meta's [movies pixel guide](https://developers.facebook.com/docs/meta-pixel/implementation/pixel-for-movies) uses the standard events `ViewContent`, `InitiateCheckout`, `Purchase`, and `PageView` with movie-specific parameters such as `movieref`.
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
metaPixelEvent('InitiateCheckout', {
|
|
335
|
+
content_ids: ['movie-1|theater-1|2026-05-11T19:30:00-07:00'],
|
|
336
|
+
movieref: 'fb_movies',
|
|
337
|
+
num_items: 2,
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Multiple pixels
|
|
342
|
+
|
|
343
|
+
Meta's [multiple pixel guidance](https://developers.facebook.com/docs/facebook-pixel/implementation/accurate_event_tracking) warns that `fbq('track', ...)` and `fbq('trackCustom', ...)` fire for every initialized pixel ID. If another integration or tag manager initializes more than one pixel, use the single-pixel helpers to prevent overfiring.
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import {
|
|
347
|
+
metaPixelSingleCustomEvent,
|
|
348
|
+
metaPixelSingleEvent,
|
|
349
|
+
} from '@c15t/scripts/meta-pixel';
|
|
350
|
+
|
|
351
|
+
metaPixelSingleEvent('PIXEL-A', 'Purchase', {
|
|
352
|
+
value: 149.97,
|
|
353
|
+
currency: 'USD',
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
metaPixelSingleCustomEvent('PIXEL-B', 'Step4', {
|
|
357
|
+
funnel: 'checkout',
|
|
358
|
+
});
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Custom audiences and sharing
|
|
362
|
+
|
|
363
|
+
Meta custom audiences are configured in Events Manager after standard events, custom events, or custom conversions are being received. The c15t integration sends the browser events; audience rules are managed in Meta. See Meta's [custom audiences guide](https://developers.facebook.com/docs/facebook-pixel/implementation/custom-audiences).
|
|
364
|
+
|
|
365
|
+
Pixel sharing between businesses or agencies is also managed through Meta Business Manager or the Business Management APIs, not through the browser script. See Meta's [pixel sharing guide](https://developers.facebook.com/docs/marketing-api/business-asset-management/guides/business-pixel-sharing).
|
|
366
|
+
|
|
367
|
+
## Types
|
|
368
|
+
|
|
369
|
+
### MetaPixelOptions
|
|
370
|
+
|
|
371
|
+
|Property|Value|
|
|
372
|
+
|:--|:--|
|
|
373
|
+
|Type Name|\`MetaPixelOptions\`|
|
|
374
|
+
|Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/meta-pixel.ts\`|
|
|
375
|
+
|
|
376
|
+
\*ExtractedTypeTable: Could not extract "MetaPixelOptions" from "./packages/scripts/src/vendors/ads-and-pixels/meta-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
377
|
+
|
|
378
|
+
### MetaPixelDataProcessingOptions
|
|
379
|
+
|
|
380
|
+
|Property|Value|
|
|
381
|
+
|:--|:--|
|
|
382
|
+
|Type Name|\`MetaPixelDataProcessingOptions\`|
|
|
383
|
+
|Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/meta-pixel.ts\`|
|
|
384
|
+
|
|
385
|
+
\*ExtractedTypeTable: Could not extract "MetaPixelDataProcessingOptions" from "./packages/scripts/src/vendors/ads-and-pixels/meta-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
386
|
+
|
|
387
|
+
### MetaPixelEventOptions
|
|
388
|
+
|
|
389
|
+
|Property|Value|
|
|
390
|
+
|:--|:--|
|
|
391
|
+
|Type Name|\`MetaPixelEventOptions\`|
|
|
392
|
+
|Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/meta-pixel.ts\`|
|
|
393
|
+
|
|
394
|
+
\*ExtractedTypeTable: Could not extract "MetaPixelEventOptions" from "./packages/scripts/src/vendors/ads-and-pixels/meta-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
395
|
+
|
|
396
|
+
### Script
|
|
397
|
+
|
|
398
|
+
|Property|Value|
|
|
399
|
+
|:--|:--|
|
|
400
|
+
|Type Name|\`Script\`|
|
|
401
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
402
|
+
|
|
403
|
+
\*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.\*
|
|
404
|
+
|
|
405
|
+
### StandardEventParams
|
|
406
|
+
|
|
407
|
+
|Property|Value|
|
|
408
|
+
|:--|:--|
|
|
409
|
+
|Type Name|\`StandardEventParams\`|
|
|
410
|
+
|Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/meta-pixel.ts\`|
|
|
411
|
+
|
|
412
|
+
\*ExtractedTypeTable: Could not extract "StandardEventParams" from "./packages/scripts/src/vendors/ads-and-pixels/meta-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|