@c15t/react 2.0.4 → 2.2.0-canary-20260727202135
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 +29 -14
- package/client/components/integrations.js +3 -0
- package/dist/components/consent-banner/atoms/overlay.cjs +1 -1
- package/dist/components/consent-banner/atoms/root.cjs +1 -1
- package/dist/components/consent-banner/components.cjs +1 -1
- package/dist/components/consent-banner/consent-banner.cjs +1 -1
- package/dist/components/consent-banner/error-boundary.cjs +1 -1
- package/dist/components/consent-banner/index.cjs +1 -1
- package/dist/components/consent-banner/policy-actions.cjs +1 -1
- package/dist/components/consent-dialog/atoms/card.cjs +1 -1
- package/dist/components/consent-dialog/atoms/overlay.cjs +1 -1
- package/dist/components/consent-dialog/atoms/root.cjs +1 -1
- package/dist/components/consent-dialog/consent-dialog.cjs +1 -1
- package/dist/components/consent-dialog/index.cjs +1 -1
- package/dist/components/consent-dialog-link/index.cjs +1 -1
- package/dist/components/consent-dialog-trigger/atoms/button.cjs +1 -1
- package/dist/components/consent-dialog-trigger/atoms/button.js +1 -1
- package/dist/components/consent-dialog-trigger/atoms/icon.cjs +1 -1
- package/dist/components/consent-dialog-trigger/atoms/root.cjs +1 -1
- package/dist/components/consent-dialog-trigger/atoms/text.cjs +1 -1
- package/dist/components/consent-dialog-trigger/atoms/toolbar.cjs +1 -0
- package/dist/components/consent-dialog-trigger/atoms/toolbar.js +1 -0
- package/dist/components/consent-dialog-trigger/consent-dialog-trigger-toolbar.cjs +1 -0
- package/dist/components/consent-dialog-trigger/consent-dialog-trigger-toolbar.js +1 -0
- package/dist/components/consent-dialog-trigger/consent-dialog-trigger.cjs +1 -1
- package/dist/components/consent-dialog-trigger/index.cjs +1 -1
- package/dist/components/consent-dialog-trigger/index.js +1 -1
- package/dist/components/consent-dialog-trigger/use-draggable.cjs +1 -1
- package/dist/components/consent-preferences-link/consent-preferences-link.cjs +1 -1
- package/dist/components/consent-preferences-link/index.cjs +1 -1
- package/dist/components/consent-widget/atoms/accordion.cjs +1 -1
- package/dist/components/consent-widget/atoms/button.cjs +1 -1
- package/dist/components/consent-widget/atoms/footer.cjs +1 -1
- package/dist/components/consent-widget/atoms/root.cjs +1 -1
- package/dist/components/consent-widget/consent-widget.cjs +1 -1
- package/dist/components/consent-widget/index.cjs +1 -1
- package/dist/components/consent-widget/policy-actions.cjs +1 -1
- package/dist/components/frame/atoms.cjs +1 -1
- package/dist/components/frame/atoms.js +1 -1
- package/dist/components/frame/frame.cjs +1 -1
- package/dist/components/frame/index.cjs +1 -1
- package/dist/components/iab-consent-banner/atoms/button-group.cjs +1 -1
- package/dist/components/iab-consent-banner/atoms/card.cjs +1 -1
- package/dist/components/iab-consent-banner/atoms/description.cjs +1 -1
- package/dist/components/iab-consent-banner/atoms/footer.cjs +1 -1
- package/dist/components/iab-consent-banner/atoms/header.cjs +1 -1
- package/dist/components/iab-consent-banner/atoms/overlay.cjs +1 -1
- package/dist/components/iab-consent-banner/atoms/root.cjs +1 -1
- package/dist/components/iab-consent-banner/atoms/title.cjs +1 -1
- package/dist/components/iab-consent-banner/iab-consent-banner.cjs +1 -1
- package/dist/components/iab-consent-banner/iab-consent-banner.js +1 -1
- package/dist/components/iab-consent-banner/index.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/card.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/content.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/footer.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/header.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/overlay.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/purpose-item.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/root.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/stack-item.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/tabs.cjs +1 -1
- package/dist/components/iab-consent-dialog/atoms/vendor-list.cjs +1 -1
- package/dist/components/iab-consent-dialog/hooks/use-gvl-data.cjs +1 -1
- package/dist/components/iab-consent-dialog/iab-consent-dialog.cjs +1 -1
- package/dist/components/iab-consent-dialog/index.cjs +1 -1
- package/dist/components/iab-consent-dialog/use-iab-translations.cjs +1 -1
- package/dist/components/integrations/google-map.cjs +1 -0
- package/dist/components/integrations/google-map.js +1 -0
- package/dist/components/integrations/index.cjs +1 -0
- package/dist/components/integrations/index.js +1 -0
- package/dist/components/integrations/shared.cjs +1 -0
- package/dist/components/integrations/shared.js +1 -0
- package/dist/components/integrations/youtube-embed.cjs +1 -0
- package/dist/components/integrations/youtube-embed.js +1 -0
- package/dist/components/shared/libs/recursive-clone-children.cjs +1 -1
- package/dist/components/shared/libs/slot.cjs +1 -1
- package/dist/components/shared/libs/use-controllable-state.cjs +1 -1
- package/dist/components/shared/policy-actions.cjs +1 -1
- package/dist/components/shared/primitives/box.cjs +1 -1
- package/dist/components/shared/primitives/button.cjs +1 -1
- package/dist/components/shared/primitives/button.js +1 -1
- package/dist/components/shared/primitives/legal-links/index.cjs +1 -1
- package/dist/components/shared/primitives/legal-links/index.js +1 -1
- package/dist/components/shared/ui/accordion/accordion.cjs +1 -1
- package/dist/components/shared/ui/accordion/index.cjs +1 -1
- package/dist/components/shared/ui/animated-collapse/animated-collapse.cjs +1 -1
- package/dist/components/shared/ui/animated-collapse/index.cjs +1 -1
- package/dist/components/shared/ui/branding.cjs +1 -1
- package/dist/components/shared/ui/button/button.cjs +1 -1
- package/dist/components/shared/ui/button/index.cjs +1 -1
- package/dist/components/shared/ui/collapsible/collapsible.cjs +1 -1
- package/dist/components/shared/ui/collapsible/index.cjs +1 -1
- package/dist/components/shared/ui/dialog/dialog.cjs +1 -1
- package/dist/components/shared/ui/dialog/index.cjs +1 -1
- package/dist/components/shared/ui/icon.cjs +1 -1
- package/dist/components/shared/ui/logo.cjs +1 -1
- package/dist/components/shared/ui/preference-item/index.cjs +1 -1
- package/dist/components/shared/ui/preference-item/preference-item.cjs +1 -1
- package/dist/components/shared/ui/switch/index.cjs +1 -1
- package/dist/components/shared/ui/switch/switch.cjs +1 -1
- package/dist/components/shared/ui/tabs/index.cjs +1 -1
- package/dist/components/shared/ui/tabs/tabs.cjs +1 -1
- package/dist/context/consent-manager-context.cjs +1 -1
- package/dist/context/consent-tracking-context.cjs +1 -1
- package/dist/context/theme-context.cjs +1 -1
- package/dist/headless.cjs +1 -1
- package/dist/headless.js +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-color-scheme.cjs +1 -1
- package/dist/hooks/use-component-config.cjs +1 -1
- package/dist/hooks/use-consent-dialog-trigger.cjs +1 -1
- package/dist/hooks/use-consent-manager.cjs +1 -1
- package/dist/hooks/use-consent-script.cjs +1 -0
- package/dist/hooks/use-consent-script.js +1 -0
- package/dist/hooks/use-focus-trap.cjs +1 -1
- package/dist/hooks/use-headless-consent-ui.cjs +1 -1
- package/dist/hooks/use-headless-iab-consent-ui.cjs +1 -1
- package/dist/hooks/use-reduced-motion.cjs +1 -1
- package/dist/hooks/use-scroll-lock.cjs +1 -1
- package/dist/hooks/use-ssr-status.cjs +1 -1
- package/dist/hooks/use-styles.cjs +1 -1
- package/dist/hooks/use-text-direction.cjs +1 -1
- package/dist/hooks/use-theme.cjs +1 -1
- package/dist/hooks/use-translations.cjs +1 -1
- package/dist/iab.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/primitives/accordion.cjs +1 -1
- package/dist/primitives/button.cjs +1 -1
- package/dist/primitives/collapsible.cjs +1 -1
- package/dist/primitives/dialog.cjs +1 -1
- package/dist/primitives/preference-item.cjs +1 -1
- package/dist/primitives/switch.cjs +1 -1
- package/dist/primitives/tabs.cjs +1 -1
- package/dist/primitives.cjs +1 -1
- package/dist/providers/consent-manager-provider.cjs +1 -1
- package/dist/server/fetch-ssr-data.cjs +1 -1
- package/dist/server/fetch-ssr-data.js +1 -1
- package/dist/server/headers.cjs +1 -1
- package/dist/server/headers.js +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/init-cache-key.cjs +1 -1
- package/dist/server/normalize-url.cjs +1 -1
- package/dist/styles.tw3.css +1 -1
- package/dist/types/theme/index.cjs +1 -1
- package/dist/types/theme/style-types.cjs +1 -1
- package/dist/utils/cn.cjs +1 -1
- package/dist/utils/merge-styles.cjs +1 -1
- package/dist/utils/test-helpers.cjs +1 -1
- package/dist/utils/theme-utils.cjs +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist-types/components/consent-banner/components.d.ts +2 -2
- package/dist-types/components/consent-banner/policy-actions.d.ts +1 -1
- package/dist-types/components/consent-dialog/atoms/card.d.ts +5 -5
- package/dist-types/components/consent-dialog-trigger/atoms/toolbar.d.ts +22 -0
- package/dist-types/components/consent-dialog-trigger/consent-dialog-trigger-toolbar.d.ts +35 -0
- package/dist-types/components/consent-dialog-trigger/index.d.ts +2 -1
- package/dist-types/components/consent-dialog-trigger/types.d.ts +111 -6
- package/dist-types/components/consent-widget/atoms/accordion.d.ts +4 -4
- package/dist-types/components/consent-widget/consent-widget.d.ts +1 -1
- package/dist-types/components/consent-widget/policy-actions.d.ts +1 -1
- package/dist-types/components/integrations/google-map.d.ts +82 -0
- package/dist-types/components/integrations/index.d.ts +2 -0
- package/dist-types/components/integrations/shared.d.ts +12 -0
- package/dist-types/components/integrations/youtube-embed.d.ts +95 -0
- package/dist-types/components/shared/policy-actions.d.ts +1 -1
- package/dist-types/components/shared/primitives/button.d.ts +36 -2
- package/dist-types/components/shared/primitives/legal-links/index.d.ts +1 -1
- package/dist-types/components/shared/ui/accordion/accordion.d.ts +2 -2
- package/dist-types/components/shared/ui/branding.d.ts +3 -3
- package/dist-types/components/shared/ui/button/button.d.ts +1 -1
- package/dist-types/components/shared/ui/dialog/dialog.d.ts +1 -1
- package/dist-types/components/shared/ui/logo.d.ts +8 -8
- package/dist-types/headless.d.ts +1 -0
- package/dist-types/hooks/index.d.ts +1 -0
- package/dist-types/hooks/use-consent-script.d.ts +80 -0
- package/dist-types/index.d.ts +3 -1
- package/dist-types/providers/consent-manager-provider.d.ts +1 -1
- package/dist-types/server/headers.d.ts +1 -1
- package/dist-types/utils/theme-utils.d.ts +1 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +155 -76
- package/docs/{building-headless-components.md → frameworks/react/building-headless-components.md} +3 -1
- package/docs/{callbacks.md → frameworks/react/callbacks.md} +3 -1
- package/docs/{components → frameworks/react/components}/consent-banner.md +10 -21
- package/docs/{components → frameworks/react/components}/consent-dialog-link.md +8 -5
- package/docs/frameworks/react/components/consent-dialog-trigger.md +202 -0
- package/docs/{components → frameworks/react/components}/consent-dialog.md +7 -15
- package/docs/frameworks/react/components/consent-manager-provider.md +228 -0
- package/docs/{components → frameworks/react/components}/consent-widget.md +8 -6
- package/docs/{components → frameworks/react/components}/dev-tools.md +9 -6
- package/docs/{components → frameworks/react/components}/frame.md +8 -9
- package/docs/{concepts → frameworks/react/concepts}/client-modes.md +4 -2
- package/docs/{concepts → frameworks/react/concepts}/consent-categories.md +1 -0
- package/docs/{concepts → frameworks/react/concepts}/consent-models.md +1 -0
- package/docs/{concepts → frameworks/react/concepts}/cookie-management.md +3 -3
- package/docs/{concepts → frameworks/react/concepts}/glossary.md +1 -0
- package/docs/{concepts → frameworks/react/concepts}/initialization-flow.md +1 -0
- package/docs/{concepts → frameworks/react/concepts}/policy-packs.md +1 -0
- package/docs/{headless.md → frameworks/react/headless.md} +3 -1
- package/docs/{hooks → frameworks/react/hooks}/use-color-scheme.md +1 -0
- package/docs/{hooks → frameworks/react/hooks}/use-consent-manager/checking-consent.md +3 -1
- package/docs/{hooks → frameworks/react/hooks}/use-consent-manager/location-info.md +3 -1
- package/docs/frameworks/react/hooks/use-consent-manager/overview.md +172 -0
- package/docs/{hooks → frameworks/react/hooks}/use-consent-manager/setting-consent.md +3 -1
- package/docs/{hooks → frameworks/react/hooks}/use-draggable.md +3 -1
- package/docs/{hooks → frameworks/react/hooks}/use-focus-trap.md +1 -0
- package/docs/{hooks → frameworks/react/hooks}/use-reduced-motion.md +3 -1
- package/docs/{hooks → frameworks/react/hooks}/use-ssr-status.md +6 -5
- package/docs/{hooks → frameworks/react/hooks}/use-text-direction.md +1 -0
- package/docs/frameworks/react/hooks/use-translations.md +55 -0
- package/docs/{iab → frameworks/react/iab}/consent-banner.md +9 -12
- package/docs/{iab → frameworks/react/iab}/consent-dialog.md +9 -14
- package/docs/{iab → frameworks/react/iab}/overview.md +4 -2
- package/docs/{iab → frameworks/react/iab}/use-gvl-data.md +3 -2
- package/docs/{iframe-blocking.md → frameworks/react/iframe-blocking.md} +8 -9
- package/docs/{internationalization.md → frameworks/react/internationalization.md} +13 -3
- package/docs/{network-blocker.md → frameworks/react/network-blocker.md} +13 -51
- package/docs/{optimization.md → frameworks/react/optimization.md} +3 -2
- package/docs/{policy-packs.md → frameworks/react/policy-packs.md} +3 -1
- package/docs/{quickstart.md → frameworks/react/quickstart.md} +26 -42
- package/docs/frameworks/react/script-loader.md +553 -0
- package/docs/{server-side.md → frameworks/react/server-side.md} +9 -4
- package/docs/{styling → frameworks/react/styling}/classnames.md +3 -1
- package/docs/{styling → frameworks/react/styling}/color-scheme.md +3 -1
- package/docs/frameworks/react/styling/css-variables.md +53 -0
- package/docs/frameworks/react/styling/overview.md +302 -0
- package/docs/frameworks/react/styling/slots.md +94 -0
- package/docs/{styling → frameworks/react/styling}/tailwind.md +3 -1
- package/docs/frameworks/react/styling/tokens.md +156 -0
- package/docs/{troubleshooting.md → frameworks/react/troubleshooting.md} +3 -1
- 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 +15 -181
- 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 +152 -150
- package/docs/integrations/fathom-analytics.md +150 -0
- package/docs/integrations/google-maps.md +263 -0
- package/docs/integrations/google-tag-manager.md +102 -101
- package/docs/integrations/google-tag.md +104 -92
- 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 +142 -90
- package/docs/integrations/logrocket.md +175 -0
- package/docs/integrations/matomo-analytics.md +171 -0
- package/docs/integrations/meta-pixel.md +379 -309
- package/docs/integrations/microsoft-clarity.md +173 -0
- package/docs/integrations/microsoft-uet.md +135 -91
- package/docs/integrations/mixpanel-analytics.md +130 -0
- package/docs/integrations/overview.md +119 -75
- package/docs/integrations/pirsch.md +142 -0
- package/docs/integrations/plausible-analytics.md +154 -0
- package/docs/integrations/posthog.md +186 -127
- 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 +101 -91
- package/docs/integrations/umami-analytics.md +148 -0
- package/docs/integrations/vercel-analytics.md +141 -0
- package/docs/integrations/x-pixel.md +123 -109
- 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 +183 -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 +309 -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 +23 -12
- package/readme.json +12 -7
- 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/script-loader.md +0 -321
- package/docs/styling/css-variables.md +0 -92
- package/docs/styling/overview.md +0 -460
- package/docs/styling/slots.md +0 -128
- package/docs/styling/tokens.md +0 -216
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Vercel Analytics
|
|
3
|
+
description: Bootstrap Vercel Analytics with a declarative queue and script attributes.
|
|
4
|
+
group: integrations
|
|
5
|
+
icon: vercel-analytics
|
|
6
|
+
---
|
|
7
|
+
Vercel Analytics loads through `@c15t/scripts` using a declarative queue bootstrap (`vaq` + `va`) and script attributes for DSN/endpoint options.
|
|
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 { vercelAnalytics } from '@c15t/scripts/vercel-analytics';
|
|
17
|
+
|
|
18
|
+
const scripts = [vercelAnalytics()];
|
|
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 { vercelAnalytics } from '@c15t/scripts/vercel-analytics';
|
|
43
|
+
|
|
44
|
+
const scripts = [vercelAnalytics()];
|
|
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 { vercelAnalytics } from '@c15t/scripts/vercel-analytics';
|
|
66
|
+
|
|
67
|
+
getOrCreateConsentRuntime({
|
|
68
|
+
mode: 'hosted',
|
|
69
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
70
|
+
scripts: [vercelAnalytics()],
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## How c15t loads it
|
|
75
|
+
|
|
76
|
+
* **Category:** `measurement` (Analytics)
|
|
77
|
+
* **Loads when:** measurement consent is granted
|
|
78
|
+
* **On revocation:** unloaded - c15t removes the script from the DOM and clears access to runtime globals until consent is granted again.
|
|
79
|
+
|
|
80
|
+
Load the debug bundle or a custom endpoint when needed:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
vercelAnalytics({
|
|
84
|
+
mode: 'development',
|
|
85
|
+
disableAutoTrack: true,
|
|
86
|
+
endpoint: 'https://analytics.example.com/v1/events',
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Tracking events in your app
|
|
91
|
+
|
|
92
|
+
c15t initializes a bootstrap phase first (`vaq` plus a local `window.va` stub), then loads the remote Vercel Analytics script after `measurement` consent is granted. Calls are safe once the bootstrap stub exists (they are queued/ignored in `vaq`), but they execute only after consent is granted and the real `window.va` is injected and flushes the queue.
|
|
93
|
+
|
|
94
|
+
Guard event calls by checking consent state. From React:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { useCallback } from 'react';
|
|
98
|
+
import { useConsentManager } from '@c15t/react';
|
|
99
|
+
|
|
100
|
+
function SignupExample() {
|
|
101
|
+
const { has } = useConsentManager();
|
|
102
|
+
|
|
103
|
+
const trackSignup = useCallback(() => {
|
|
104
|
+
if (has('measurement')) {
|
|
105
|
+
window.va?.('signup', { plan: 'pro' });
|
|
106
|
+
}
|
|
107
|
+
}, [has]);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
From plain JavaScript:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
115
|
+
|
|
116
|
+
const { consentStore } = getOrCreateConsentRuntime();
|
|
117
|
+
|
|
118
|
+
if (consentStore.getState().has('measurement')) {
|
|
119
|
+
window.va?.('signup', { plan: 'pro' });
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Types
|
|
124
|
+
|
|
125
|
+
### VercelAnalyticsOptions
|
|
126
|
+
|
|
127
|
+
|Property|Value|
|
|
128
|
+
|:--|:--|
|
|
129
|
+
|Type Name|\`VercelAnalyticsOptions\`|
|
|
130
|
+
|Source Path|\`./packages/scripts/src/vendors/analytics/vercel-analytics.ts\`|
|
|
131
|
+
|
|
132
|
+
\*ExtractedTypeTable: Could not extract "VercelAnalyticsOptions" from "./packages/scripts/src/vendors/analytics/vercel-analytics.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
133
|
+
|
|
134
|
+
### Script
|
|
135
|
+
|
|
136
|
+
|Property|Value|
|
|
137
|
+
|:--|:--|
|
|
138
|
+
|Type Name|\`Script\`|
|
|
139
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
140
|
+
|
|
141
|
+
\*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,26 +1,88 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: X Pixel (Twitter Pixel)
|
|
3
|
-
description: Track conversions and build audiences for advertising campaigns on
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
description: Track conversions and build audiences for advertising campaigns on
|
|
4
|
+
X (formerly Twitter).
|
|
6
5
|
icon: x
|
|
6
|
+
group: integrations
|
|
7
7
|
---
|
|
8
|
-
X Pixel (formerly Twitter Pixel) is X's conversion tracking and audience building tool. It helps you measure ad performance, retarget website visitors, and optimize campaigns on the X platform.
|
|
8
|
+
X Pixel (formerly Twitter Pixel) is X's conversion tracking and audience building tool. It helps you measure ad performance, retarget website visitors, and optimize campaigns on the X platform.
|
|
9
|
+
|
|
10
|
+
## Official X documentation
|
|
11
|
+
|
|
12
|
+
* [Conversion tracking for websites (X Ads Help)](https://business.x.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites)
|
|
13
|
+
|
|
14
|
+
## Integrate with c15t
|
|
15
|
+
|
|
16
|
+
**React**
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { type ReactNode } from 'react';
|
|
20
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
21
|
+
import { xPixel } from '@c15t/scripts/x-pixel';
|
|
9
22
|
|
|
10
|
-
|
|
23
|
+
const scripts = [xPixel({ pixelId: '123456789012345' })];
|
|
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 { xPixel } from '@c15t/scripts/x-pixel';
|
|
48
|
+
|
|
49
|
+
const scripts = [xPixel({ pixelId: '123456789012345' })];
|
|
50
|
+
|
|
51
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
52
|
+
return (
|
|
53
|
+
<ConsentManagerProvider
|
|
54
|
+
options={{
|
|
55
|
+
mode: 'hosted',
|
|
56
|
+
backendURL: '/api/c15t',
|
|
57
|
+
scripts,
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{children}
|
|
61
|
+
</ConsentManagerProvider>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
11
65
|
|
|
12
|
-
|
|
13
|
-
> See the integration overview for how to pass scripts to your framework (JavaScript, React, or Next.js).
|
|
66
|
+
**JavaScript**
|
|
14
67
|
|
|
15
68
|
```ts
|
|
69
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
16
70
|
import { xPixel } from '@c15t/scripts/x-pixel';
|
|
17
71
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
72
|
+
getOrCreateConsentRuntime({
|
|
73
|
+
mode: 'hosted',
|
|
74
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
75
|
+
scripts: [xPixel({ pixelId: '123456789012345' })],
|
|
76
|
+
});
|
|
21
77
|
```
|
|
22
78
|
|
|
23
|
-
##
|
|
79
|
+
## How c15t loads it
|
|
80
|
+
|
|
81
|
+
* **Category:** `marketing` (Ads & Pixels)
|
|
82
|
+
* **Loads when:** marketing consent is granted
|
|
83
|
+
* **On revocation:** unloaded — c15t removes the script element from the DOM
|
|
84
|
+
|
|
85
|
+
## Configure the integration
|
|
24
86
|
|
|
25
87
|
You can use the `xPixelEvent` function to track events. This is a wrapper around the `twq` function that the X Pixel script uses.
|
|
26
88
|
|
|
@@ -30,114 +92,66 @@ import { xPixelEvent } from '@c15t/scripts/x-pixel';
|
|
|
30
92
|
xPixelEvent('tw-xxxx-xxxx', { value: 10.00, currency: 'USD' });
|
|
31
93
|
```
|
|
32
94
|
|
|
95
|
+
## Tracking events in your app
|
|
96
|
+
|
|
97
|
+
c15t gates the X Pixel script from loading until `marketing` consent is granted. Your application code that calls `twq` or the `xPixelEvent` helper is **not** automatically gated — `window.twq` does not exist before consent is granted, and is removed again if consent is revoked. Unguarded calls throw.
|
|
98
|
+
|
|
99
|
+
Guard event calls by checking consent state:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { useCallback } from 'react';
|
|
103
|
+
import { useConsentManager } from '@c15t/react';
|
|
104
|
+
import { xPixelEvent } from '@c15t/scripts/x-pixel';
|
|
105
|
+
|
|
106
|
+
function useTrackPurchase() {
|
|
107
|
+
const { has } = useConsentManager();
|
|
108
|
+
return useCallback(() => {
|
|
109
|
+
if (has('marketing')) {
|
|
110
|
+
xPixelEvent('tw-xxxx-xxxx', { value: 10.0, currency: 'USD' });
|
|
111
|
+
}
|
|
112
|
+
}, [has]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function PurchaseButton() {
|
|
116
|
+
const trackPurchase = useTrackPurchase();
|
|
117
|
+
return <button onClick={trackPurchase}>Complete purchase</button>;
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
33
121
|
## Types
|
|
34
122
|
|
|
35
123
|
### XPixelOptions
|
|
36
124
|
|
|
37
|
-
|Property|
|
|
38
|
-
|
|
39
|
-
|
|
|
40
|
-
|
|
|
125
|
+
|Property|Value|
|
|
126
|
+
|:--|:--|
|
|
127
|
+
|Type Name|\`XPixelOptions\`|
|
|
128
|
+
|Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/x-pixel.ts\`|
|
|
129
|
+
|
|
130
|
+
\*ExtractedTypeTable: Could not extract "XPixelOptions" from "./packages/scripts/src/vendors/ads-and-pixels/x-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
41
131
|
|
|
42
132
|
### Script
|
|
43
133
|
|
|
44
|
-
|Property|
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|src
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|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|
|
|
51
|
-
|persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
|
|
52
|
-
|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|
|
|
53
|
-
|fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
|
|
54
|
-
|attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
|
|
55
|
-
|async|boolean \|undefined|Whether to use async loading|-|Optional|
|
|
56
|
-
|defer|boolean \|undefined|Whether to defer script loading|-|Optional|
|
|
57
|
-
|nonce|string \|undefined|Content Security Policy nonce|-|Optional|
|
|
58
|
-
|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|
|
|
59
|
-
|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|
|
|
60
|
-
|onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
|
|
61
|
-
|onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
|
|
62
|
-
|onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
|
|
63
|
-
|onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
|
|
64
|
-
|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|
|
|
65
|
-
|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|
|
|
66
|
-
|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|
|
|
67
|
-
|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|
|
|
68
|
-
|
|
69
|
-
#### `onBeforeLoad`
|
|
70
|
-
|
|
71
|
-
Callback executed before the script is loaded
|
|
72
|
-
|
|
73
|
-
|Property|Type|Description|Default|Required|
|
|
74
|
-
|:--|:--|:--|:--|:--:|
|
|
75
|
-
|id|string|The original script ID|-|✅ Required|
|
|
76
|
-
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
77
|
-
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
78
|
-
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
79
|
-
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
80
|
-
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
81
|
-
|
|
82
|
-
#### `onLoad`
|
|
83
|
-
|
|
84
|
-
Callback executed when the script loads successfully
|
|
85
|
-
|
|
86
|
-
|Property|Type|Description|Default|Required|
|
|
87
|
-
|:--|:--|:--|:--|:--:|
|
|
88
|
-
|id|string|The original script ID|-|✅ Required|
|
|
89
|
-
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
90
|
-
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
91
|
-
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
92
|
-
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
93
|
-
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
94
|
-
|
|
95
|
-
#### `onError`
|
|
96
|
-
|
|
97
|
-
Callback executed if the script fails to load
|
|
98
|
-
|
|
99
|
-
|Property|Type|Description|Default|Required|
|
|
100
|
-
|:--|:--|:--|:--|:--:|
|
|
101
|
-
|id|string|The original script ID|-|✅ Required|
|
|
102
|
-
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
103
|
-
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
104
|
-
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
105
|
-
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
106
|
-
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
107
|
-
|
|
108
|
-
#### `onConsentChange`
|
|
109
|
-
|
|
110
|
-
Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
|
|
111
|
-
|
|
112
|
-
|Property|Type|Description|Default|Required|
|
|
113
|
-
|:--|:--|:--|:--|:--:|
|
|
114
|
-
|id|string|The original script ID|-|✅ Required|
|
|
115
|
-
|elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
|
|
116
|
-
|hasConsent|boolean|Has consent|-|✅ Required|
|
|
117
|
-
|consents|ConsentState|The current consent state|-|✅ Required|
|
|
118
|
-
|element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
|
|
119
|
-
|error|Error \|undefined|Error information (for error callbacks)|-|Optional|
|
|
134
|
+
|Property|Value|
|
|
135
|
+
|:--|:--|
|
|
136
|
+
|Type Name|\`Script\`|
|
|
137
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
138
|
+
|
|
139
|
+
\*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.\*
|
|
120
140
|
|
|
121
141
|
### XPixelEvent
|
|
122
142
|
|
|
123
|
-
|Property|
|
|
124
|
-
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|description|string \|undefined|Description of the conversion event|-|Optional|
|
|
130
|
-
|twclid|string \|undefined|twclid of the conversion event The X Pixel already automatically passes twclid from URL or first-party cookie. This parameter can be optionally used to force attribution to a certain ad click.|-|Optional|
|
|
131
|
-
|status|boolean \|undefined|Status of the conversion event|-|Optional|
|
|
132
|
-
|contents|XPixelContent \|undefined|Content/products associated with the conversion event|-|Optional|
|
|
143
|
+
|Property|Value|
|
|
144
|
+
|:--|:--|
|
|
145
|
+
|Type Name|\`XPixelEvent\`|
|
|
146
|
+
|Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/x-pixel.ts\`|
|
|
147
|
+
|
|
148
|
+
\*ExtractedTypeTable: Could not extract "XPixelEvent" from "./packages/scripts/src/vendors/ads-and-pixels/x-pixel.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
133
149
|
|
|
134
150
|
### XPixelContent
|
|
135
151
|
|
|
136
|
-
|Property|
|
|
137
|
-
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|num\_items|number \|undefined|Quantity of the content|-|Optional|
|
|
143
|
-
|content\_group\_id|string \|undefined|ID associated with a group of product variants|-|Optional|
|
|
152
|
+
|Property|Value|
|
|
153
|
+
|:--|:--|
|
|
154
|
+
|Type Name|\`XPixelContent\`|
|
|
155
|
+
|Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/x-pixel.ts\`|
|
|
156
|
+
|
|
157
|
+
\*ExtractedTypeTable: Could not extract "XPixelContent" from "./packages/scripts/src/vendors/ads-and-pixels/x-pixel.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,193 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: YouTube
|
|
3
|
+
description: Keep YouTube iframes unmounted until consent with a
|
|
4
|
+
privacy-enhanced, lazy-loaded React or Next.js embed.
|
|
5
|
+
icon: youtube
|
|
6
|
+
group: integrations
|
|
7
|
+
---
|
|
8
|
+
`YouTubeEmbed` is a renderable integration for React and Next.js. It uses c15t's
|
|
9
|
+
`Frame` consent boundary, so the YouTube iframe is not mounted and no YouTube
|
|
10
|
+
request is made until the configured consent category is allowed.
|
|
11
|
+
|
|
12
|
+
The component does not load the YouTube IFrame Player API. It is intended for
|
|
13
|
+
standard iframe embeds and keeps script readiness separate from iframe gating.
|
|
14
|
+
|
|
15
|
+
## Integrate with c15t
|
|
16
|
+
|
|
17
|
+
`YouTubeEmbed` must render inside a `ConsentManagerProvider`. Complete the
|
|
18
|
+
[React quickstart](/docs/frameworks/react/quickstart) or
|
|
19
|
+
[Next.js quickstart](/docs/frameworks/next/quickstart) first.
|
|
20
|
+
|
|
21
|
+
**React**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { YouTubeEmbed } from '@c15t/react';
|
|
25
|
+
|
|
26
|
+
export function ProductVideo() {
|
|
27
|
+
return (
|
|
28
|
+
<YouTubeEmbed
|
|
29
|
+
consentCategory="marketing"
|
|
30
|
+
params={{ controls: true, playsinline: true }}
|
|
31
|
+
title="Product overview"
|
|
32
|
+
videoId="dQw4w9WgXcQ"
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Next.js**
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
'use client';
|
|
42
|
+
|
|
43
|
+
import { YouTubeEmbed } from '@c15t/nextjs';
|
|
44
|
+
|
|
45
|
+
export function ProductVideo() {
|
|
46
|
+
return (
|
|
47
|
+
<YouTubeEmbed
|
|
48
|
+
consentCategory="marketing"
|
|
49
|
+
params={{ controls: true, playsinline: true }}
|
|
50
|
+
title="Product overview"
|
|
51
|
+
videoId="dQw4w9WgXcQ"
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`marketing` is the default category. Choose a different category only when it
|
|
58
|
+
matches the purpose of the embed and the policy presented to your users.
|
|
59
|
+
|
|
60
|
+
## How c15t loads it
|
|
61
|
+
|
|
62
|
+
* **Before consent:** c15t renders a placeholder and does not mount the iframe.
|
|
63
|
+
* **After consent:** the iframe mounts with its final embed URL.
|
|
64
|
+
* **On revocation:** the `Frame` boundary unmounts the iframe, stopping the
|
|
65
|
+
embedded player and future requests from that document.
|
|
66
|
+
* **Loading behavior:** c15t reserves the final player size, shows a localized
|
|
67
|
+
loading state, and uses native iframe lazy loading by default.
|
|
68
|
+
* **Default layout:** the placeholder and player share a responsive 16:9,
|
|
69
|
+
borderless frame with a `200px` minimum height.
|
|
70
|
+
* **Privacy-enhanced mode:** URLs built from `videoId` use
|
|
71
|
+
`youtube-nocookie.com` by default.
|
|
72
|
+
|
|
73
|
+
Privacy-enhanced mode changes the YouTube host but does not replace consent
|
|
74
|
+
gating. Keep the iframe behind the category required by your privacy policy.
|
|
75
|
+
|
|
76
|
+
## Build the embed URL
|
|
77
|
+
|
|
78
|
+
Prefer `videoId` when you control the video:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<YouTubeEmbed
|
|
82
|
+
consentCategory="marketing"
|
|
83
|
+
params={{
|
|
84
|
+
autoplay: false,
|
|
85
|
+
controls: true,
|
|
86
|
+
playsinline: true,
|
|
87
|
+
rel: false,
|
|
88
|
+
}}
|
|
89
|
+
start={36}
|
|
90
|
+
title="Quarterly product update"
|
|
91
|
+
videoId="dQw4w9WgXcQ"
|
|
92
|
+
/>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Boolean `params` are serialized as YouTube's `1` and `0` values. `start` is
|
|
96
|
+
serialized as the player's start time in seconds. If `params.start` is also
|
|
97
|
+
present, the top-level `start` prop takes precedence.
|
|
98
|
+
|
|
99
|
+
Set `privacyEnhanced={false}` only when you intentionally need the regular
|
|
100
|
+
`youtube.com` host.
|
|
101
|
+
|
|
102
|
+
### Migrate an existing iframe URL
|
|
103
|
+
|
|
104
|
+
Use `src` when you already have a complete embed URL:
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<YouTubeEmbed
|
|
108
|
+
consentCategory="marketing"
|
|
109
|
+
src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?start=36"
|
|
110
|
+
title="Quarterly product update"
|
|
111
|
+
/>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
When `src` is provided, c15t uses it unchanged. TypeScript treats `src` and
|
|
115
|
+
`videoId` as mutually exclusive source modes: `start`, `params`, and
|
|
116
|
+
`privacyEnhanced` are available only with `videoId`.
|
|
117
|
+
|
|
118
|
+
## Style the wrapper and iframe
|
|
119
|
+
|
|
120
|
+
`wrapperClassName` targets the consent-gated `Frame`. `className` and the
|
|
121
|
+
forwarded ref target the iframe itself.
|
|
122
|
+
|
|
123
|
+
The defaults are responsive and stable without utility classes. Override them
|
|
124
|
+
only when your layout needs a different aspect ratio or height:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
<YouTubeEmbed
|
|
128
|
+
consentCategory="marketing"
|
|
129
|
+
frameProps={{ style: { aspectRatio: '4 / 3', minHeight: 280 } }}
|
|
130
|
+
style={{ borderRadius: 4 }}
|
|
131
|
+
title="Product overview"
|
|
132
|
+
videoId="dQw4w9WgXcQ"
|
|
133
|
+
/>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`frameProps.style` is merged after the wrapper defaults. The iframe fills that
|
|
137
|
+
wrapper, has no border, and inherits the wrapper radius by default.
|
|
138
|
+
|
|
139
|
+
## Customize the placeholder
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { Frame, YouTubeEmbed } from '@c15t/react';
|
|
143
|
+
|
|
144
|
+
<YouTubeEmbed
|
|
145
|
+
consentCategory="marketing"
|
|
146
|
+
placeholder={
|
|
147
|
+
<Frame.Root>
|
|
148
|
+
<Frame.Title>Allow marketing consent to watch this video.</Frame.Title>
|
|
149
|
+
<Frame.Button category="marketing" />
|
|
150
|
+
</Frame.Root>
|
|
151
|
+
}
|
|
152
|
+
title="Product overview"
|
|
153
|
+
videoId="dQw4w9WgXcQ"
|
|
154
|
+
/>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Custom placeholders should explain why the content is blocked and provide a
|
|
158
|
+
clear way to change consent. Always give the iframe a meaningful `title`.
|
|
159
|
+
|
|
160
|
+
Use `loadingFallback` to replace the post-consent loading message and
|
|
161
|
+
`errorFallback` to replace the configuration error state. If neither `videoId`
|
|
162
|
+
nor `src` is supplied at runtime, the component renders that error state instead
|
|
163
|
+
of mounting an iframe.
|
|
164
|
+
|
|
165
|
+
Standard cross-origin iframes do not provide a reliable player-error signal.
|
|
166
|
+
`YouTubeEmbed` forwards the iframe's native `onError` when a browser emits it,
|
|
167
|
+
but player-level errors require the YouTube IFrame Player API and are outside
|
|
168
|
+
this iframe-only component.
|
|
169
|
+
|
|
170
|
+
## Verify setup
|
|
171
|
+
|
|
172
|
+
1. Clear saved consent and reload the page.
|
|
173
|
+
2. Confirm there is no YouTube iframe or YouTube network request before consent.
|
|
174
|
+
3. Grant the configured category and confirm exactly one iframe mounts.
|
|
175
|
+
4. Confirm a `videoId` embed uses `youtube-nocookie.com` unless
|
|
176
|
+
`privacyEnhanced={false}`.
|
|
177
|
+
5. Revoke consent and confirm the iframe is removed.
|
|
178
|
+
6. Confirm the default 16:9 frame is borderless and reserves the same space at
|
|
179
|
+
mobile and desktop widths.
|
|
180
|
+
|
|
181
|
+
See YouTube's [embedded player parameters](https://developers.google.com/youtube/player_parameters)
|
|
182
|
+
for the supported query parameters.
|
|
183
|
+
|
|
184
|
+
## Types
|
|
185
|
+
|
|
186
|
+
### YouTubeEmbedProps
|
|
187
|
+
|
|
188
|
+
|Property|Value|
|
|
189
|
+
|:--|:--|
|
|
190
|
+
|Type Name|\`YouTubeEmbedProps\`|
|
|
191
|
+
|Source Path|\`./packages/react/src/components/integrations/youtube-embed.tsx\`|
|
|
192
|
+
|
|
193
|
+
\*ExtractedTypeTable: Could not extract "YouTubeEmbedProps" from "./packages/react/src/components/integrations/youtube-embed.tsx" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|