@c15t/scripts 2.0.1 → 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 +41 -29
- 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 +111 -17
- package/dist/engine/runtime.js +102 -12
- package/dist/registry.cjs +423 -0
- package/dist/registry.js +372 -0
- package/dist/resolve.cjs +9 -5
- package/dist/types.cjs +32 -10
- package/dist/types.js +10 -1
- package/dist/vendors/_shared/attributes.cjs +55 -0
- package/dist/vendors/_shared/attributes.js +14 -0
- package/dist/vendors/_shared/google-consent.cjs +69 -0
- package/dist/vendors/_shared/google-consent.js +27 -0
- package/dist/vendors/_shared/install-builders.cjs +59 -0
- package/dist/vendors/_shared/install-builders.js +21 -0
- package/dist/vendors/_shared/script-url.cjs +78 -0
- package/dist/vendors/_shared/script-url.js +28 -0
- package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +11 -7
- package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +206 -0
- package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
- package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +42 -21
- package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +151 -0
- package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +131 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
- package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +11 -7
- package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
- package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +15 -8
- package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
- 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 +68 -0
- package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
- 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 +73 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
- package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +14 -10
- package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
- package/dist/vendors/analytics/fathom-analytics.cjs +76 -0
- package/dist/vendors/analytics/fathom-analytics.js +35 -0
- package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +18 -35
- package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
- 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 +85 -0
- package/dist/vendors/analytics/hotjar.js +44 -0
- package/dist/vendors/analytics/logrocket.cjs +99 -0
- package/dist/vendors/analytics/logrocket.js +58 -0
- package/dist/vendors/analytics/matomo-analytics.cjs +232 -0
- package/dist/vendors/analytics/matomo-analytics.js +191 -0
- package/dist/vendors/analytics/microsoft-clarity.cjs +138 -0
- package/dist/vendors/analytics/microsoft-clarity.js +97 -0
- package/dist/vendors/analytics/mixpanel-analytics.cjs +134 -0
- package/dist/vendors/analytics/mixpanel-analytics.js +93 -0
- package/dist/vendors/analytics/pirsch.cjs +108 -0
- package/dist/vendors/analytics/pirsch.js +67 -0
- package/dist/vendors/analytics/plausible-analytics.cjs +122 -0
- package/dist/vendors/analytics/plausible-analytics.js +81 -0
- package/dist/vendors/analytics/posthog.cjs +204 -0
- package/dist/vendors/analytics/posthog.js +163 -0
- package/dist/vendors/analytics/promptwatch.cjs +70 -0
- package/dist/vendors/analytics/promptwatch.js +29 -0
- package/dist/vendors/analytics/rudderstack.cjs +227 -0
- package/dist/vendors/analytics/rudderstack.js +183 -0
- package/dist/vendors/analytics/rybbit-analytics.cjs +104 -0
- package/dist/vendors/analytics/rybbit-analytics.js +63 -0
- package/dist/vendors/analytics/segment.cjs +97 -0
- package/dist/vendors/analytics/segment.js +56 -0
- package/dist/vendors/analytics/umami-analytics.cjs +80 -0
- package/dist/vendors/analytics/umami-analytics.js +39 -0
- package/dist/vendors/analytics/vercel-analytics.cjs +94 -0
- package/dist/vendors/analytics/vercel-analytics.js +53 -0
- package/dist/vendors/functional/crisp.cjs +143 -0
- package/dist/vendors/functional/crisp.js +102 -0
- package/dist/vendors/functional/intercom.cjs +89 -0
- package/dist/vendors/functional/intercom.js +45 -0
- package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +17 -34
- package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
- package/dist-types/__tests__/helpers.d.ts +141 -0
- package/dist-types/engine/runtime.d.ts +1 -1
- package/dist-types/registry.d.ts +440 -0
- package/dist-types/types.d.ts +53 -2
- package/dist-types/vendors/_shared/attributes.d.ts +35 -0
- package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
- package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
- package/dist-types/vendors/_shared/script-url.d.ts +75 -0
- package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +92 -0
- package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
- package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +45 -34
- package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
- package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
- package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +48 -33
- package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +34 -17
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
- 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 +67 -0
- package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +25 -25
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
- package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +21 -24
- 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 +73 -0
- package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +98 -0
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +113 -0
- package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
- package/dist-types/vendors/analytics/posthog.d.ts +154 -0
- package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
- package/dist-types/vendors/analytics/rudderstack.d.ts +330 -0
- package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
- package/dist-types/vendors/analytics/segment.d.ts +158 -0
- package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
- package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
- package/dist-types/vendors/functional/crisp.d.ts +78 -0
- package/dist-types/vendors/functional/intercom.d.ts +135 -0
- package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +22 -25
- 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 +223 -8
- package/readme.json +8 -4
- package/dist/meta-pixel.cjs +0 -129
- package/dist/meta-pixel.js +0 -89
- package/dist/posthog.cjs +0 -137
- package/dist/posthog.js +0 -100
- package/dist-types/linkedin-insights.d.ts +0 -79
- package/dist-types/meta-pixel.d.ts +0 -185
- package/dist-types/posthog.d.ts +0 -112
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an optional boolean into a string suitable for a script `data-*`
|
|
3
|
+
* attribute.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Optional boolean value from a vendor option.
|
|
6
|
+
* @returns `'true'` or `'false'` when a boolean is provided, otherwise
|
|
7
|
+
* `undefined` so the manifest compiler can omit the attribute.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* booleanDataAttribute(true); // 'true'
|
|
12
|
+
* booleanDataAttribute(false); // 'false'
|
|
13
|
+
* booleanDataAttribute(undefined); // undefined
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function booleanDataAttribute(value: boolean | undefined): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Converts a string or string list into a script `data-*` attribute value.
|
|
19
|
+
*
|
|
20
|
+
* Arrays are JSON-serialized so values containing commas can be round-tripped
|
|
21
|
+
* with `JSON.parse` by consumers that read the attribute.
|
|
22
|
+
*
|
|
23
|
+
* @param value - Optional string value or string list from a vendor option.
|
|
24
|
+
* @returns The original string, a JSON-serialized array, or `undefined` so the
|
|
25
|
+
* manifest compiler can omit the attribute.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* listDataAttribute('example.com'); // 'example.com'
|
|
30
|
+
* listDataAttribute(['a.com', 'b.com']); // '["a.com","b.com"]'
|
|
31
|
+
* listDataAttribute([]); // undefined
|
|
32
|
+
* listDataAttribute(undefined); // undefined
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function listDataAttribute(value: string[] | string | undefined): string | undefined;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default c15t consent category mapping for Google Consent Mode v2.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Shared by direct gtag.js and Google Tag Manager integrations so both emit the
|
|
6
|
+
* same Google storage consent defaults unless a caller provides an override.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const manifest = {
|
|
11
|
+
* consentMapping: GOOGLE_CONSENT_MODE_V2_DEFAULT_MAPPING,
|
|
12
|
+
* };
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const GOOGLE_CONSENT_MODE_V2_DEFAULT_MAPPING: Record<string, string[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Applies an optional Google consent mapping override to a manifest.
|
|
18
|
+
*
|
|
19
|
+
* @param manifest - Vendor manifest that already contains the default consent
|
|
20
|
+
* mapping.
|
|
21
|
+
* @param consentMapping - Optional caller-provided mapping from c15t consent
|
|
22
|
+
* categories to Google consent types.
|
|
23
|
+
* @returns The original manifest when no override is provided, or a shallow
|
|
24
|
+
* copy with the override mapping when one is provided.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const customMapping: Record<string, string[]> = {
|
|
29
|
+
* marketing: ['ad_storage'],
|
|
30
|
+
* };
|
|
31
|
+
* const mapped = withOptionalConsentMapping<TManifest>(
|
|
32
|
+
* manifest,
|
|
33
|
+
* customMapping
|
|
34
|
+
* );
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const unchanged = withOptionalConsentMapping<TManifest>(
|
|
40
|
+
* manifest,
|
|
41
|
+
* undefined
|
|
42
|
+
* );
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function withOptionalConsentMapping<TManifest extends {
|
|
46
|
+
consentMapping?: Record<string, string[]>;
|
|
47
|
+
}>(manifest: TManifest, consentMapping: Record<string, string[]> | undefined): TManifest;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { VendorManifest } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Optional tracking call inserted between the vendor init call and script load.
|
|
4
|
+
*/
|
|
5
|
+
interface QueuePixelInstallStep {
|
|
6
|
+
/** Arguments passed to the vendor queue function. */
|
|
7
|
+
args: unknown[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Options for building the common pixel install sequence.
|
|
11
|
+
*/
|
|
12
|
+
export interface BuildQueuePixelInstallOptions {
|
|
13
|
+
/** Global queue function to call, for example `rdt` or `snaptr`. */
|
|
14
|
+
global: string;
|
|
15
|
+
/** Arguments for the required initialization call. */
|
|
16
|
+
initArgs: unknown[];
|
|
17
|
+
/** Optional tracking command queued immediately after initialization. */
|
|
18
|
+
trackStep?: QueuePixelInstallStep;
|
|
19
|
+
/** Manifest interpolation token used for the final loader script URL. */
|
|
20
|
+
scriptPlaceholder?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Builds the common queue-pixel install sequence used by advertising pixels.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Queue pixel install options.
|
|
26
|
+
* @returns Manifest install steps containing the required init call, an
|
|
27
|
+
* optional tracking call, and an async `loadScript` step.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildQueuePixelInstall({ global, initArgs, trackStep, scriptPlaceholder, }: BuildQueuePixelInstallOptions): VendorManifest['install'];
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trims an optional string and treats empty or whitespace-only values as
|
|
3
|
+
* missing.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Optional string value, usually a user-provided override.
|
|
6
|
+
* @returns The trimmed string when it contains non-whitespace characters,
|
|
7
|
+
* otherwise `undefined`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* trimToUndefined(' https://cdn.example.com '); // 'https://cdn.example.com'
|
|
12
|
+
* trimToUndefined(' '); // undefined
|
|
13
|
+
* trimToUndefined(undefined); // undefined
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function trimToUndefined(value: string | undefined): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a script URL from an optional override and a required fallback.
|
|
19
|
+
*
|
|
20
|
+
* @param override - Explicit script URL supplied by the integration caller.
|
|
21
|
+
* @param fallback - Default vendor script URL.
|
|
22
|
+
* @returns `override` when it is defined, otherwise `fallback`.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* This helper intentionally does not trim or validate the override. Use
|
|
26
|
+
* `trimToUndefined` before calling this helper when blank string overrides
|
|
27
|
+
* should fall back to the vendor default.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* resolveScriptUrl(undefined, 'https://cdn.example.com/default.js');
|
|
32
|
+
* // 'https://cdn.example.com/default.js'
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* resolveScriptUrl(
|
|
38
|
+
* 'https://custom.com/script.js',
|
|
39
|
+
* 'https://cdn.example.com/default.js'
|
|
40
|
+
* );
|
|
41
|
+
* // 'https://custom.com/script.js'
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveScriptUrl(override: string | undefined, fallback: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Removes leading slash characters without using a regular expression.
|
|
47
|
+
*
|
|
48
|
+
* This helper is used on caller-controlled URL fragments, so it intentionally
|
|
49
|
+
* stays linear even for very long repeated slash input.
|
|
50
|
+
*/
|
|
51
|
+
export declare function stripLeadingSlashes(value: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Removes trailing slash characters without using a regular expression.
|
|
54
|
+
*
|
|
55
|
+
* This helper is used on caller-controlled URL fragments, so it intentionally
|
|
56
|
+
* stays linear even for very long repeated slash input.
|
|
57
|
+
*/
|
|
58
|
+
export declare function stripTrailingSlashes(value: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Joins a base URL and path with exactly one slash between them.
|
|
61
|
+
*
|
|
62
|
+
* @param base - Base URL or origin. Trailing slashes are removed before joining.
|
|
63
|
+
* @param path - Path segment. Leading slashes are removed before joining.
|
|
64
|
+
* @returns A slash-joined URL string.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* joinUrlPath('https://example.com///', '///script.js');
|
|
69
|
+
* // 'https://example.com/script.js'
|
|
70
|
+
*
|
|
71
|
+
* joinUrlPath('https://example.com', 'script.js');
|
|
72
|
+
* // 'https://example.com/script.js'
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function joinUrlPath(base: string, path: string): string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
export interface LinkedInInsightsConversionEvent {
|
|
3
|
+
conversion_id: string | number;
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
}
|
|
6
|
+
type LinkedInInsightsFunction = {
|
|
7
|
+
(command: 'track', event: LinkedInInsightsConversionEvent): void;
|
|
8
|
+
(command: string, ...args: unknown[]): void;
|
|
9
|
+
};
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
lintrk: LinkedInInsightsFunction & {
|
|
13
|
+
q?: unknown[][];
|
|
14
|
+
};
|
|
15
|
+
_linkedin_partner_id?: string;
|
|
16
|
+
_linkedin_data_partner_ids?: string[];
|
|
17
|
+
ORIBILI?: {
|
|
18
|
+
_DEBUG?: {
|
|
19
|
+
disableScript?: () => void;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* LinkedIn Insight Tag vendor manifest.
|
|
26
|
+
*
|
|
27
|
+
* Sets up the LinkedIn partner ID globals and loads the Insight Tag script
|
|
28
|
+
* via structured startup steps.
|
|
29
|
+
*/
|
|
30
|
+
export declare const linkedinInsightsManifest: {
|
|
31
|
+
readonly kind: "c15t.vendor-manifest";
|
|
32
|
+
readonly schemaVersion: 1;
|
|
33
|
+
readonly vendor: 'linkedin-insights';
|
|
34
|
+
readonly category: 'marketing';
|
|
35
|
+
readonly install: [{
|
|
36
|
+
readonly type: 'setGlobal';
|
|
37
|
+
readonly name: '_linkedin_partner_id';
|
|
38
|
+
readonly value: '{{id}}';
|
|
39
|
+
readonly ifUndefined: false;
|
|
40
|
+
}, {
|
|
41
|
+
readonly type: 'setGlobal';
|
|
42
|
+
readonly name: '_linkedin_data_partner_ids';
|
|
43
|
+
readonly value: readonly [];
|
|
44
|
+
readonly ifUndefined: true;
|
|
45
|
+
}, {
|
|
46
|
+
readonly type: 'pushToQueue';
|
|
47
|
+
readonly queue: '_linkedin_data_partner_ids';
|
|
48
|
+
readonly value: '{{id}}';
|
|
49
|
+
}, {
|
|
50
|
+
readonly type: 'defineStubFunction';
|
|
51
|
+
readonly name: 'lintrk';
|
|
52
|
+
readonly queue: {
|
|
53
|
+
readonly property: 'q';
|
|
54
|
+
};
|
|
55
|
+
readonly queueFormat: 'array';
|
|
56
|
+
readonly ifUndefined: true;
|
|
57
|
+
}, {
|
|
58
|
+
readonly type: 'loadScript';
|
|
59
|
+
readonly src: '{{scriptSrc}}';
|
|
60
|
+
readonly async: true;
|
|
61
|
+
}];
|
|
62
|
+
};
|
|
63
|
+
export interface LinkedInInsightsOptions {
|
|
64
|
+
/**
|
|
65
|
+
* Your LinkedIn Insight Tag partner ID.
|
|
66
|
+
*
|
|
67
|
+
* LinkedIn shows this in Campaign Manager under Data -> Signals manager ->
|
|
68
|
+
* Insight Tag.
|
|
69
|
+
*
|
|
70
|
+
* @example `123456789012345`
|
|
71
|
+
*/
|
|
72
|
+
id: string;
|
|
73
|
+
/** LinkedIn Insight Tag loader URL. */
|
|
74
|
+
scriptSrc?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* LinkedIn Insight Tag script.
|
|
78
|
+
*
|
|
79
|
+
* @param options - The options for the LinkedIn Insight Tag script.
|
|
80
|
+
* @returns The LinkedIn Insight Tag script configuration.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const linkedinInsightsScript = linkedinInsights({
|
|
85
|
+
* id: '123456789012345',
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @see {@link https://www.linkedin.com/help/lms/answer/a418880} Add the LinkedIn Insight Tag to your website
|
|
90
|
+
*/
|
|
91
|
+
export declare function linkedinInsights({ id, scriptSrc, }: LinkedInInsightsOptions): Script;
|
|
92
|
+
export {};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the `contents` array object property.
|
|
4
|
+
*/
|
|
5
|
+
export interface FbqContent {
|
|
6
|
+
id: string | number;
|
|
7
|
+
quantity: number;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Base interface for all possible event parameters.
|
|
12
|
+
* All properties are optional here; specific event types will make them required.
|
|
13
|
+
*/
|
|
14
|
+
export interface FbqBaseEventParams {
|
|
15
|
+
content_category?: string;
|
|
16
|
+
content_ids?: (string | number)[];
|
|
17
|
+
content_name?: string;
|
|
18
|
+
content_type?: 'product' | 'product_group';
|
|
19
|
+
contents?: FbqContent[];
|
|
20
|
+
currency?: string;
|
|
21
|
+
delivery_category?: 'in_store' | 'curbside' | 'home_delivery';
|
|
22
|
+
num_items?: number;
|
|
23
|
+
predicted_ltv?: number;
|
|
24
|
+
search_string?: string;
|
|
25
|
+
status?: boolean;
|
|
26
|
+
value?: number;
|
|
27
|
+
}
|
|
28
|
+
export type FbqCustomParams = Record<string, unknown>;
|
|
29
|
+
type WithCustomParams<TParams> = TParams & FbqCustomParams;
|
|
30
|
+
type AddPaymentInfoParams = WithCustomParams<Pick<FbqBaseEventParams, 'content_ids' | 'contents' | 'currency' | 'value'>>;
|
|
31
|
+
type AddToCartParams = WithCustomParams<Pick<FbqBaseEventParams, 'content_ids' | 'content_type' | 'contents' | 'currency' | 'value'>>;
|
|
32
|
+
type AddToWishlistParams = WithCustomParams<Pick<FbqBaseEventParams, 'content_ids' | 'contents' | 'currency' | 'value'>>;
|
|
33
|
+
type CompleteRegistrationParams = WithCustomParams<Pick<FbqBaseEventParams, 'currency' | 'value' | 'status'>>;
|
|
34
|
+
type InitiateCheckoutParams = WithCustomParams<Pick<FbqBaseEventParams, 'content_ids' | 'contents' | 'currency' | 'num_items' | 'value'>>;
|
|
35
|
+
type LeadParams = WithCustomParams<Pick<FbqBaseEventParams, 'currency' | 'value'>>;
|
|
36
|
+
type PageViewParams = FbqCustomParams;
|
|
37
|
+
type SearchParams = WithCustomParams<Pick<FbqBaseEventParams, 'content_ids' | 'content_type' | 'contents' | 'currency' | 'search_string' | 'value'>>;
|
|
38
|
+
type StartTrialParams = WithCustomParams<Pick<FbqBaseEventParams, 'currency' | 'predicted_ltv' | 'value'>>;
|
|
39
|
+
type SubscribeParams = WithCustomParams<Pick<FbqBaseEventParams, 'currency' | 'predicted_ltv' | 'value'>>;
|
|
40
|
+
type ViewContentParams = WithCustomParams<Pick<FbqBaseEventParams, 'content_ids' | 'content_type' | 'contents' | 'currency' | 'value'>>;
|
|
41
|
+
/**
|
|
42
|
+
* The 'Purchase' event has required properties.
|
|
43
|
+
* We use TypeScript's utility types to enforce this.
|
|
44
|
+
*/
|
|
45
|
+
type PurchaseParams = WithCustomParams<Pick<FbqBaseEventParams, 'content_ids' | 'content_type' | 'contents' | 'num_items'> & Required<Pick<FbqBaseEventParams, 'currency' | 'value'>>>;
|
|
46
|
+
/**
|
|
47
|
+
* Events with no specific properties listed can accept any of the base parameters.
|
|
48
|
+
*/
|
|
49
|
+
type ContactParams = WithCustomParams<FbqBaseEventParams>;
|
|
50
|
+
type CustomizeProductParams = WithCustomParams<FbqBaseEventParams>;
|
|
51
|
+
type DonateParams = WithCustomParams<FbqBaseEventParams>;
|
|
52
|
+
type FindLocationParams = WithCustomParams<FbqBaseEventParams>;
|
|
53
|
+
type ScheduleParams = WithCustomParams<FbqBaseEventParams>;
|
|
54
|
+
type SubmitApplicationParams = WithCustomParams<FbqBaseEventParams>;
|
|
55
|
+
/**
|
|
56
|
+
* A mapping of Standard Event names to their corresponding parameter types.
|
|
57
|
+
* This is the core of our type-safety mechanism.
|
|
58
|
+
*/
|
|
59
|
+
export interface StandardEventParams {
|
|
60
|
+
AddPaymentInfo: AddPaymentInfoParams;
|
|
61
|
+
AddToCart: AddToCartParams;
|
|
62
|
+
AddToWishlist: AddToWishlistParams;
|
|
63
|
+
CompleteRegistration: CompleteRegistrationParams;
|
|
64
|
+
Contact: ContactParams;
|
|
65
|
+
CustomizeProduct: CustomizeProductParams;
|
|
66
|
+
Donate: DonateParams;
|
|
67
|
+
FindLocation: FindLocationParams;
|
|
68
|
+
InitiateCheckout: InitiateCheckoutParams;
|
|
69
|
+
Lead: LeadParams;
|
|
70
|
+
PageView: PageViewParams;
|
|
71
|
+
Purchase: PurchaseParams;
|
|
72
|
+
Schedule: ScheduleParams;
|
|
73
|
+
Search: SearchParams;
|
|
74
|
+
StartTrial: StartTrialParams;
|
|
75
|
+
SubmitApplication: SubmitApplicationParams;
|
|
76
|
+
Subscribe: SubscribeParams;
|
|
77
|
+
ViewContent: ViewContentParams;
|
|
78
|
+
}
|
|
79
|
+
export type StandardEventName = keyof StandardEventParams;
|
|
80
|
+
export interface MetaPixelEventOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Event ID used to deduplicate browser events against Conversions API events.
|
|
83
|
+
*
|
|
84
|
+
* @see https://developers.facebook.com/docs/marketing-api/conversions-api/deduplicate-pixel-and-server-events
|
|
85
|
+
*/
|
|
86
|
+
eventID?: string;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
export interface MetaPixelDataProcessingOptions {
|
|
90
|
+
/**
|
|
91
|
+
* Data processing flags sent to Meta before `init`.
|
|
92
|
+
*
|
|
93
|
+
* Use `['LDU']` to enable Limited Data Use, or `[]` to explicitly disable it.
|
|
94
|
+
*/
|
|
95
|
+
options: 'LDU'[] | [];
|
|
96
|
+
/**
|
|
97
|
+
* Meta country code. Use `0` to let Meta geolocate the event or `1` for USA.
|
|
98
|
+
*/
|
|
99
|
+
country?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Meta state code. Use `0` to let Meta geolocate the event.
|
|
102
|
+
*
|
|
103
|
+
* @example `1000` for California
|
|
104
|
+
*/
|
|
105
|
+
state?: number;
|
|
106
|
+
}
|
|
107
|
+
declare global {
|
|
108
|
+
interface Window {
|
|
109
|
+
fbq: {
|
|
110
|
+
(command: 'dataProcessingOptions', options: MetaPixelDataProcessingOptions['options'], country?: number, state?: number): void;
|
|
111
|
+
(command: 'init', pixelId: string, options?: Record<string, unknown>): void;
|
|
112
|
+
(command: 'track', eventName: StandardEventName, params?: StandardEventParams[StandardEventName], options?: MetaPixelEventOptions): void;
|
|
113
|
+
(command: 'trackCustom', eventName: string, params?: FbqCustomParams, options?: MetaPixelEventOptions): void;
|
|
114
|
+
(command: 'trackSingle', pixelId: string, eventName: StandardEventName, params?: StandardEventParams[StandardEventName], options?: MetaPixelEventOptions): void;
|
|
115
|
+
(command: 'trackSingleCustom', pixelId: string, eventName: string, params?: FbqCustomParams, options?: MetaPixelEventOptions): void;
|
|
116
|
+
(command: 'consent', action: 'grant' | 'revoke'): void;
|
|
117
|
+
(...args: unknown[]): void;
|
|
118
|
+
};
|
|
119
|
+
_fbq: Window['fbq'];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Meta Pixel vendor manifest.
|
|
124
|
+
*
|
|
125
|
+
* The Meta Pixel uses structured bootstrap steps to define the standard `fbq`
|
|
126
|
+
* stub and provides a consent API via `fbq('consent', 'grant'|'revoke')`.
|
|
127
|
+
*/
|
|
128
|
+
export declare const metaPixelManifest: {
|
|
129
|
+
readonly kind: "c15t.vendor-manifest";
|
|
130
|
+
readonly schemaVersion: 1;
|
|
131
|
+
readonly vendor: 'meta-pixel';
|
|
132
|
+
readonly category: 'marketing';
|
|
133
|
+
readonly persistAfterConsentRevoked: true;
|
|
134
|
+
readonly bootstrap: [{
|
|
135
|
+
readonly type: 'defineStubFunction';
|
|
136
|
+
readonly name: 'fbq';
|
|
137
|
+
readonly queue: {
|
|
138
|
+
readonly property: 'queue';
|
|
139
|
+
};
|
|
140
|
+
readonly dispatchProperty: 'callMethod';
|
|
141
|
+
readonly selfReferences: ["push"];
|
|
142
|
+
readonly aliases: ["_fbq"];
|
|
143
|
+
readonly properties: {
|
|
144
|
+
readonly loaded: true;
|
|
145
|
+
readonly version: '2.0';
|
|
146
|
+
};
|
|
147
|
+
readonly ifUndefined: true;
|
|
148
|
+
}];
|
|
149
|
+
readonly install: [{
|
|
150
|
+
readonly type: 'callGlobal';
|
|
151
|
+
readonly global: 'fbq';
|
|
152
|
+
readonly args: ["consent", "grant"];
|
|
153
|
+
}, {
|
|
154
|
+
readonly type: 'callGlobal';
|
|
155
|
+
readonly global: 'fbq';
|
|
156
|
+
readonly args: ["init", "{{pixelId}}"];
|
|
157
|
+
}, {
|
|
158
|
+
readonly type: 'callGlobal';
|
|
159
|
+
readonly global: 'fbq';
|
|
160
|
+
readonly args: ["track", "PageView"];
|
|
161
|
+
}, {
|
|
162
|
+
readonly type: 'loadScript';
|
|
163
|
+
readonly src: '{{scriptSrc}}';
|
|
164
|
+
readonly async: true;
|
|
165
|
+
}];
|
|
166
|
+
readonly onConsentGranted: [{
|
|
167
|
+
readonly type: 'callGlobal';
|
|
168
|
+
readonly global: 'fbq';
|
|
169
|
+
readonly args: ["consent", "grant"];
|
|
170
|
+
}];
|
|
171
|
+
readonly onConsentDenied: [{
|
|
172
|
+
readonly type: 'callGlobal';
|
|
173
|
+
readonly global: 'fbq';
|
|
174
|
+
readonly args: ["consent", "revoke"];
|
|
175
|
+
}];
|
|
176
|
+
};
|
|
177
|
+
export interface MetaPixelOptions {
|
|
178
|
+
/**
|
|
179
|
+
* Your Meta Pixel ID
|
|
180
|
+
* @example `123456789012345`
|
|
181
|
+
*/
|
|
182
|
+
pixelId: string;
|
|
183
|
+
/** Optional payload passed as the third argument to `fbq('init', ...)`. */
|
|
184
|
+
initOptions?: Record<string, unknown>;
|
|
185
|
+
/**
|
|
186
|
+
* Queue the default `PageView` event during setup.
|
|
187
|
+
*
|
|
188
|
+
* @default true
|
|
189
|
+
*/
|
|
190
|
+
trackPageView?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Optional Meta data processing options, such as Limited Data Use.
|
|
193
|
+
*
|
|
194
|
+
* When provided, c15t queues `fbq('dataProcessingOptions', ...)` before
|
|
195
|
+
* `fbq('init', ...)`.
|
|
196
|
+
*/
|
|
197
|
+
dataProcessingOptions?: MetaPixelDataProcessingOptions;
|
|
198
|
+
/** Meta Pixel loader URL. */
|
|
199
|
+
scriptSrc?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Creates a Meta Pixel script.
|
|
203
|
+
*
|
|
204
|
+
* The manifest defines a structured `fbq` stub plus the external loader URL,
|
|
205
|
+
* avoiding raw inline vendor snippets in the manifest payload.
|
|
206
|
+
*
|
|
207
|
+
* @param options - The options for the Meta Pixel script
|
|
208
|
+
* @returns The Meta Pixel script configuration
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* const metaPixelScript = metaPixel({
|
|
213
|
+
* pixelId: '123456789012345',
|
|
214
|
+
* });
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @see {@link https://developers.facebook.com/docs/meta-pixel/get-started} Meta Pixel documentation
|
|
218
|
+
*/
|
|
219
|
+
export declare function metaPixel({ pixelId, initOptions, trackPageView, dataProcessingOptions, scriptSrc, }: MetaPixelOptions): Script;
|
|
220
|
+
/**
|
|
221
|
+
* Tracks a Meta Pixel standard event.
|
|
222
|
+
*
|
|
223
|
+
* This is a wrapper around `fbq('track', ...)`.
|
|
224
|
+
*
|
|
225
|
+
* @template TEventName - The Meta `StandardEventName` being tracked.
|
|
226
|
+
* @param eventName - The `StandardEventName` to track.
|
|
227
|
+
* @param params - Optional `StandardEventParams[TEventName]` payload.
|
|
228
|
+
* @param eventOptions - Optional `MetaPixelEventOptions` or event ID string.
|
|
229
|
+
* @returns `void`; calls `window.fbq`.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* metaPixelEvent('Purchase', { value: 10.0, currency: 'USD' }, 'event-123');
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* @see {@link https://developers.facebook.com/docs/meta-pixel/reference} Meta Pixel documentation
|
|
237
|
+
*/
|
|
238
|
+
export declare const metaPixelEvent: <TEventName extends StandardEventName>(eventName: TEventName, params?: StandardEventParams[TEventName], eventOptions?: MetaPixelEventOptions | string) => void;
|
|
239
|
+
/**
|
|
240
|
+
* Tracks a Meta Pixel custom event with optional custom parameters.
|
|
241
|
+
*
|
|
242
|
+
* @param eventName - The custom event name to track
|
|
243
|
+
* @param params - Optional custom parameters to track
|
|
244
|
+
* @param eventOptions - Optional event options, including Conversions API eventID
|
|
245
|
+
*/
|
|
246
|
+
export declare const metaPixelCustomEvent: (eventName: string, params?: FbqCustomParams, eventOptions?: MetaPixelEventOptions | string) => void;
|
|
247
|
+
/**
|
|
248
|
+
* Tracks a standard event for a single Meta Pixel ID.
|
|
249
|
+
*
|
|
250
|
+
* Use this when multiple Meta Pixels are initialized on the same page and the
|
|
251
|
+
* event should not fire for every initialized pixel.
|
|
252
|
+
*
|
|
253
|
+
* @template TEventName - The Meta `StandardEventName` being tracked.
|
|
254
|
+
* @param pixelId - Meta Pixel ID that should receive the event.
|
|
255
|
+
* @param eventName - The `StandardEventName` to track.
|
|
256
|
+
* @param params - Optional `StandardEventParams[TEventName]` payload.
|
|
257
|
+
* @param eventOptions - Optional `MetaPixelEventOptions` or event ID string.
|
|
258
|
+
* @returns `void`; calls `window.fbq`.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* metaPixelSingleEvent(
|
|
263
|
+
* '123456',
|
|
264
|
+
* 'Purchase',
|
|
265
|
+
* { value: 9.99, currency: 'USD' },
|
|
266
|
+
* 'event-123'
|
|
267
|
+
* );
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export declare const metaPixelSingleEvent: <TEventName extends StandardEventName>(pixelId: string, eventName: TEventName, params?: StandardEventParams[TEventName], eventOptions?: MetaPixelEventOptions | string) => void;
|
|
271
|
+
/**
|
|
272
|
+
* Tracks a custom event for a single Meta Pixel ID.
|
|
273
|
+
*
|
|
274
|
+
* Use this when multiple Meta Pixels are initialized on the same page and the
|
|
275
|
+
* custom event should not fire for every initialized pixel.
|
|
276
|
+
*
|
|
277
|
+
* @param pixelId - Meta Pixel ID that should receive the custom event.
|
|
278
|
+
* @param eventName - Custom event name to track.
|
|
279
|
+
* @param params - Optional `FbqCustomParams` payload.
|
|
280
|
+
* @param eventOptions - Optional `MetaPixelEventOptions` or event ID string.
|
|
281
|
+
* @returns `void`; calls `window.fbq`.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* metaPixelSingleCustomEvent('123456', 'MyCustomEvent', { foo: 'bar' });
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
export declare const metaPixelSingleCustomEvent: (pixelId: string, eventName: string, params?: FbqCustomParams, eventOptions?: MetaPixelEventOptions | string) => void;
|
|
289
|
+
export {};
|