@c15t/scripts 3.0.0-alpha.0 → 3.0.0-alpha.2
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 +7 -0
- package/README.md +4 -3
- package/dist/e2e-test-utils.js +5 -3
- package/dist/engine/runtime.js +14 -3
- package/dist/events.js +218 -0
- package/dist/registry.js +40 -0
- package/dist/vendors/ads-and-pixels/pinterest-tag.js +123 -0
- package/dist/vendors/analytics/google-tag.js +14 -2
- package/dist/vendors/analytics/microsoft-clarity.js +4 -1
- package/dist/vendors/analytics/one-dollar-stats.js +30 -0
- package/dist/vendors/analytics/segment.js +10 -1
- package/dist/vendors/functional/front-chat.js +64 -0
- package/dist/vendors/tag-managers/cloudflare-zaraz.js +98 -0
- package/dist/vendors/tag-managers/google-tag-manager.js +17 -3
- package/dist-types/__tests__/helpers.d.ts +2 -2
- package/dist-types/engine/compile.d.ts +1 -1
- package/dist-types/engine/runtime.d.ts +1 -1
- package/dist-types/events.d.ts +46 -0
- package/dist-types/registry.d.ts +36 -0
- package/dist-types/resolve.d.ts +1 -1
- package/dist-types/vendors/_shared/install-builders.d.ts +1 -1
- package/dist-types/vendors/ads-and-pixels/pinterest-tag.d.ts +295 -0
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +1 -1
- package/dist-types/vendors/analytics/google-tag.d.ts +3 -1
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +1 -1
- package/dist-types/vendors/analytics/one-dollar-stats.d.ts +39 -0
- package/dist-types/vendors/analytics/segment.d.ts +7 -1
- package/dist-types/vendors/functional/front-chat.d.ts +62 -0
- package/dist-types/vendors/tag-managers/cloudflare-zaraz.d.ts +39 -0
- package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +3 -1
- package/docs/README.md +7 -0
- package/docs/customization/overview.md +4 -3
- package/docs/customization/recipes.md +4 -2
- package/docs/customization/tokens.md +66 -3
- package/docs/frameworks/javascript/script-loader.md +53 -0
- package/docs/frameworks/next/script-loader.md +60 -12
- package/docs/frameworks/react/script-loader.md +14 -0
- package/docs/guides/consent-state.md +327 -0
- package/docs/guides/deployment-modes.md +12 -0
- package/docs/guides/shared-consent-controls.md +158 -0
- package/docs/integrations/adobe-analytics.md +1 -1
- package/docs/integrations/ahrefs-analytics.md +1 -1
- package/docs/integrations/amplitude.md +1 -1
- package/docs/integrations/building-integrations.md +5 -0
- package/docs/integrations/clear-on-revocation.md +167 -0
- package/docs/integrations/clearbit.md +1 -1
- package/docs/integrations/cloudflare-web-analytics.md +1 -1
- package/docs/integrations/cloudflare-zaraz.md +399 -0
- package/docs/integrations/crisp.md +1 -1
- package/docs/integrations/databuddy.md +1 -1
- package/docs/integrations/fathom-analytics.md +1 -1
- package/docs/integrations/front-chat.md +322 -0
- package/docs/integrations/google-maps.md +21 -21
- package/docs/integrations/google-tag-manager.md +1 -1
- package/docs/integrations/google-tag.md +1 -1
- package/docs/integrations/granular-consent.md +210 -0
- package/docs/integrations/heap.md +1 -1
- package/docs/integrations/hightouch.md +1 -1
- package/docs/integrations/hotjar.md +1 -1
- package/docs/integrations/intercom.md +1 -1
- package/docs/integrations/linkedin-insights.md +1 -1
- package/docs/integrations/logrocket.md +1 -1
- package/docs/integrations/matomo-analytics.md +1 -1
- package/docs/integrations/meta-pixel.md +1 -1
- package/docs/integrations/microsoft-clarity.md +1 -1
- package/docs/integrations/microsoft-uet.md +1 -1
- package/docs/integrations/mixpanel-analytics.md +1 -1
- package/docs/integrations/one-dollar-stats.md +305 -0
- package/docs/integrations/openai-pixel.md +1 -1
- package/docs/integrations/overview.md +22 -18
- package/docs/integrations/pinterest-tag.md +321 -0
- package/docs/integrations/pirsch.md +1 -1
- package/docs/integrations/plausible-analytics.md +1 -1
- package/docs/integrations/posthog.md +1 -1
- package/docs/integrations/promptwatch.md +1 -1
- package/docs/integrations/reddit-pixel.md +1 -1
- package/docs/integrations/rudderstack.md +1 -1
- package/docs/integrations/rybbit-analytics.md +1 -1
- package/docs/integrations/segment.md +1 -1
- package/docs/integrations/snapchat-pixel.md +1 -1
- package/docs/integrations/tiktok-pixel.md +1 -1
- package/docs/integrations/umami-analytics.md +1 -1
- package/docs/integrations/vercel-analytics.md +1 -1
- package/docs/integrations/x-pixel.md +1 -1
- package/docs/integrations/youtube.md +27 -22
- package/docs/upgrade-v3.md +176 -1
- package/package.json +30 -2
- package/readme.json +0 -19
|
@@ -34,15 +34,16 @@ behavior before choosing either approach.
|
|
|
34
34
|
| [Google Maps](./google-maps.md) | Framework-specific consent-gated map iframe | Iframe mounts only while the chosen permission is allowed |
|
|
35
35
|
| [YouTube](./youtube.md) | Framework-specific consent-gated video iframe | Iframe mounts only while the chosen permission is allowed |
|
|
36
36
|
|
|
37
|
-
Both guides include all nine framework examples. React and Svelte use `
|
|
37
|
+
Both guides include all nine framework examples. React and Svelte use `ConsentGate`;
|
|
38
38
|
Vue conditionally renders the iframe, and Astro and JavaScript use the existing
|
|
39
39
|
kernel to control its DOM lifecycle. Embeds do not require `@c15t/scripts`.
|
|
40
40
|
|
|
41
41
|
## Tag managers
|
|
42
42
|
|
|
43
|
-
| Integration | Helper | Category | Loading behavior
|
|
44
|
-
| --------------------------------------------- | ------------------ | ----------- |
|
|
45
|
-
| [
|
|
43
|
+
| Integration | Helper | Category | Loading behavior |
|
|
44
|
+
| --------------------------------------------- | ------------------ | ----------- | ------------------------------------------------ |
|
|
45
|
+
| [Cloudflare Zaraz](./cloudflare-zaraz.md) | `cloudflareZaraz` | `necessary` | Synchronizes purposes; Zaraz owns tool execution |
|
|
46
|
+
| [Google Tag Manager](./google-tag-manager.md) | `googleTagManager` | `necessary` | Always loads; signals Google consent |
|
|
46
47
|
|
|
47
48
|
## Analytics
|
|
48
49
|
|
|
@@ -60,6 +61,7 @@ kernel to control its DOM lifecycle. Embeds do not require `@c15t/scripts`.
|
|
|
60
61
|
| [Heap](./heap.md) | `heap` | `measurement` | Waits for effective permission |
|
|
61
62
|
| [Matomo Analytics](./matomo-analytics.md) | `matomoAnalytics` | `measurement` | Gated by default; optional consent mode |
|
|
62
63
|
| [Mixpanel](./mixpanel-analytics.md) | `mixpanelAnalytics` | `measurement` | Always loads; calls opt-in and opt-out APIs |
|
|
64
|
+
| [OneDollarStats](./one-dollar-stats.md) | `oneDollarStats` | `measurement` | Waits for effective permission |
|
|
63
65
|
| [Hotjar](./hotjar.md) | `hotjar` | `measurement` | Waits for effective permission |
|
|
64
66
|
| [Hightouch](./hightouch.md) | `hightouch` | `measurement` | Waits for effective permission |
|
|
65
67
|
| [LogRocket](./logrocket.md) | `logRocket` | `measurement` | Waits for effective permission |
|
|
@@ -75,23 +77,25 @@ kernel to control its DOM lifecycle. Embeds do not require `@c15t/scripts`.
|
|
|
75
77
|
|
|
76
78
|
## Functionality
|
|
77
79
|
|
|
78
|
-
| Integration
|
|
79
|
-
|
|
|
80
|
-
| [Crisp](./crisp.md)
|
|
81
|
-
| [
|
|
80
|
+
| Integration | Helper | Category | Loading behavior |
|
|
81
|
+
| ----------------------------- | ----------- | --------------- | ------------------------------ |
|
|
82
|
+
| [Crisp](./crisp.md) | `crisp` | `functionality` | Waits for effective permission |
|
|
83
|
+
| [Front Chat](./front-chat.md) | `frontChat` | `functionality` | Waits for effective permission |
|
|
84
|
+
| [Intercom](./intercom.md) | `intercom` | `functionality` | Waits for effective permission |
|
|
82
85
|
|
|
83
86
|
## Ads and pixels
|
|
84
87
|
|
|
85
|
-
| Integration | Helper | Category | Loading behavior
|
|
86
|
-
| ---------------------------------------------- | ------------------ | ----------- |
|
|
87
|
-
| [Meta Pixel](./meta-pixel.md) | `metaPixel` | `marketing` | Waits for effective permission
|
|
88
|
-
| [OpenAI Pixel](./openai-pixel.md) | `openaiPixel` | `marketing` | Gated initially; retains SDK and signals consent
|
|
89
|
-
| [
|
|
90
|
-
| [
|
|
91
|
-
| [
|
|
92
|
-
| [
|
|
93
|
-
| [
|
|
94
|
-
| [
|
|
88
|
+
| Integration | Helper | Category | Loading behavior |
|
|
89
|
+
| ---------------------------------------------- | ------------------ | ----------- | ---------------------------------------------------- |
|
|
90
|
+
| [Meta Pixel](./meta-pixel.md) | `metaPixel` | `marketing` | Waits for effective permission |
|
|
91
|
+
| [OpenAI Pixel](./openai-pixel.md) | `openaiPixel` | `marketing` | Gated initially; retains SDK and signals consent |
|
|
92
|
+
| [Pinterest Tag](./pinterest-tag.md) | `pinterestTag` | `marketing` | Gated initially; retains the tag and signals consent |
|
|
93
|
+
| [Reddit Pixel](./reddit-pixel.md) | `redditPixel` | `marketing` | Gated initially; retains SDK and switches cookies |
|
|
94
|
+
| [TikTok Pixel](./tiktok-pixel.md) | `tiktokPixel` | `marketing` | Gated initially; retains SDK and signals consent |
|
|
95
|
+
| [LinkedIn Insight Tag](./linkedin-insights.md) | `linkedinInsights` | `marketing` | Waits for effective permission |
|
|
96
|
+
| [Microsoft UET](./microsoft-uet.md) | `microsoftUet` | `marketing` | Always loads; signals ad storage consent |
|
|
97
|
+
| [Snapchat Pixel](./snapchat-pixel.md) | `snapchatPixel` | `marketing` | Waits for effective permission |
|
|
98
|
+
| [X Pixel](./x-pixel.md) | `xPixel` | `marketing` | Waits for effective permission |
|
|
95
99
|
|
|
96
100
|
## Keep one owner per vendor
|
|
97
101
|
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Pinterest Tag
|
|
3
|
+
description: Configure the Pinterest Tag with c15t v3, track typed events and
|
|
4
|
+
verify marketing permission, revocation and reload.
|
|
5
|
+
group: integrations
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Configure Pinterest Tag
|
|
9
|
+
|
|
10
|
+
Use the numeric tag ID from Pinterest Ads Manager. The helper recreates
|
|
11
|
+
Pinterest's base code: it defines the `pintrk` queue, queues `load`,
|
|
12
|
+
`setconsent(true)` and a page visit, then loads `core.js`.
|
|
13
|
+
|
|
14
|
+
| Package manager | Command |
|
|
15
|
+
| :-------------- | :-------------------------- |
|
|
16
|
+
| npm | `npm install @c15t/scripts` |
|
|
17
|
+
| pnpm | `pnpm add @c15t/scripts` |
|
|
18
|
+
| yarn | `yarn add @c15t/scripts` |
|
|
19
|
+
| bun | `bun add @c15t/scripts` |
|
|
20
|
+
|
|
21
|
+
```ts title="src/consent-scripts.ts"
|
|
22
|
+
import { pinterestTag } from '@c15t/scripts/pinterest-tag';
|
|
23
|
+
|
|
24
|
+
export const scripts = [pinterestTag({ tagId: 'YOUR_TAG_ID' })];
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Register the scripts
|
|
28
|
+
|
|
29
|
+
Complete your [framework quickstart](https://c15t.com/docs/frameworks) first. Keep its Inth
|
|
30
|
+
endpoint, policy, styles and consent UI. Remove the vendor's original script,
|
|
31
|
+
SDK initializer or tag-manager entry so c15t owns loading once.
|
|
32
|
+
|
|
33
|
+
The `scripts` export in `src/consent-scripts.ts` is a configuration, not an
|
|
34
|
+
initializer. Add it to your existing consent owner using the registration point
|
|
35
|
+
below. These are partial edits to that owner, not additional providers.
|
|
36
|
+
|
|
37
|
+
**Next.js**
|
|
38
|
+
|
|
39
|
+
Import the configuration into the client boundary from your router guide:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { ConsentRoot } from 'c15t/next';
|
|
43
|
+
import { scripts } from './consent-scripts';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Keep the server-resolved `state` and shared `consentConfig` from your
|
|
47
|
+
router guide. Its manifest, init and save URLs stay in effect. Add
|
|
48
|
+
`scripts` as a top-level prop on the existing root:
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
<ConsentRoot state={state} config={consentConfig} scripts={scripts}>
|
|
52
|
+
{children}
|
|
53
|
+
</ConsentRoot>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
For a Pages Router or static-export setup using `ConsentProvider`, add
|
|
57
|
+
`scripts` to its existing `options` instead. Keep the router-specific setup
|
|
58
|
+
from [Next.js script loading](../frameworks/next/script-loader.md).
|
|
59
|
+
|
|
60
|
+
**TanStack Start**
|
|
61
|
+
|
|
62
|
+
In your existing root route component, import the scripts alongside
|
|
63
|
+
`ConsentRoot`. Keep the server loader from the [TanStack Start quickstart](https://c15t.com/docs/frameworks/tanstack-start/quickstart).
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { Outlet } from '@tanstack/react-router';
|
|
67
|
+
import { ConsentRoot } from 'c15t/tanstack-start';
|
|
68
|
+
import { scripts } from '../consent-scripts';
|
|
69
|
+
|
|
70
|
+
function Root() {
|
|
71
|
+
const state = Route.useLoaderData();
|
|
72
|
+
return (
|
|
73
|
+
<ConsentRoot state={state} backendURL={backendURL} initRoute={false} scripts={scripts}>
|
|
74
|
+
<Outlet />
|
|
75
|
+
{/* Keep your consent banner, dialog and preferences link here. */}
|
|
76
|
+
</ConsentRoot>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This edits the existing route. `Route` and `backendURL` come from its setup;
|
|
82
|
+
keep the document shell and head components if they are part of your root.
|
|
83
|
+
`initRoute={false}` keeps the quickstart's direct-backend initialization.
|
|
84
|
+
If your app mounts a consent server route, retain its existing `initRoute`
|
|
85
|
+
instead. Do not return script callbacks from a server function or route loader.
|
|
86
|
+
|
|
87
|
+
**React**
|
|
88
|
+
|
|
89
|
+
Import the scripts into your existing provider component:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import { ConsentProvider } from 'c15t/react';
|
|
93
|
+
import { scripts } from './consent-scripts';
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Keep the existing options and add `scripts`:
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
<ConsentProvider options={{ ...consentOptions, scripts }}>
|
|
100
|
+
{children}
|
|
101
|
+
</ConsentProvider>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Here `consentOptions` is your existing configuration, including
|
|
105
|
+
`mode: hosted({ url: backendURL })`. Keep the banner, dialog and preferences
|
|
106
|
+
link inside the provider. See [React script loading](../frameworks/react/script-loader.md).
|
|
107
|
+
|
|
108
|
+
**Nuxt**
|
|
109
|
+
|
|
110
|
+
Attach one loader from the root `app.vue`, after the Nuxt module has
|
|
111
|
+
started its browser runtime. This keeps vendor callbacks in application code rather
|
|
112
|
+
than serialized `nuxt.config.ts` runtime configuration.
|
|
113
|
+
|
|
114
|
+
```vue title="app/app.vue"
|
|
115
|
+
<script setup lang="ts">
|
|
116
|
+
import { onUnmounted } from 'vue';
|
|
117
|
+
import { createScriptLoader } from 'c15t/modules/script-loader';
|
|
118
|
+
import { scripts } from '../src/consent-scripts';
|
|
119
|
+
|
|
120
|
+
const nuxtApp = useNuxtApp();
|
|
121
|
+
const kernel = useConsentKernel();
|
|
122
|
+
let loader: ReturnType<typeof createScriptLoader> | undefined;
|
|
123
|
+
|
|
124
|
+
const removeMountedHook = nuxtApp.hook('app:mounted', () => {
|
|
125
|
+
loader = createScriptLoader({ kernel, scripts });
|
|
126
|
+
});
|
|
127
|
+
onUnmounted(() => {
|
|
128
|
+
removeMountedHook();
|
|
129
|
+
loader?.dispose();
|
|
130
|
+
});
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<template>
|
|
134
|
+
<ConsentRoot />
|
|
135
|
+
<NuxtPage />
|
|
136
|
+
</template>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Merge the setup code into your root and retain its footer and preferences
|
|
140
|
+
link. `useConsentKernel` is auto-imported by the c15t Nuxt module. Adjust the
|
|
141
|
+
relative script import if your `app.vue` is at the project root. This loader
|
|
142
|
+
waits until the module has applied browser persistence and privacy signals,
|
|
143
|
+
then reads the current snapshot and observes future changes. Do not also register these scripts
|
|
144
|
+
in another loader. See the [Nuxt quickstart](https://c15t.com/docs/frameworks/nuxt/quickstart).
|
|
145
|
+
|
|
146
|
+
**Vue**
|
|
147
|
+
|
|
148
|
+
Use the kernel already provided by the Vue plugin. Merge this setup into
|
|
149
|
+
`App.vue`, whose lifetime covers the application:
|
|
150
|
+
|
|
151
|
+
```vue title="src/App.vue"
|
|
152
|
+
<script setup lang="ts">
|
|
153
|
+
import { onMounted, onUnmounted } from 'vue';
|
|
154
|
+
import { createScriptLoader } from 'c15t/modules/script-loader';
|
|
155
|
+
import { useConsentKernel } from 'c15t/vue/vue-plugin';
|
|
156
|
+
import ConsentRoot from 'c15t/vue/consent-root';
|
|
157
|
+
import { scripts } from './consent-scripts';
|
|
158
|
+
|
|
159
|
+
const kernel = useConsentKernel();
|
|
160
|
+
let loader: ReturnType<typeof createScriptLoader> | undefined;
|
|
161
|
+
|
|
162
|
+
onMounted(() => {
|
|
163
|
+
loader = createScriptLoader({ kernel, scripts });
|
|
164
|
+
});
|
|
165
|
+
onUnmounted(() => loader?.dispose());
|
|
166
|
+
</script>
|
|
167
|
+
|
|
168
|
+
<template>
|
|
169
|
+
<ConsentRoot />
|
|
170
|
+
<main>Your application</main>
|
|
171
|
+
</template>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Keep your existing page content and preferences link. The plugin still owns
|
|
175
|
+
the kernel and persistence; this component owns only the vendor loader.
|
|
176
|
+
Do not register the same scripts in plugin configuration as well. See the
|
|
177
|
+
[Vue quickstart](https://c15t.com/docs/frameworks/vue/quickstart).
|
|
178
|
+
|
|
179
|
+
**Astro**
|
|
180
|
+
|
|
181
|
+
Point the existing Astro integration at a client module. Keep its `mode`,
|
|
182
|
+
`ui` and framework integration from the [Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart).
|
|
183
|
+
Import `fileURLToPath` in your Astro configuration:
|
|
184
|
+
|
|
185
|
+
```js title="astro.config.mjs"
|
|
186
|
+
import { fileURLToPath } from 'node:url';
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Add this option to the existing `c15t({ ... })` call. Resolve the path from
|
|
190
|
+
the configuration file because Astro injects the import into a virtual module:
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)),
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Export the scripts from that module:
|
|
197
|
+
|
|
198
|
+
```ts title="src/c15t.client.ts"
|
|
199
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
200
|
+
import { scripts } from './consent-scripts';
|
|
201
|
+
|
|
202
|
+
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
The integration passes this extension to its shared browser runtime. Vendor
|
|
206
|
+
helpers contain callbacks, so do not put them in the serialized `scripts`
|
|
207
|
+
option in `astro.config.mjs`. Keep one runtime across consent islands and
|
|
208
|
+
`ClientRouter` navigation.
|
|
209
|
+
|
|
210
|
+
**Svelte**
|
|
211
|
+
|
|
212
|
+
Import the scripts in the component that owns your existing provider and
|
|
213
|
+
pass them as a top-level prop:
|
|
214
|
+
|
|
215
|
+
```svelte title="src/App.svelte"
|
|
216
|
+
<script lang="ts">
|
|
217
|
+
import { ConsentManagerProvider, hosted } from '@c15t/svelte';
|
|
218
|
+
import { scripts } from './consent-scripts';
|
|
219
|
+
|
|
220
|
+
const backendURL = import.meta.env.VITE_C15T_BACKEND_URL;
|
|
221
|
+
if (!backendURL) throw new Error('Set VITE_C15T_BACKEND_URL');
|
|
222
|
+
const mode = hosted({ url: backendURL });
|
|
223
|
+
</script>
|
|
224
|
+
|
|
225
|
+
<ConsentManagerProvider {mode} {scripts}>
|
|
226
|
+
<!-- Keep your application, consent UI and preferences link here. -->
|
|
227
|
+
</ConsentManagerProvider>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Retain the styles and consent UI from the [Svelte quickstart](https://c15t.com/docs/frameworks/svelte/quickstart).
|
|
231
|
+
The provider owns the loader and disposes it on unmount.
|
|
232
|
+
|
|
233
|
+
**SvelteKit**
|
|
234
|
+
|
|
235
|
+
Add the scripts to the existing root layout provider. Keep the server load
|
|
236
|
+
and its serializable prefetch data from the [SvelteKit quickstart](https://c15t.com/docs/frameworks/sveltekit/quickstart).
|
|
237
|
+
|
|
238
|
+
```svelte title="src/routes/+layout.svelte"
|
|
239
|
+
<script lang="ts">
|
|
240
|
+
import { ConsentManagerProvider, hosted } from '@c15t/svelte';
|
|
241
|
+
import { scripts } from '../consent-scripts';
|
|
242
|
+
|
|
243
|
+
let { children, data } = $props();
|
|
244
|
+
const mode = hosted({ url: data.backendURL });
|
|
245
|
+
</script>
|
|
246
|
+
|
|
247
|
+
<ConsentManagerProvider {mode} {scripts} prefetch={data.prefetch}>
|
|
248
|
+
{@render children()}
|
|
249
|
+
<!-- Keep your consent UI and preferences link here. -->
|
|
250
|
+
</ConsentManagerProvider>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Import vendor helpers in the layout component, not in `+layout.server.ts`.
|
|
254
|
+
For static hosting, keep your browser-only `mode` setup and omit request
|
|
255
|
+
prefetch; the `scripts` prop stays the same. If you pass an externally owned
|
|
256
|
+
`runtime` to the provider, register scripts when creating that runtime instead.
|
|
257
|
+
|
|
258
|
+
**JavaScript**
|
|
259
|
+
|
|
260
|
+
Attach the loader to your existing kernel before calling
|
|
261
|
+
`kernel.commands.init()`:
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
import { createScriptLoader } from 'c15t/modules/script-loader';
|
|
265
|
+
import { scripts } from './consent-scripts';
|
|
266
|
+
|
|
267
|
+
const loader = createScriptLoader({ kernel, scripts });
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Call `loader.dispose()` when that application instance is destroyed.
|
|
271
|
+
`kernel` is the hosted kernel from your quickstart. A provider-owned kernel
|
|
272
|
+
already has a loader; do not attach a second one. See
|
|
273
|
+
[JavaScript script loading](../frameworks/javascript/script-loader.md).
|
|
274
|
+
|
|
275
|
+
Pinterest's `<noscript>` image fallback is not emitted. It fires without
|
|
276
|
+
JavaScript, so c15t cannot gate it.
|
|
277
|
+
|
|
278
|
+
## Options
|
|
279
|
+
|
|
280
|
+
| Option | Behavior |
|
|
281
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
282
|
+
| `tagId` | Required Pinterest Tag ID. |
|
|
283
|
+
| `loadOptions` | Third argument to `pintrk('load')`, such as `em` for enhanced match. Pass user data only with the permission it needs. |
|
|
284
|
+
| `trackPageVisit` | Queues `pintrk('page')` during setup. Defaults to `true`. |
|
|
285
|
+
| `scriptUrl` | Defaults to `https://s.pinimg.com/ct/core.js`. |
|
|
286
|
+
|
|
287
|
+
## Track events
|
|
288
|
+
|
|
289
|
+
`pinterestTagEvent()` sends a typed `pintrk('track')` call. It covers Pinterest's
|
|
290
|
+
20 event types and accepts user-defined names, which Pinterest uses for audience
|
|
291
|
+
targeting only. Put product details in `line_items`.
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
import { pinterestTagEvent } from '@c15t/scripts/pinterest-tag';
|
|
295
|
+
|
|
296
|
+
pinterestTagEvent('checkout', {
|
|
297
|
+
currency: 'USD',
|
|
298
|
+
event_id: 'order-123',
|
|
299
|
+
line_items: [{ product_id: '1414', product_price: 99.99, product_quantity: 1 }],
|
|
300
|
+
order_id: 'order-123',
|
|
301
|
+
value: 99.99,
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Set `event_id` to deduplicate against the Conversions API. An optional third
|
|
306
|
+
argument receives Pinterest's `(didInit, error)` result. The helper does nothing
|
|
307
|
+
until the tag has loaded, and it checks API availability, not consent.
|
|
308
|
+
|
|
309
|
+
## Consent behavior
|
|
310
|
+
|
|
311
|
+
The first load waits for marketing permission. On revocation the helper keeps
|
|
312
|
+
the tag and calls `pintrk('setconsent', false)`, which Pinterest documents as
|
|
313
|
+
stopping events and clearing its first-party cookies. c15t then reloads the page.
|
|
314
|
+
A later grant calls `setconsent(true)`.
|
|
315
|
+
|
|
316
|
+
## Verify the integration
|
|
317
|
+
|
|
318
|
+
Use a fresh session with an opt-in policy and confirm `core.js` is absent. Grant
|
|
319
|
+
`marketing` and check the page visit in Pinterest's Tag Helper. Revoke it and
|
|
320
|
+
confirm the page reloads and no further events are sent. Follow the
|
|
321
|
+
[consent verification guide](../guides/verify-consent.md).
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -206,7 +206,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
206
206
|
Export the scripts from that module:
|
|
207
207
|
|
|
208
208
|
```ts title="src/c15t.client.ts"
|
|
209
|
-
import type { C15tClientOptionsExtension } from '
|
|
209
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
210
210
|
import { scripts } from './consent-scripts';
|
|
211
211
|
|
|
212
212
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -203,7 +203,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
203
203
|
Export the scripts from that module:
|
|
204
204
|
|
|
205
205
|
```ts title="src/c15t.client.ts"
|
|
206
|
-
import type { C15tClientOptionsExtension } from '
|
|
206
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
207
207
|
import { scripts } from './consent-scripts';
|
|
208
208
|
|
|
209
209
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|