@c15t/scripts 2.0.1 → 2.1.0
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/README.md +9 -9
- package/dist/engine/runtime.cjs +11 -0
- package/dist/engine/runtime.js +11 -0
- package/dist/registry.cjs +338 -0
- package/dist/registry.js +292 -0
- package/dist/types.cjs +18 -0
- package/dist/types.js +10 -1
- package/dist/vendors/_shared/attributes.cjs +51 -0
- package/dist/vendors/_shared/attributes.js +14 -0
- package/dist/vendors/_shared/google-consent.cjs +64 -0
- package/dist/vendors/_shared/google-consent.js +27 -0
- package/dist/vendors/_shared/install-builders.cjs +55 -0
- package/dist/vendors/_shared/install-builders.js +21 -0
- package/dist/vendors/_shared/script-url.cjs +74 -0
- package/dist/vendors/_shared/script-url.js +28 -0
- package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +2 -2
- package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +202 -0
- package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
- package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +31 -14
- package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +147 -0
- package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +127 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
- package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +2 -2
- 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} +6 -3
- package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
- package/dist/vendors/analytics/ahrefs-analytics.cjs +64 -0
- package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.cjs +69 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
- package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +3 -3
- package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
- package/dist/vendors/analytics/fathom-analytics.cjs +72 -0
- package/dist/vendors/analytics/fathom-analytics.js +35 -0
- package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +7 -28
- package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
- package/dist/vendors/analytics/hotjar.cjs +81 -0
- package/dist/vendors/analytics/hotjar.js +44 -0
- package/dist/vendors/analytics/matomo-analytics.cjs +228 -0
- package/dist/vendors/analytics/matomo-analytics.js +191 -0
- package/dist/vendors/analytics/microsoft-clarity.cjs +110 -0
- package/dist/vendors/analytics/microsoft-clarity.js +73 -0
- package/dist/vendors/analytics/mixpanel-analytics.cjs +119 -0
- package/dist/vendors/analytics/mixpanel-analytics.js +82 -0
- package/dist/vendors/analytics/plausible-analytics.cjs +118 -0
- package/dist/vendors/analytics/plausible-analytics.js +81 -0
- package/dist/{posthog.cjs → vendors/analytics/posthog.cjs} +69 -6
- package/dist/vendors/analytics/posthog.js +163 -0
- package/dist/vendors/analytics/promptwatch.cjs +66 -0
- package/dist/vendors/analytics/promptwatch.js +29 -0
- package/dist/vendors/analytics/rybbit-analytics.cjs +100 -0
- package/dist/vendors/analytics/rybbit-analytics.js +63 -0
- package/dist/vendors/analytics/segment.cjs +93 -0
- package/dist/vendors/analytics/segment.js +56 -0
- package/dist/vendors/analytics/umami-analytics.cjs +76 -0
- package/dist/vendors/analytics/umami-analytics.js +39 -0
- package/dist/vendors/analytics/vercel-analytics.cjs +90 -0
- package/dist/vendors/analytics/vercel-analytics.js +53 -0
- package/dist/vendors/functional/crisp.cjs +139 -0
- package/dist/vendors/functional/crisp.js +102 -0
- package/dist/vendors/functional/intercom.cjs +85 -0
- package/dist/vendors/functional/intercom.js +45 -0
- package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +6 -27
- 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 +368 -0
- package/dist-types/types.d.ts +13 -0
- 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/{linkedin-insights.d.ts → vendors/ads-and-pixels/linkedin-insights.d.ts} +22 -9
- 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} +21 -10
- 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} +20 -5
- package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +21 -4
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
- package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
- package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +5 -8
- package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +86 -0
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +101 -0
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
- package/dist-types/{posthog.d.ts → vendors/analytics/posthog.d.ts} +47 -5
- package/dist-types/vendors/analytics/promptwatch.d.ts +36 -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} +5 -8
- package/package.json +165 -4
- package/dist/meta-pixel.cjs +0 -129
- package/dist/meta-pixel.js +0 -89
- package/dist/posthog.js +0 -100
- package/dist-types/meta-pixel.d.ts +0 -185
- /package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
export type SnapchatPixelEventName = 'PAGE_VIEW' | 'VIEW_CONTENT' | 'ADD_CART' | 'PURCHASE' | 'SIGN_UP' | 'SAVE' | 'START_CHECKOUT' | 'APP_OPEN' | 'ADD_BILLING' | 'SEARCH' | 'SUBSCRIBE' | 'AD_CLICK' | 'AD_VIEW' | 'COMPLETE_TUTORIAL' | 'LEVEL_COMPLETE' | 'INVITE' | 'LOGIN' | 'SHARE' | 'RESERVE' | 'ACHIEVEMENT_UNLOCKED' | 'ADD_TO_WISHLIST' | 'SPENT_CREDITS' | 'RATE' | 'START_TRIAL' | 'LIST_VIEW';
|
|
3
|
+
export interface SnapchatPixelEventProperties {
|
|
4
|
+
/** Total monetary value for commerce events such as `PURCHASE`. */
|
|
5
|
+
price?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Event identifier used to deduplicate browser Pixel events against
|
|
8
|
+
* server-side Conversions API events.
|
|
9
|
+
*/
|
|
10
|
+
client_dedup_id?: string;
|
|
11
|
+
/** ISO 4217 currency code, for example `USD`. */
|
|
12
|
+
currency?: string;
|
|
13
|
+
/** Transaction/order identifier for purchase events. */
|
|
14
|
+
transaction_id?: string;
|
|
15
|
+
/** Product, SKU, or content identifiers associated with the event. */
|
|
16
|
+
item_ids?: string[];
|
|
17
|
+
/** Product or content category associated with the event. */
|
|
18
|
+
item_category?: string;
|
|
19
|
+
/** Free-form description for the event. */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Query text for `SEARCH` events. */
|
|
22
|
+
search_string?: string;
|
|
23
|
+
/** Number of items represented by the event. */
|
|
24
|
+
number_items?: number;
|
|
25
|
+
/** Whether payment information was available, represented as `0` or `1`. */
|
|
26
|
+
payment_info_available?: 0 | 1;
|
|
27
|
+
/** Signup method for `SIGN_UP` events. */
|
|
28
|
+
sign_up_method?: string;
|
|
29
|
+
/** Whether the action succeeded, represented as `0` or `1`. */
|
|
30
|
+
success?: 0 | 1;
|
|
31
|
+
/** Brand names associated with the event contents. */
|
|
32
|
+
brands?: string[];
|
|
33
|
+
/** Fulfillment method for commerce events. */
|
|
34
|
+
delivery_method?: 'in_store' | 'curbside' | 'delivery';
|
|
35
|
+
/** Customer lifecycle status associated with the event. */
|
|
36
|
+
customer_status?: 'new' | 'returning' | 'reactivated';
|
|
37
|
+
/** Optional custom tag for event segmentation in Snapchat. */
|
|
38
|
+
event_tag?: string;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
type SnapchatPixelFunction = {
|
|
42
|
+
(command: 'track', eventName: SnapchatPixelEventName | (string & {}), properties?: SnapchatPixelEventProperties): void;
|
|
43
|
+
(command: 'init', pixelId: string, config?: Record<string, unknown>): void;
|
|
44
|
+
(command: string, ...args: unknown[]): void;
|
|
45
|
+
};
|
|
46
|
+
declare global {
|
|
47
|
+
interface Window {
|
|
48
|
+
snaptr?: SnapchatPixelFunction & {
|
|
49
|
+
handleRequest?: (...args: unknown[]) => void;
|
|
50
|
+
loaded?: boolean;
|
|
51
|
+
push?: Window['snaptr'];
|
|
52
|
+
queue?: unknown[][];
|
|
53
|
+
version?: string;
|
|
54
|
+
};
|
|
55
|
+
_snaptr?: Window['snaptr'];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Snapchat Pixel vendor manifest.
|
|
60
|
+
*
|
|
61
|
+
* Uses a structured queue stub and queues `init` plus an optional
|
|
62
|
+
* `PAGE_VIEW` event before the vendor bundle loads.
|
|
63
|
+
*/
|
|
64
|
+
export declare const snapchatPixelManifest: {
|
|
65
|
+
readonly vendor: "snapchat-pixel";
|
|
66
|
+
readonly category: "marketing";
|
|
67
|
+
readonly bootstrap: [{
|
|
68
|
+
readonly type: "defineStubFunction";
|
|
69
|
+
readonly name: "snaptr";
|
|
70
|
+
readonly queue: {
|
|
71
|
+
readonly property: "queue";
|
|
72
|
+
};
|
|
73
|
+
readonly dispatchProperty: "handleRequest";
|
|
74
|
+
readonly queueFormat: "array";
|
|
75
|
+
readonly aliases: ["_snaptr"];
|
|
76
|
+
readonly selfReferences: ["push"];
|
|
77
|
+
readonly properties: {
|
|
78
|
+
readonly loaded: true;
|
|
79
|
+
readonly version: "1.0";
|
|
80
|
+
};
|
|
81
|
+
readonly ifUndefined: true;
|
|
82
|
+
}];
|
|
83
|
+
readonly install: [{
|
|
84
|
+
readonly type: "callGlobal";
|
|
85
|
+
readonly global: "snaptr";
|
|
86
|
+
readonly args: ["init", "{{pixelId}}"];
|
|
87
|
+
}, {
|
|
88
|
+
readonly type: "callGlobal";
|
|
89
|
+
readonly global: "snaptr";
|
|
90
|
+
readonly args: ["track", "PAGE_VIEW"];
|
|
91
|
+
}, {
|
|
92
|
+
readonly type: "loadScript";
|
|
93
|
+
readonly src: "{{scriptUrl}}";
|
|
94
|
+
readonly async: true;
|
|
95
|
+
}];
|
|
96
|
+
readonly kind: "c15t.vendor-manifest";
|
|
97
|
+
readonly schemaVersion: 1;
|
|
98
|
+
};
|
|
99
|
+
export interface SnapchatPixelOptions {
|
|
100
|
+
/**
|
|
101
|
+
* Your Snapchat Pixel ID.
|
|
102
|
+
* @example `123456789012345`
|
|
103
|
+
*/
|
|
104
|
+
pixelId: string;
|
|
105
|
+
/** Optional init payload passed to `snaptr('init', ...)`. */
|
|
106
|
+
initOptions?: Record<string, unknown>;
|
|
107
|
+
/**
|
|
108
|
+
* Queue the default `PAGE_VIEW` event during setup.
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
trackPageView?: boolean;
|
|
112
|
+
/** Snapchat Pixel loader URL. */
|
|
113
|
+
scriptUrl?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates a Snapchat Pixel script.
|
|
117
|
+
*
|
|
118
|
+
* @param options.pixelId - Snapchat Pixel ID used in `snaptr('init', ...)`.
|
|
119
|
+
* Expected format is a numeric string (commonly 15 digits), for example
|
|
120
|
+
* `'123456789012345'`. This value is required and should come directly from
|
|
121
|
+
* Snapchat Ads Manager.
|
|
122
|
+
* @param options.initOptions - Optional object passed as the third argument to
|
|
123
|
+
* `snaptr('init', pixelId, initOptions)`, for advanced initialization values.
|
|
124
|
+
* Example: `{ user_email: 'user@example.com', user_phone_number: '+15551234567' }`.
|
|
125
|
+
* @param options.trackPageView - Whether to queue the default
|
|
126
|
+
* `snaptr('track', 'PAGE_VIEW')` call during setup. Defaults to `true`; set to
|
|
127
|
+
* `false` when you want to control page-view tracking manually.
|
|
128
|
+
* @returns A resolved c15t `Script` configuration that defines the Snapchat
|
|
129
|
+
* queue stub, runs `init` (and optionally `PAGE_VIEW`), and then loads the
|
|
130
|
+
* Snapchat SDK script URL.
|
|
131
|
+
* @throws `resolveManifest` may throw when required placeholders cannot be
|
|
132
|
+
* resolved (for example, when `pixelId` is missing/empty) or when provided
|
|
133
|
+
* manifest values are invalid for interpolation.
|
|
134
|
+
*
|
|
135
|
+
* Edge cases:
|
|
136
|
+
* - Missing `pixelId` causes manifest resolution to fail.
|
|
137
|
+
* - Non-numeric or malformed `pixelId` values may initialize incorrectly in
|
|
138
|
+
* Snapchat even if local script construction succeeds.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const script = snapchatPixel({
|
|
143
|
+
* pixelId: '123456789012345',
|
|
144
|
+
* initOptions: {
|
|
145
|
+
* user_email: 'user@example.com',
|
|
146
|
+
* user_phone_number: '+15551234567',
|
|
147
|
+
* },
|
|
148
|
+
* trackPageView: false,
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function snapchatPixel({ pixelId, initOptions, trackPageView, scriptUrl, }: SnapchatPixelOptions): Script;
|
|
153
|
+
/**
|
|
154
|
+
* Tracks a Snapchat Pixel event.
|
|
155
|
+
*
|
|
156
|
+
* @param eventName - Snapchat standard event name or a custom event name.
|
|
157
|
+
* @param properties - Optional event properties, including
|
|
158
|
+
* `client_dedup_id` for Pixel plus Conversions API deduplication.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* snapchatPixelEvent('PURCHASE', {
|
|
163
|
+
* price: 99,
|
|
164
|
+
* currency: 'USD',
|
|
165
|
+
* transaction_id: 'order-123',
|
|
166
|
+
* client_dedup_id: 'event-123',
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export declare const snapchatPixelEvent: (eventName: SnapchatPixelEventName | (string & {}), properties?: SnapchatPixelEventProperties) => void;
|
|
171
|
+
export {};
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import type { Script } from 'c15t';
|
|
2
|
+
interface TikTokPixelFunction {
|
|
3
|
+
grantConsent: () => void;
|
|
4
|
+
revokeConsent: () => void;
|
|
5
|
+
page: () => void;
|
|
6
|
+
track: (eventName: string, properties?: Record<string, unknown>) => void;
|
|
7
|
+
identify: (properties?: Record<string, unknown>) => void;
|
|
8
|
+
instances: (...args: unknown[]) => void;
|
|
9
|
+
debug: (...args: unknown[]) => void;
|
|
10
|
+
on: (...args: unknown[]) => void;
|
|
11
|
+
off: (...args: unknown[]) => void;
|
|
12
|
+
once: (...args: unknown[]) => void;
|
|
13
|
+
ready: (...args: unknown[]) => void;
|
|
14
|
+
alias: (...args: unknown[]) => void;
|
|
15
|
+
group: (...args: unknown[]) => void;
|
|
16
|
+
enableCookie: (...args: unknown[]) => void;
|
|
17
|
+
disableCookie: (...args: unknown[]) => void;
|
|
18
|
+
holdConsent: (...args: unknown[]) => void;
|
|
19
|
+
}
|
|
2
20
|
declare global {
|
|
3
21
|
interface Window {
|
|
4
|
-
ttq:
|
|
5
|
-
grantConsent: () => void;
|
|
6
|
-
revokeConsent: () => void;
|
|
7
|
-
page: () => void;
|
|
8
|
-
};
|
|
22
|
+
ttq: TikTokPixelFunction;
|
|
9
23
|
}
|
|
10
24
|
}
|
|
11
25
|
/**
|
|
@@ -89,3 +103,4 @@ export interface TikTokPixelOptions {
|
|
|
89
103
|
* @see {@link https://ads.tiktok.com/help/article/tiktok-pixel} TikTok Pixel documentation
|
|
90
104
|
*/
|
|
91
105
|
export declare function tiktokPixel({ pixelId, scriptSrc, }: TikTokPixelOptions): Script;
|
|
106
|
+
export {};
|
|
@@ -69,9 +69,23 @@ export interface XPixelEvent {
|
|
|
69
69
|
twclid?: string;
|
|
70
70
|
/**
|
|
71
71
|
* Status of the conversion event
|
|
72
|
-
*
|
|
72
|
+
* Should be set to values like "started" or "completed".
|
|
73
|
+
* @example "completed"
|
|
73
74
|
*/
|
|
74
|
-
status?:
|
|
75
|
+
status?: 'started' | 'completed';
|
|
76
|
+
/**
|
|
77
|
+
* Email address used for user matching.
|
|
78
|
+
* The X Pixel hashes this value before transmission.
|
|
79
|
+
* @example "[email protected]"
|
|
80
|
+
*/
|
|
81
|
+
email_address?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Phone number used for user matching.
|
|
84
|
+
* Include country code in E.164 format (for example, +11234567890).
|
|
85
|
+
* The X Pixel hashes this value before transmission.
|
|
86
|
+
* @example "+11234567890"
|
|
87
|
+
*/
|
|
88
|
+
phone_number?: string;
|
|
75
89
|
/**
|
|
76
90
|
* Content/products associated with the conversion event
|
|
77
91
|
* @example [{content_id: 'OT001', content_name: 'bird seed', content_price: 50, num_items: 1}]
|
|
@@ -141,7 +155,7 @@ export interface XPixelOptions {
|
|
|
141
155
|
* });
|
|
142
156
|
* ```
|
|
143
157
|
*
|
|
144
|
-
* @see {@link https://
|
|
158
|
+
* @see {@link https://business.x.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites} X conversion tracking documentation
|
|
145
159
|
*/
|
|
146
160
|
export declare function xPixel({ pixelId, scriptSrc }: XPixelOptions): Script;
|
|
147
161
|
/**
|
|
@@ -162,5 +176,8 @@ export declare function xPixel({ pixelId, scriptSrc }: XPixelOptions): Script;
|
|
|
162
176
|
* ```
|
|
163
177
|
*
|
|
164
178
|
* @see {@link https://business.x.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites#event-types-and-parameters}
|
|
179
|
+
* @throws {Error} Throws when `window` is unavailable or `window.twq` is not a
|
|
180
|
+
* function. Ensure marketing consent is granted and the X Pixel has loaded
|
|
181
|
+
* before calling this helper.
|
|
165
182
|
*/
|
|
166
|
-
export declare const xPixelEvent: (eventId: string, metadata?: XPixelEvent) => void
|
|
183
|
+
export declare const xPixelEvent: (eventId: string, metadata?: XPixelEvent) => void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
AhrefsAnalytics?: {
|
|
5
|
+
sendEvent: (name: string, options?: {
|
|
6
|
+
props?: Record<string, string>;
|
|
7
|
+
meta?: Record<string, unknown>;
|
|
8
|
+
}) => void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Ahrefs Analytics vendor manifest.
|
|
14
|
+
*
|
|
15
|
+
* Loads Ahrefs Web Analytics and passes the project key via `data-key`. Ahrefs
|
|
16
|
+
* Web Analytics is cookieless, so the script is consent-gated on `measurement`
|
|
17
|
+
* and unloaded when consent is revoked.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ahrefsAnalyticsManifest: {
|
|
20
|
+
readonly vendor: "ahrefs-analytics";
|
|
21
|
+
readonly category: "measurement";
|
|
22
|
+
readonly install: [{
|
|
23
|
+
readonly type: "loadScript";
|
|
24
|
+
readonly src: "{{scriptUrl}}";
|
|
25
|
+
readonly async: true;
|
|
26
|
+
readonly attributes: {
|
|
27
|
+
readonly 'data-key': "{{key}}";
|
|
28
|
+
};
|
|
29
|
+
}];
|
|
30
|
+
readonly kind: "c15t.vendor-manifest";
|
|
31
|
+
readonly schemaVersion: 1;
|
|
32
|
+
};
|
|
33
|
+
export interface AhrefsAnalyticsOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Your Ahrefs Web Analytics project key.
|
|
36
|
+
*/
|
|
37
|
+
key: string;
|
|
38
|
+
/**
|
|
39
|
+
* Custom loader URL.
|
|
40
|
+
* @default 'https://analytics.ahrefs.com/analytics.js'
|
|
41
|
+
*/
|
|
42
|
+
scriptUrl?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates an Ahrefs Analytics script.
|
|
46
|
+
*
|
|
47
|
+
* The Ahrefs SDK exposes its runtime API on `window.AhrefsAnalytics` after
|
|
48
|
+
* load. This helper only models the serializable script manifest.
|
|
49
|
+
*
|
|
50
|
+
* @see https://ahrefs.com/web-analytics
|
|
51
|
+
*
|
|
52
|
+
* @param options - The options for the Ahrefs Analytics script.
|
|
53
|
+
* @returns The Ahrefs Analytics script.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { ahrefsAnalytics } from '@c15t/scripts/ahrefs-analytics';
|
|
58
|
+
*
|
|
59
|
+
* ahrefsAnalytics({ key: 'YOUR_PROJECT_KEY' });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function ahrefsAnalytics(options: AhrefsAnalyticsOptions): Script;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
__cfBeacon?: {
|
|
5
|
+
spa?: boolean;
|
|
6
|
+
token: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Cloudflare Web Analytics vendor manifest.
|
|
12
|
+
*
|
|
13
|
+
* Serializes Cloudflare's beacon config into the `data-cf-beacon` attribute.
|
|
14
|
+
* Cloudflare Web Analytics is cookieless, so the script is consent-gated on
|
|
15
|
+
* `measurement` and unloaded when consent is revoked.
|
|
16
|
+
*/
|
|
17
|
+
export declare const cloudflareWebAnalyticsManifest: {
|
|
18
|
+
readonly vendor: "cloudflare-web-analytics";
|
|
19
|
+
readonly category: "measurement";
|
|
20
|
+
readonly install: [{
|
|
21
|
+
readonly type: "loadScript";
|
|
22
|
+
readonly src: "{{scriptUrl}}";
|
|
23
|
+
readonly defer: true;
|
|
24
|
+
readonly attributes: {
|
|
25
|
+
readonly 'data-cf-beacon': "{{beaconConfig}}";
|
|
26
|
+
};
|
|
27
|
+
}];
|
|
28
|
+
readonly kind: "c15t.vendor-manifest";
|
|
29
|
+
readonly schemaVersion: 1;
|
|
30
|
+
};
|
|
31
|
+
export interface CloudflareWebAnalyticsOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Your Cloudflare Web Analytics token.
|
|
34
|
+
*/
|
|
35
|
+
token: string;
|
|
36
|
+
/**
|
|
37
|
+
* Enable Cloudflare's SPA route tracking.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
spa?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Custom loader URL.
|
|
43
|
+
* @default 'https://static.cloudflareinsights.com/beacon.min.js'
|
|
44
|
+
*/
|
|
45
|
+
scriptUrl?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a Cloudflare Web Analytics script.
|
|
49
|
+
*
|
|
50
|
+
* @see https://developers.cloudflare.com/analytics/web-analytics/get-started/
|
|
51
|
+
*
|
|
52
|
+
* @param options - The options for the Cloudflare Web Analytics script.
|
|
53
|
+
* @returns The Cloudflare Web Analytics script.
|
|
54
|
+
* @throws {Error} Throws `cloudflareWebAnalytics: missing token` when
|
|
55
|
+
* `options.token` is missing, invalid, or trims to an empty string.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { cloudflareWebAnalytics } from '@c15t/scripts/cloudflare-web-analytics';
|
|
60
|
+
*
|
|
61
|
+
* cloudflareWebAnalytics({
|
|
62
|
+
* token: 'abc123...',
|
|
63
|
+
* spa: true,
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function cloudflareWebAnalytics(options: CloudflareWebAnalyticsOptions): Script;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
fathom?: {
|
|
5
|
+
blockTrackingForMe: () => void;
|
|
6
|
+
enableTrackingForMe: () => void;
|
|
7
|
+
trackEvent: (eventName: string, opts?: {
|
|
8
|
+
_value?: number;
|
|
9
|
+
}) => void;
|
|
10
|
+
trackGoal: (goalId: string, cents: number) => void;
|
|
11
|
+
trackPageview: (opts?: {
|
|
12
|
+
url: string;
|
|
13
|
+
referrer?: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Fathom Analytics vendor manifest.
|
|
20
|
+
*
|
|
21
|
+
* Configures Fathom via script `data-*` attributes. Fathom is a cookieless
|
|
22
|
+
* analytics product, so the script is consent-gated on `measurement` and
|
|
23
|
+
* unloaded when consent is revoked.
|
|
24
|
+
*/
|
|
25
|
+
export declare const fathomAnalyticsManifest: {
|
|
26
|
+
readonly vendor: "fathom-analytics";
|
|
27
|
+
readonly category: "measurement";
|
|
28
|
+
readonly install: [{
|
|
29
|
+
readonly type: "loadScript";
|
|
30
|
+
readonly src: "{{scriptUrl}}";
|
|
31
|
+
readonly defer: true;
|
|
32
|
+
readonly attributes: {
|
|
33
|
+
readonly 'data-site': "{{site}}";
|
|
34
|
+
readonly 'data-spa': "{{spa}}";
|
|
35
|
+
readonly 'data-auto': "{{autoAttribute}}";
|
|
36
|
+
readonly 'data-canonical': "{{canonicalAttribute}}";
|
|
37
|
+
readonly 'data-honor-dnt': "{{honorDntAttribute}}";
|
|
38
|
+
};
|
|
39
|
+
}];
|
|
40
|
+
readonly kind: "c15t.vendor-manifest";
|
|
41
|
+
readonly schemaVersion: 1;
|
|
42
|
+
};
|
|
43
|
+
export interface FathomAnalyticsOptions {
|
|
44
|
+
/**
|
|
45
|
+
* Your Fathom Analytics site ID.
|
|
46
|
+
*/
|
|
47
|
+
site: string;
|
|
48
|
+
/**
|
|
49
|
+
* The SPA tracking mode. When undefined, SPA auto-routing is disabled and
|
|
50
|
+
* the `data-spa` attribute is omitted.
|
|
51
|
+
*/
|
|
52
|
+
spa?: 'auto' | 'history' | 'hash';
|
|
53
|
+
/**
|
|
54
|
+
* Automatically track page views.
|
|
55
|
+
*/
|
|
56
|
+
auto?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Enable canonical URL tracking.
|
|
59
|
+
*/
|
|
60
|
+
canonical?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Honor Do Not Track requests.
|
|
63
|
+
*/
|
|
64
|
+
honorDnt?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Custom loader URL.
|
|
67
|
+
* @default 'https://cdn.usefathom.com/script.js'
|
|
68
|
+
*/
|
|
69
|
+
scriptUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Creates a Fathom Analytics script.
|
|
73
|
+
*
|
|
74
|
+
* @see https://usefathom.com/docs/script/script-settings
|
|
75
|
+
*
|
|
76
|
+
* @param options - The options for the Fathom Analytics script.
|
|
77
|
+
* @returns The Fathom Analytics script.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { fathomAnalytics } from '@c15t/scripts/fathom-analytics';
|
|
82
|
+
*
|
|
83
|
+
* fathomAnalytics({
|
|
84
|
+
* site: 'SITE123',
|
|
85
|
+
* spa: 'history',
|
|
86
|
+
* canonical: true,
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function fathomAnalytics(options: FathomAnalyticsOptions): Script;
|
|
@@ -30,7 +30,10 @@ export declare const gtagManifest: {
|
|
|
30
30
|
readonly install: [{
|
|
31
31
|
readonly type: "callGlobal";
|
|
32
32
|
readonly global: "gtag";
|
|
33
|
-
readonly args: ["js",
|
|
33
|
+
readonly args: ["js", {
|
|
34
|
+
readonly kind: "c15t.runtime-value";
|
|
35
|
+
readonly value: "date";
|
|
36
|
+
}];
|
|
34
37
|
}, {
|
|
35
38
|
readonly type: "callGlobal";
|
|
36
39
|
readonly global: "gtag";
|
|
@@ -40,13 +43,7 @@ export declare const gtagManifest: {
|
|
|
40
43
|
readonly src: "https://www.googletagmanager.com/gtag/js?id={{id}}";
|
|
41
44
|
readonly async: true;
|
|
42
45
|
}];
|
|
43
|
-
readonly consentMapping:
|
|
44
|
-
readonly necessary: ["security_storage"];
|
|
45
|
-
readonly functionality: ["functionality_storage"];
|
|
46
|
-
readonly measurement: ["analytics_storage"];
|
|
47
|
-
readonly marketing: ["ad_storage", "ad_user_data", "ad_personalization"];
|
|
48
|
-
readonly experience: ["personalization_storage"];
|
|
49
|
-
};
|
|
46
|
+
readonly consentMapping: Record<string, string[]>;
|
|
50
47
|
readonly consentSignal: "gtag";
|
|
51
48
|
readonly kind: "c15t.vendor-manifest";
|
|
52
49
|
readonly schemaVersion: 1;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
hj?: ((...args: unknown[]) => void) & {
|
|
5
|
+
q?: unknown[][];
|
|
6
|
+
};
|
|
7
|
+
_hjSettings?: {
|
|
8
|
+
hjid: number | string;
|
|
9
|
+
hjsv: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hotjar vendor manifest.
|
|
15
|
+
*
|
|
16
|
+
* Seeds the global Hotjar settings object and queue stub before loading
|
|
17
|
+
* the vendor bundle.
|
|
18
|
+
*/
|
|
19
|
+
export declare const hotjarManifest: {
|
|
20
|
+
readonly vendor: "hotjar";
|
|
21
|
+
readonly category: "measurement";
|
|
22
|
+
readonly install: [{
|
|
23
|
+
readonly type: "setGlobal";
|
|
24
|
+
readonly name: "_hjSettings";
|
|
25
|
+
readonly value: {
|
|
26
|
+
readonly hjid: "{{siteId}}";
|
|
27
|
+
readonly hjsv: "{{version}}";
|
|
28
|
+
};
|
|
29
|
+
readonly ifUndefined: true;
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "defineStubFunction";
|
|
32
|
+
readonly name: "hj";
|
|
33
|
+
readonly queue: {
|
|
34
|
+
readonly property: "q";
|
|
35
|
+
};
|
|
36
|
+
readonly queueFormat: "array";
|
|
37
|
+
readonly ifUndefined: true;
|
|
38
|
+
}, {
|
|
39
|
+
readonly type: "loadScript";
|
|
40
|
+
readonly src: "{{scriptUrl}}";
|
|
41
|
+
readonly async: true;
|
|
42
|
+
}];
|
|
43
|
+
readonly kind: "c15t.vendor-manifest";
|
|
44
|
+
readonly schemaVersion: 1;
|
|
45
|
+
};
|
|
46
|
+
export interface HotjarOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Your Hotjar site ID.
|
|
49
|
+
* @example `1234567`
|
|
50
|
+
*/
|
|
51
|
+
siteId: number | string;
|
|
52
|
+
/**
|
|
53
|
+
* Hotjar script version.
|
|
54
|
+
* @default 6
|
|
55
|
+
*/
|
|
56
|
+
version?: number;
|
|
57
|
+
/** Hotjar loader URL. */
|
|
58
|
+
scriptUrl?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates a Hotjar script.
|
|
62
|
+
*
|
|
63
|
+
* @param options - The options for the Hotjar script.
|
|
64
|
+
* @returns The Hotjar script configuration.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { hotjar } from '@c15t/scripts/hotjar';
|
|
69
|
+
*
|
|
70
|
+
* hotjar({ siteId: 1234567 });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function hotjar({ siteId, version, scriptUrl, }: HotjarOptions): Script;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
import { type VendorManifest } from '../../types';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
_paq?: unknown[];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare const matomoAnalyticsManifest: VendorManifest;
|
|
9
|
+
export interface MatomoAnalyticsOptions {
|
|
10
|
+
/** Your Matomo site ID. */
|
|
11
|
+
siteId?: string | number;
|
|
12
|
+
/** Your Matomo base URL, for example `https://analytics.example.com`. */
|
|
13
|
+
matomoUrl?: string;
|
|
14
|
+
/** Your Matomo Cloud identifier, for example `my-site.matomo.cloud`. */
|
|
15
|
+
cloudId?: string;
|
|
16
|
+
/** Optional explicit tracker endpoint override. */
|
|
17
|
+
trackerUrl?: string;
|
|
18
|
+
/** Optional explicit script URL override. */
|
|
19
|
+
scriptUrl?: string;
|
|
20
|
+
/** Queue `enableLinkTracking`. */
|
|
21
|
+
enableLinkTracking?: boolean;
|
|
22
|
+
/** Queue `disableCookies`. */
|
|
23
|
+
disableCookies?: boolean;
|
|
24
|
+
/** Queue an initial `trackPageView`. */
|
|
25
|
+
trackPageView?: boolean;
|
|
26
|
+
/** Default Matomo consent state (`required` blocks, `given` starts enabled). */
|
|
27
|
+
defaultConsent?: 'required' | 'given';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a Matomo Analytics script.
|
|
31
|
+
*
|
|
32
|
+
* @param options - The options for the Matomo Analytics script.
|
|
33
|
+
* @returns The Matomo Analytics script configuration.
|
|
34
|
+
* @throws {Error} Throws
|
|
35
|
+
* `'matomoAnalytics requires \`matomoUrl\`, \`cloudId\`, or explicit \`trackerUrl\` and \`scriptUrl\` values.'`
|
|
36
|
+
* when either resolved `trackerUrl` or `scriptUrl` is missing (for example,
|
|
37
|
+
* when neither `matomoUrl` nor `cloudId` is provided and explicit
|
|
38
|
+
* `trackerUrl`/`scriptUrl` values are not supplied). Provide `matomoUrl`, or
|
|
39
|
+
* provide both explicit `trackerUrl` and `scriptUrl`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function matomoAnalytics(options?: MatomoAnalyticsOptions): Script;
|