@c15t/scripts 2.1.0 → 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 +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 +100 -17
- package/dist/engine/runtime.js +91 -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 +11 -7
- 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 +42 -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 +39 -39
- 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 +354 -0
- package/docs/frameworks/next/script-loader.md +499 -0
- package/docs/frameworks/react/script-loader.md +553 -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 +309 -0
- package/package.json +61 -7
- package/readme.json +8 -4
package/AGENTS.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @c15t/scripts
|
|
2
|
+
|
|
3
|
+
> Consent-aware script integration docs for analytics, advertising pixels, tag managers, widgets, and custom loaders.
|
|
4
|
+
|
|
5
|
+
These docs ship inside the package so coding agents can read them offline. Open the topic file you need from the list below — paths are relative to this file.
|
|
6
|
+
|
|
7
|
+
## Frameworks
|
|
8
|
+
|
|
9
|
+
Install and configure c15t in JavaScript, React, and Next.js applications.
|
|
10
|
+
|
|
11
|
+
- [Script Loader](./docs/frameworks/javascript/script-loader.md): Gate third-party scripts behind consent — load Google Analytics, Meta Pixel, and other tracking scripts only when users grant permission.
|
|
12
|
+
- [Script Loader](./docs/frameworks/next/script-loader.md): Gate third-party scripts behind consent in Next.js — load Google Analytics, Meta Pixel, and other tracking scripts only when users grant permission.
|
|
13
|
+
- [Script Loader](./docs/frameworks/react/script-loader.md): Gate third-party scripts behind consent in React — load Google Analytics, Meta Pixel, and other tracking scripts only when users grant permission.
|
|
14
|
+
|
|
15
|
+
## Integrations
|
|
16
|
+
|
|
17
|
+
Connect analytics, advertising, maps, media, and other third-party tools behind consent.
|
|
18
|
+
|
|
19
|
+
- [Adobe Analytics](./docs/integrations/adobe-analytics.md): Adobe Analytics loaded through an Adobe Experience Platform Data Collection Tags embed URL.
|
|
20
|
+
- [Ahrefs Analytics](./docs/integrations/ahrefs-analytics.md): Cookieless web analytics from Ahrefs with a prebuilt helper that wires the project key into a c15t-managed script.
|
|
21
|
+
- [Amplitude](./docs/integrations/amplitude.md): Load Amplitude Browser SDK 2 with c15t and gate product analytics behind measurement consent.
|
|
22
|
+
- [Build a Custom Script Integration](./docs/integrations/building-integrations.md): Learn when to use a raw Script, when to build a reusable manifest-backed integration, and how to debug and test custom consent-aware scripts in c15t.
|
|
23
|
+
- [Clearbit](./docs/integrations/clearbit.md): Visitor and company enrichment loaded with Clearbit's account-keyed tags.js snippet.
|
|
24
|
+
- [Cloudflare Web Analytics](./docs/integrations/cloudflare-web-analytics.md): Cookieless analytics from Cloudflare with a prebuilt helper that serializes the beacon config into the `data-cf-beacon` attribute.
|
|
25
|
+
- [Crisp](./docs/integrations/crisp.md): Load Crisp live chat with website ID, runtime, cookie, and session options.
|
|
26
|
+
- [Databuddy](./docs/integrations/databuddy.md): Databuddy is a privacy-focused analytics platform that helps you understand user behavior and track events. It supports cookieless tracking and manages consent automatically through c15t's consent state synchronization.
|
|
27
|
+
- [Fathom Analytics](./docs/integrations/fathom-analytics.md): Privacy-friendly cookieless analytics with a prebuilt helper that maps Fathom's data attributes into a c15t-managed script.
|
|
28
|
+
- [Google Maps](./docs/integrations/google-maps.md): Render Google Maps only after consent with one shared Maps JavaScript API loader and independently managed map instances.
|
|
29
|
+
- [GA4 + Google Ads (gtag.js)](./docs/integrations/google-tag.md): Send data to Google Analytics 4 and Google Ads with automatic Consent Mode v2 support.
|
|
30
|
+
- [Google Tag Manager](./docs/integrations/google-tag-manager.md): Deploy and manage marketing tags centrally with automatic consent state synchronization.
|
|
31
|
+
- [Heap](./docs/integrations/heap.md): Load Heap with c15t and gate autocapture product analytics behind measurement consent.
|
|
32
|
+
- [Hightouch](./docs/integrations/hightouch.md): Load Hightouch Events with c15t and gate the browser SDK behind measurement consent.
|
|
33
|
+
- [Hotjar](./docs/integrations/hotjar.md): Product analytics and behavior insights with a prebuilt helper that seeds Hotjar globals before loading the vendor bundle.
|
|
34
|
+
- [Intercom](./docs/integrations/intercom.md): Bootstrap Intercom settings and load the messenger widget bundle.
|
|
35
|
+
- [LinkedIn Insights](./docs/integrations/linkedin-insights.md): Track conversions and build matched audiences for LinkedIn advertising campaigns.
|
|
36
|
+
- [LogRocket](./docs/integrations/logrocket.md): Session replay and monitoring loaded after measurement consent with LogRocket's browser SDK.
|
|
37
|
+
- [Matomo Analytics](./docs/integrations/matomo-analytics.md): Load Matomo with c15t and keep Matomo's queue aligned with measurement consent.
|
|
38
|
+
- [Meta Pixel](./docs/integrations/meta-pixel.md): Track conversions and build audiences for Facebook and Instagram advertising campaigns.
|
|
39
|
+
- [Microsoft Clarity](./docs/integrations/microsoft-clarity.md): Session replay and behavior analytics with a prebuilt helper that keeps Clarity consent synchronized with c15t measurement state.
|
|
40
|
+
- [Microsoft UET](./docs/integrations/microsoft-uet.md): Track conversions and measure performance for Microsoft Advertising and Bing Ads.
|
|
41
|
+
- [Mixpanel Analytics](./docs/integrations/mixpanel-analytics.md): Load Mixpanel with c15t and let Mixpanel's own opt-in and opt-out APIs follow measurement consent.
|
|
42
|
+
- [Integrations](./docs/integrations/overview.md): Load analytics, pixels, tag managers, and widgets through c15t so consent state controls when they run, update, and appear in your consent UI.
|
|
43
|
+
- [Pirsch](./docs/integrations/pirsch.md): Privacy-friendly, cookieless analytics loaded with Pirsch's fixed script id and identification-code attributes.
|
|
44
|
+
- [Plausible Analytics](./docs/integrations/plausible-analytics.md): Privacy-friendly cookieless analytics with a prebuilt helper that preserves Plausible's queue bootstrap and loader attributes.
|
|
45
|
+
- [PostHog](./docs/integrations/posthog.md): PostHog is an open-source product analytics platform for tracking user behavior, session replays, feature flags, and A/B testing. It supports cookieless tracking, allowing analytics to continue even without cookie consent.
|
|
46
|
+
- [Promptwatch](./docs/integrations/promptwatch.md): Promptwatch analyzes traffic on your site for Artificial Intelligence (AI) traffic and usage insights. Data is stored in the EU without user-identifiable information.
|
|
47
|
+
- [Reddit Pixel](./docs/integrations/reddit-pixel.md): Track conversions and build retargeting audiences for Reddit advertising campaigns.
|
|
48
|
+
- [RudderStack](./docs/integrations/rudderstack.md): Load RudderStack's JavaScript SDK with c15t and gate the browser SDK behind measurement consent.
|
|
49
|
+
- [Rybbit Analytics](./docs/integrations/rybbit-analytics.md): Privacy-friendly analytics with script-tag configuration via Rybbit's data attributes.
|
|
50
|
+
- [Segment](./docs/integrations/segment.md): Load Segment Analytics.js with c15t and gate it behind measurement consent.
|
|
51
|
+
- [Snapchat Pixel](./docs/integrations/snapchat-pixel.md): Measure Snapchat ad performance and build remarketing audiences with a prebuilt pixel helper.
|
|
52
|
+
- [TikTok Pixel](./docs/integrations/tiktok-pixel.md): Measure ad performance and build audiences for TikTok advertising campaigns.
|
|
53
|
+
- [Umami Analytics](./docs/integrations/umami-analytics.md): Open-source, cookieless analytics with a prebuilt helper that maps Umami's data attributes into a c15t-managed script.
|
|
54
|
+
- [Vercel Analytics](./docs/integrations/vercel-analytics.md): Bootstrap Vercel Analytics with a declarative queue and script attributes.
|
|
55
|
+
- [X Pixel (Twitter Pixel)](./docs/integrations/x-pixel.md): Track conversions and build audiences for advertising campaigns on X (formerly Twitter).
|
|
56
|
+
- [YouTube](./docs/integrations/youtube.md): Keep YouTube iframes unmounted until consent with a privacy-enhanced, lazy-loaded React or Next.js embed.
|
|
57
|
+
|
|
58
|
+
## Reference
|
|
59
|
+
|
|
60
|
+
Concepts, legal templates, open-source policies, and contributor documentation.
|
|
61
|
+
|
|
62
|
+
- [Script Loader](./docs/shared/react/guides/script-loader.md): Reference page for script loader.
|
package/README.md
CHANGED
|
@@ -9,38 +9,50 @@
|
|
|
9
9
|
|
|
10
10
|
# @c15t/scripts: Prebuilt Consent Scripts
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
<p>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@c15t/scripts"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/npm/%40c15t%2Fscripts.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/npm/%40c15t%2Fscripts.svg?variant=outline&mode=light" alt="Latest NPM Version"></picture></a>
|
|
14
|
+
<a href="https://github.com/c15t/c15t"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/github/c15t/c15t/stars.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/github/c15t/c15t/stars.svg?variant=outline&mode=light" alt="Stars"></picture></a>
|
|
15
|
+
<a href="https://github.com/c15t/c15t/blob/main/LICENSE.md"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/github/c15t/c15t/license.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/github/c15t/c15t/license.svg?variant=outline&mode=light" alt="License"></picture></a>
|
|
16
|
+
<a href="https://c15t.link/discord"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/discord/1312171102268690493.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/discord/1312171102268690493.svg?variant=outline&mode=light" alt="Discord"></picture></a>
|
|
17
|
+
<a href="https://skills.sh/c15t/skills/c15t"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/skills/c15t/skills/c15t.svg?variant=outline&mode=dark"><img src="https://shieldcn.dev/skills/c15t/skills/c15t.svg?variant=outline&mode=light" alt="Skills"></picture></a>
|
|
18
|
+
<a href="https://inth.com?utm_source=npm&utm_medium=readme&utm_campaign=oss_readme&utm_content=%40c15t%2Fscripts"><picture><source media="(prefers-color-scheme: dark)" srcset="https://shieldcn.dev/badge/Made%20By-Inth-ffc803.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAzOTMgNDAwIj48cGF0aCBmaWxsPSIjMDAwIiBkPSJNMTgyLjY2MiAwdjM2Ljg5NWgtNTkuMDMxdjgyLjczM2g1OS4wMzF2MzYuODkzSDI3LjQ4MnYtMzYuODkzaDU5LjAzVjM2Ljg5NWgtNTkuMDNWMHpNMzIxLjk0MSA4OS44NVYwaDM1LjM1NXYxNTYuNTIxaC0yNS43MTNsLTg2LjEzNy05MC4zNjR2OTAuMzY0aC0zNS4zNTVWMGgyNi4zNTV6Ii8%2BPHBhdGggZmlsbD0iIzAwMCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzE4LjU3MSAxODUuNzE0aDc0LjI4NlY0MDBIMFYxODUuNzE0aDI3Mi44NTd2LTQ3LjE0M3ptLTI5MS4wOSAyOC45Njl2MzcuMTE4aDU4LjEzN3YxMTkuNjI4aDM2Ljg5NVYyNTEuODAxaDU4LjU4NHYtMzcuMTE4em0xODIuNjEuMjI0djE1Ni41MjJoMzYuODk0VjMxMy41OWg3My4zNDF2NTcuODM5aDM3LjExOFYyMTQuOTA3aC0zNy4xMTh2NjEuNzg4aC03My4zNDF2LTYxLjc4OHoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg%3D%3D&color=ffc803&labelTextColor=000000&valueColor=000000&mode=dark"><img src="https://shieldcn.dev/badge/Made%20By-Inth-ffc803.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAzOTMgNDAwIj48cGF0aCBmaWxsPSIjMDAwIiBkPSJNMTgyLjY2MiAwdjM2Ljg5NWgtNTkuMDMxdjgyLjczM2g1OS4wMzF2MzYuODkzSDI3LjQ4MnYtMzYuODkzaDU5LjAzVjM2Ljg5NWgtNTkuMDNWMHpNMzIxLjk0MSA4OS44NVYwaDM1LjM1NXYxNTYuNTIxaC0yNS43MTNsLTg2LjEzNy05MC4zNjR2OTAuMzY0aC0zNS4zNTVWMGgyNi4zNTV6Ii8%2BPHBhdGggZmlsbD0iIzAwMCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzE4LjU3MSAxODUuNzE0aDc0LjI4NlY0MDBIMFYxODUuNzE0aDI3Mi44NTd2LTQ3LjE0M3ptLTI5MS4wOSAyOC45Njl2MzcuMTE4aDU4LjEzN3YxMTkuNjI4aDM2Ljg5NVYyNTEuODAxaDU4LjU4NHYtMzcuMTE4em0xODIuNjEuMjI0djE1Ni41MjJoMzYuODk0VjMxMy41OWg3My4zNDF2NTcuODM5aDM3LjExOFYyMTQuOTA3aC0zNy4xMTh2NjEuNzg4aC03My4zNDF2LTYxLjc4OHoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg%3D%3D&color=ffc803&labelTextColor=000000&valueColor=000000&mode=light" alt="Made by Inth"></picture></a>
|
|
19
|
+
</p>
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Consent-aware script integrations for Google Tag Manager, Google Consent Mode v2, GA4, Google Ads, Meta Pixel, analytics tools, pixels, tag managers, and widgets.
|
|
22
22
|
|
|
23
23
|
## Key Features
|
|
24
24
|
|
|
25
|
-
- Prebuilt script
|
|
25
|
+
- Prebuilt script loaders for popular analytics, advertising, marketing, and functional tools
|
|
26
|
+
- Google Tag Manager support with Google Consent Mode v2 defaults and consent updates
|
|
27
|
+
- Google Analytics 4 and Google Ads support through gtag.js
|
|
28
|
+
- Consent-gated Meta Pixel and conversion pixel loading
|
|
26
29
|
- Easy integration with c15t's script loader
|
|
27
30
|
- Configuration options for each supported vendor
|
|
28
|
-
- Supported vendors include Google Tag Manager, Meta Pixel, PostHog, TikTok Pixel, LinkedIn Insights, Microsoft UET,
|
|
31
|
+
- Supported vendors include Google Tag Manager, Meta Pixel, Amplitude, Heap, PostHog, TikTok Pixel, LinkedIn Insights, Microsoft UET, X Pixel, Reddit Pixel, Snapchat Pixel, Intercom, Crisp, and more
|
|
29
32
|
|
|
30
33
|
## Documentation
|
|
31
34
|
|
|
32
35
|
For further information, guides, and examples visit the [reference documentation](https://c15t.com/docs/integrations).
|
|
33
36
|
|
|
34
|
-
##
|
|
37
|
+
## Integrations
|
|
38
|
+
|
|
39
|
+
- **Google Tag Manager**: Loads with Google Consent Mode v2 defaults set to denied; GTM-managed tags fire only once matching consent is granted ([guide](https://c15t.com/docs/integrations/google-tag-manager))
|
|
40
|
+
- **Google Analytics 4 + Google Ads (gtag.js)**: Consent Mode v2 defaults and consent updates when users make a choice ([guide](https://c15t.com/docs/integrations/google-tag))
|
|
41
|
+
- **Conversion pixels**: Meta Pixel, TikTok Pixel, LinkedIn Insights, Microsoft UET (Microsoft Ads), X Pixel, Reddit Pixel, Snapchat Pixel
|
|
42
|
+
- **Analytics**: PostHog, Amplitude, Heap, Segment, RudderStack, Hightouch, Mixpanel, Microsoft Clarity, Hotjar, Plausible, Fathom, Matomo, Umami, Vercel Analytics
|
|
43
|
+
- **Chat widgets**: Intercom, Crisp
|
|
44
|
+
|
|
45
|
+
## Example
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { googleTagManager } from '@c15t/scripts/google-tag-manager'
|
|
49
|
+
import { metaPixel } from '@c15t/scripts/meta-pixel'
|
|
35
50
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- [LinkedIn Insights](https://c15t.link/linkedin-insights)
|
|
42
|
-
- [Microsoft UET](https://c15t.link/microsoft-uet)
|
|
43
|
-
- [X Pixel](https://c15t.link/x-pixel)
|
|
51
|
+
const scripts = [
|
|
52
|
+
googleTagManager({ id: 'GTM-XXXXXX' }),
|
|
53
|
+
metaPixel({ pixelId: '000000000000000' }),
|
|
54
|
+
]
|
|
55
|
+
```
|
|
44
56
|
|
|
45
57
|
## Support
|
|
46
58
|
|
package/dist/e2e-test-utils.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -25,14 +29,15 @@ var __webpack_exports__ = {};
|
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
31
|
deniedConsents: ()=>deniedConsents,
|
|
32
|
+
grantedMarketingConsents: ()=>grantedMarketingConsents,
|
|
28
33
|
grantedMeasurementConsents: ()=>grantedMeasurementConsents,
|
|
29
34
|
installBodyProbe: ()=>installBodyProbe,
|
|
30
|
-
loadScripts: ()=>script_loader_namespaceObject.loadScripts,
|
|
31
|
-
registerVendorContractCleanup: ()=>registerVendorContractCleanup,
|
|
32
35
|
installHeadProbe: ()=>installHeadProbe,
|
|
33
36
|
isArgumentsPayload: ()=>isArgumentsPayload,
|
|
37
|
+
loadScripts: ()=>script_loader_namespaceObject.loadScripts,
|
|
38
|
+
registerVendorContractCleanup: ()=>registerVendorContractCleanup,
|
|
34
39
|
toArgs: ()=>toArgs,
|
|
35
|
-
|
|
40
|
+
updateScripts: ()=>script_loader_namespaceObject.updateScripts
|
|
36
41
|
});
|
|
37
42
|
const external_vitest_namespaceObject = require("vitest");
|
|
38
43
|
const script_loader_namespaceObject = require("../../core/src/libs/script-loader");
|
|
@@ -76,19 +81,53 @@ function resetVendorGlobals() {
|
|
|
76
81
|
for (const key of [
|
|
77
82
|
'TiktokAnalyticsObject',
|
|
78
83
|
'UET',
|
|
84
|
+
'$crisp',
|
|
85
|
+
'CRISP_COOKIE_DOMAIN',
|
|
86
|
+
'CRISP_COOKIE_EXPIRE',
|
|
87
|
+
'CRISP_RUNTIME_CONFIG',
|
|
88
|
+
'CRISP_TOKEN_ID',
|
|
89
|
+
'CRISP_WEBSITE_ID',
|
|
90
|
+
'Intercom',
|
|
79
91
|
'_linkedin_data_partner_ids',
|
|
80
92
|
'_linkedin_partner_id',
|
|
81
93
|
'_fbq',
|
|
94
|
+
'_hjSettings',
|
|
95
|
+
'_paq',
|
|
96
|
+
'_satellite',
|
|
97
|
+
'_snaptr',
|
|
98
|
+
'adobeDataLayer',
|
|
99
|
+
'amplitude',
|
|
100
|
+
'analytics',
|
|
101
|
+
'clarity',
|
|
82
102
|
'dataLayer',
|
|
83
103
|
'databuddy',
|
|
84
104
|
'databuddyConfig',
|
|
85
105
|
'fbq',
|
|
86
106
|
'google_tag_data',
|
|
107
|
+
'heap',
|
|
108
|
+
'heapReadyCb',
|
|
109
|
+
'htevents',
|
|
110
|
+
'hj',
|
|
111
|
+
'intercomSettings',
|
|
87
112
|
'lintrk',
|
|
113
|
+
'LogRocket',
|
|
114
|
+
'mixpanel',
|
|
115
|
+
'pirsch',
|
|
116
|
+
'pirschClearSession',
|
|
117
|
+
'pirschInit',
|
|
118
|
+
'pirschNotFound',
|
|
119
|
+
'plausible',
|
|
88
120
|
'posthog',
|
|
121
|
+
'rdt',
|
|
122
|
+
'rudderanalytics',
|
|
123
|
+
'rudderAnalyticsBuildType',
|
|
124
|
+
'RudderSnippetVersion',
|
|
125
|
+
'snaptr',
|
|
89
126
|
'ttq',
|
|
90
127
|
'twq',
|
|
91
|
-
'uetq'
|
|
128
|
+
'uetq',
|
|
129
|
+
'va',
|
|
130
|
+
'vaq'
|
|
92
131
|
])delete win[key];
|
|
93
132
|
}
|
|
94
133
|
function registerVendorContractCleanup() {
|
|
@@ -109,6 +148,7 @@ exports.isArgumentsPayload = __webpack_exports__.isArgumentsPayload;
|
|
|
109
148
|
exports.loadScripts = __webpack_exports__.loadScripts;
|
|
110
149
|
exports.registerVendorContractCleanup = __webpack_exports__.registerVendorContractCleanup;
|
|
111
150
|
exports.toArgs = __webpack_exports__.toArgs;
|
|
151
|
+
exports.updateScripts = __webpack_exports__.updateScripts;
|
|
112
152
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
113
153
|
"deniedConsents",
|
|
114
154
|
"grantedMarketingConsents",
|
|
@@ -118,7 +158,8 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
118
158
|
"isArgumentsPayload",
|
|
119
159
|
"loadScripts",
|
|
120
160
|
"registerVendorContractCleanup",
|
|
121
|
-
"toArgs"
|
|
161
|
+
"toArgs",
|
|
162
|
+
"updateScripts"
|
|
122
163
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
123
164
|
Object.defineProperty(exports, '__esModule', {
|
|
124
165
|
value: true
|
package/dist/e2e-test-utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterEach, vi } from "vitest";
|
|
2
|
-
import { clearAllScripts, loadScripts } from "../../core/src/libs/script-loader";
|
|
2
|
+
import { clearAllScripts, loadScripts, updateScripts } from "../../core/src/libs/script-loader";
|
|
3
3
|
const deniedConsents = {
|
|
4
4
|
necessary: true,
|
|
5
5
|
functionality: false,
|
|
@@ -40,19 +40,53 @@ function resetVendorGlobals() {
|
|
|
40
40
|
for (const key of [
|
|
41
41
|
'TiktokAnalyticsObject',
|
|
42
42
|
'UET',
|
|
43
|
+
'$crisp',
|
|
44
|
+
'CRISP_COOKIE_DOMAIN',
|
|
45
|
+
'CRISP_COOKIE_EXPIRE',
|
|
46
|
+
'CRISP_RUNTIME_CONFIG',
|
|
47
|
+
'CRISP_TOKEN_ID',
|
|
48
|
+
'CRISP_WEBSITE_ID',
|
|
49
|
+
'Intercom',
|
|
43
50
|
'_linkedin_data_partner_ids',
|
|
44
51
|
'_linkedin_partner_id',
|
|
45
52
|
'_fbq',
|
|
53
|
+
'_hjSettings',
|
|
54
|
+
'_paq',
|
|
55
|
+
'_satellite',
|
|
56
|
+
'_snaptr',
|
|
57
|
+
'adobeDataLayer',
|
|
58
|
+
'amplitude',
|
|
59
|
+
'analytics',
|
|
60
|
+
'clarity',
|
|
46
61
|
'dataLayer',
|
|
47
62
|
'databuddy',
|
|
48
63
|
'databuddyConfig',
|
|
49
64
|
'fbq',
|
|
50
65
|
'google_tag_data',
|
|
66
|
+
'heap',
|
|
67
|
+
'heapReadyCb',
|
|
68
|
+
'htevents',
|
|
69
|
+
'hj',
|
|
70
|
+
'intercomSettings',
|
|
51
71
|
'lintrk',
|
|
72
|
+
'LogRocket',
|
|
73
|
+
'mixpanel',
|
|
74
|
+
'pirsch',
|
|
75
|
+
'pirschClearSession',
|
|
76
|
+
'pirschInit',
|
|
77
|
+
'pirschNotFound',
|
|
78
|
+
'plausible',
|
|
52
79
|
'posthog',
|
|
80
|
+
'rdt',
|
|
81
|
+
'rudderanalytics',
|
|
82
|
+
'rudderAnalyticsBuildType',
|
|
83
|
+
'RudderSnippetVersion',
|
|
84
|
+
'snaptr',
|
|
53
85
|
'ttq',
|
|
54
86
|
'twq',
|
|
55
|
-
'uetq'
|
|
87
|
+
'uetq',
|
|
88
|
+
'va',
|
|
89
|
+
'vaq'
|
|
56
90
|
])delete win[key];
|
|
57
91
|
}
|
|
58
92
|
function registerVendorContractCleanup() {
|
|
@@ -64,4 +98,4 @@ function registerVendorContractCleanup() {
|
|
|
64
98
|
resetVendorGlobals();
|
|
65
99
|
});
|
|
66
100
|
}
|
|
67
|
-
export { deniedConsents, grantedMarketingConsents, grantedMeasurementConsents, installBodyProbe, installHeadProbe, isArgumentsPayload, loadScripts, registerVendorContractCleanup, toArgs };
|
|
101
|
+
export { deniedConsents, grantedMarketingConsents, grantedMeasurementConsents, installBodyProbe, installHeadProbe, isArgumentsPayload, loadScripts, registerVendorContractCleanup, toArgs, updateScripts };
|
package/dist/engine/compile.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
package/dist/engine/runtime.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -149,12 +153,36 @@ function executeStep(step) {
|
|
|
149
153
|
{
|
|
150
154
|
const target = win[step.target];
|
|
151
155
|
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
156
|
+
if (!step.queue && !Array.isArray(target)) break;
|
|
152
157
|
const targetRecord = target;
|
|
153
158
|
for (const methodName of step.methods)targetRecord[methodName] = (...args)=>{
|
|
154
159
|
const queueTarget = resolveQueueTarget(win, step.queue ?? {
|
|
155
160
|
global: step.target
|
|
156
161
|
}, targetRecord);
|
|
157
162
|
if (!queueTarget) return;
|
|
163
|
+
if ('methodCall' === step.queueFormat || 'wrappedMethodCall' === step.queueFormat || 'voidMethodCall' === step.queueFormat) {
|
|
164
|
+
const promise = new Promise((resolve)=>{
|
|
165
|
+
queueTarget.push({
|
|
166
|
+
name: methodName,
|
|
167
|
+
args,
|
|
168
|
+
resolve
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
if ('wrappedMethodCall' === step.queueFormat) return {
|
|
172
|
+
promise
|
|
173
|
+
};
|
|
174
|
+
if ('voidMethodCall' === step.queueFormat) return;
|
|
175
|
+
return promise;
|
|
176
|
+
}
|
|
177
|
+
if ('callback' === step.queueFormat) return void queueTarget.push({
|
|
178
|
+
name: methodName,
|
|
179
|
+
fn: ()=>{
|
|
180
|
+
const latestTarget = win[step.target];
|
|
181
|
+
if (null === latestTarget || 'object' != typeof latestTarget && 'function' != typeof latestTarget) return;
|
|
182
|
+
const method = latestTarget[methodName];
|
|
183
|
+
if ('function' == typeof method) method.apply(latestTarget, args);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
158
186
|
queueTarget.push([
|
|
159
187
|
methodName,
|
|
160
188
|
...args
|
|
@@ -162,6 +190,26 @@ function executeStep(step) {
|
|
|
162
190
|
};
|
|
163
191
|
break;
|
|
164
192
|
}
|
|
193
|
+
case 'defineQueueClass':
|
|
194
|
+
{
|
|
195
|
+
const target = win[step.target];
|
|
196
|
+
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
197
|
+
const queueProperty = step.queueProperty ?? '_q';
|
|
198
|
+
const QueueClass = function() {
|
|
199
|
+
this[queueProperty] = [];
|
|
200
|
+
};
|
|
201
|
+
const prototype = QueueClass.prototype;
|
|
202
|
+
for (const methodName of step.methods)prototype[methodName] = function(...args) {
|
|
203
|
+
const queueTarget = this[queueProperty];
|
|
204
|
+
if (Array.isArray(queueTarget)) queueTarget.push({
|
|
205
|
+
name: methodName,
|
|
206
|
+
args
|
|
207
|
+
});
|
|
208
|
+
return this;
|
|
209
|
+
};
|
|
210
|
+
target[step.name] = QueueClass;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
165
213
|
case 'defineGlobalMethods':
|
|
166
214
|
{
|
|
167
215
|
const target = win[step.target];
|
|
@@ -261,22 +309,57 @@ function mapConsentState(mapping, consents) {
|
|
|
261
309
|
}
|
|
262
310
|
return result;
|
|
263
311
|
}
|
|
312
|
+
function partitionConsentIds(mapping, consents) {
|
|
313
|
+
const allowedConsentIds = [];
|
|
314
|
+
const deniedConsentIds = [];
|
|
315
|
+
for (const [c15tCategory, consentIds] of Object.entries(mapping)){
|
|
316
|
+
const isGranted = consents[c15tCategory];
|
|
317
|
+
for (const consentId of consentIds)(isGranted ? allowedConsentIds : deniedConsentIds).push(consentId);
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
allowedConsentIds,
|
|
321
|
+
deniedConsentIds
|
|
322
|
+
};
|
|
323
|
+
}
|
|
264
324
|
function getConsentSignalSteps(resolvedManifest, mode, consents) {
|
|
265
325
|
if (!resolvedManifest.consentMapping || !resolvedManifest.consentSignal) return [];
|
|
266
|
-
const mapped = mapConsentState(resolvedManifest.consentMapping, consents);
|
|
267
326
|
switch(resolvedManifest.consentSignal){
|
|
268
327
|
case 'gtag':
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
'
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
328
|
+
{
|
|
329
|
+
const mapped = mapConsentState(resolvedManifest.consentMapping, consents);
|
|
330
|
+
return [
|
|
331
|
+
{
|
|
332
|
+
type: 'callGlobal',
|
|
333
|
+
global: resolvedManifest.consentSignalTarget ?? 'gtag',
|
|
334
|
+
args: [
|
|
335
|
+
'consent',
|
|
336
|
+
mode,
|
|
337
|
+
mapped
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
];
|
|
341
|
+
}
|
|
342
|
+
case 'rudderstack':
|
|
343
|
+
{
|
|
344
|
+
const partition = partitionConsentIds(resolvedManifest.consentMapping, consents);
|
|
345
|
+
return [
|
|
346
|
+
{
|
|
347
|
+
type: 'callGlobal',
|
|
348
|
+
global: resolvedManifest.consentSignalTarget ?? 'rudderanalytics',
|
|
349
|
+
method: 'consent',
|
|
350
|
+
args: [
|
|
351
|
+
{
|
|
352
|
+
consentManagement: {
|
|
353
|
+
enabled: true,
|
|
354
|
+
provider: 'custom',
|
|
355
|
+
allowedConsentIds: partition.allowedConsentIds,
|
|
356
|
+
deniedConsentIds: partition.deniedConsentIds
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
];
|
|
362
|
+
}
|
|
280
363
|
}
|
|
281
364
|
}
|
|
282
365
|
function resolvedManifestToScript(resolvedManifest) {
|
package/dist/engine/runtime.js
CHANGED
|
@@ -121,12 +121,36 @@ function executeStep(step) {
|
|
|
121
121
|
{
|
|
122
122
|
const target = win[step.target];
|
|
123
123
|
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
124
|
+
if (!step.queue && !Array.isArray(target)) break;
|
|
124
125
|
const targetRecord = target;
|
|
125
126
|
for (const methodName of step.methods)targetRecord[methodName] = (...args)=>{
|
|
126
127
|
const queueTarget = resolveQueueTarget(win, step.queue ?? {
|
|
127
128
|
global: step.target
|
|
128
129
|
}, targetRecord);
|
|
129
130
|
if (!queueTarget) return;
|
|
131
|
+
if ('methodCall' === step.queueFormat || 'wrappedMethodCall' === step.queueFormat || 'voidMethodCall' === step.queueFormat) {
|
|
132
|
+
const promise = new Promise((resolve)=>{
|
|
133
|
+
queueTarget.push({
|
|
134
|
+
name: methodName,
|
|
135
|
+
args,
|
|
136
|
+
resolve
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
if ('wrappedMethodCall' === step.queueFormat) return {
|
|
140
|
+
promise
|
|
141
|
+
};
|
|
142
|
+
if ('voidMethodCall' === step.queueFormat) return;
|
|
143
|
+
return promise;
|
|
144
|
+
}
|
|
145
|
+
if ('callback' === step.queueFormat) return void queueTarget.push({
|
|
146
|
+
name: methodName,
|
|
147
|
+
fn: ()=>{
|
|
148
|
+
const latestTarget = win[step.target];
|
|
149
|
+
if (null === latestTarget || 'object' != typeof latestTarget && 'function' != typeof latestTarget) return;
|
|
150
|
+
const method = latestTarget[methodName];
|
|
151
|
+
if ('function' == typeof method) method.apply(latestTarget, args);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
130
154
|
queueTarget.push([
|
|
131
155
|
methodName,
|
|
132
156
|
...args
|
|
@@ -134,6 +158,26 @@ function executeStep(step) {
|
|
|
134
158
|
};
|
|
135
159
|
break;
|
|
136
160
|
}
|
|
161
|
+
case 'defineQueueClass':
|
|
162
|
+
{
|
|
163
|
+
const target = win[step.target];
|
|
164
|
+
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
165
|
+
const queueProperty = step.queueProperty ?? '_q';
|
|
166
|
+
const QueueClass = function() {
|
|
167
|
+
this[queueProperty] = [];
|
|
168
|
+
};
|
|
169
|
+
const prototype = QueueClass.prototype;
|
|
170
|
+
for (const methodName of step.methods)prototype[methodName] = function(...args) {
|
|
171
|
+
const queueTarget = this[queueProperty];
|
|
172
|
+
if (Array.isArray(queueTarget)) queueTarget.push({
|
|
173
|
+
name: methodName,
|
|
174
|
+
args
|
|
175
|
+
});
|
|
176
|
+
return this;
|
|
177
|
+
};
|
|
178
|
+
target[step.name] = QueueClass;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
137
181
|
case 'defineGlobalMethods':
|
|
138
182
|
{
|
|
139
183
|
const target = win[step.target];
|
|
@@ -233,22 +277,57 @@ function mapConsentState(mapping, consents) {
|
|
|
233
277
|
}
|
|
234
278
|
return result;
|
|
235
279
|
}
|
|
280
|
+
function partitionConsentIds(mapping, consents) {
|
|
281
|
+
const allowedConsentIds = [];
|
|
282
|
+
const deniedConsentIds = [];
|
|
283
|
+
for (const [c15tCategory, consentIds] of Object.entries(mapping)){
|
|
284
|
+
const isGranted = consents[c15tCategory];
|
|
285
|
+
for (const consentId of consentIds)(isGranted ? allowedConsentIds : deniedConsentIds).push(consentId);
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
allowedConsentIds,
|
|
289
|
+
deniedConsentIds
|
|
290
|
+
};
|
|
291
|
+
}
|
|
236
292
|
function getConsentSignalSteps(resolvedManifest, mode, consents) {
|
|
237
293
|
if (!resolvedManifest.consentMapping || !resolvedManifest.consentSignal) return [];
|
|
238
|
-
const mapped = mapConsentState(resolvedManifest.consentMapping, consents);
|
|
239
294
|
switch(resolvedManifest.consentSignal){
|
|
240
295
|
case 'gtag':
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
'
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
296
|
+
{
|
|
297
|
+
const mapped = mapConsentState(resolvedManifest.consentMapping, consents);
|
|
298
|
+
return [
|
|
299
|
+
{
|
|
300
|
+
type: 'callGlobal',
|
|
301
|
+
global: resolvedManifest.consentSignalTarget ?? 'gtag',
|
|
302
|
+
args: [
|
|
303
|
+
'consent',
|
|
304
|
+
mode,
|
|
305
|
+
mapped
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
];
|
|
309
|
+
}
|
|
310
|
+
case 'rudderstack':
|
|
311
|
+
{
|
|
312
|
+
const partition = partitionConsentIds(resolvedManifest.consentMapping, consents);
|
|
313
|
+
return [
|
|
314
|
+
{
|
|
315
|
+
type: 'callGlobal',
|
|
316
|
+
global: resolvedManifest.consentSignalTarget ?? 'rudderanalytics',
|
|
317
|
+
method: 'consent',
|
|
318
|
+
args: [
|
|
319
|
+
{
|
|
320
|
+
consentManagement: {
|
|
321
|
+
enabled: true,
|
|
322
|
+
provider: 'custom',
|
|
323
|
+
allowedConsentIds: partition.allowedConsentIds,
|
|
324
|
+
deniedConsentIds: partition.deniedConsentIds
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
];
|
|
330
|
+
}
|
|
252
331
|
}
|
|
253
332
|
}
|
|
254
333
|
function resolvedManifestToScript(resolvedManifest) {
|