@c15t/scripts 1.0.1 → 1.1.0-rc.1
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/dist/databuddy.cjs +105 -50
- package/dist/databuddy.js +99 -47
- package/dist/engine/compile.cjs +126 -0
- package/dist/engine/compile.js +89 -0
- package/dist/engine/runtime.cjs +379 -0
- package/dist/engine/runtime.js +345 -0
- package/dist/google-tag-manager.cjs +80 -96
- package/dist/google-tag-manager.js +74 -87
- package/dist/google-tag.cjs +88 -39
- package/dist/google-tag.js +82 -36
- package/dist/linkedin-insights.cjs +52 -41
- package/dist/linkedin-insights.js +45 -37
- package/dist/meta-pixel.cjs +92 -26
- package/dist/meta-pixel.js +86 -23
- package/dist/microsoft-uet.cjs +92 -52
- package/dist/microsoft-uet.js +86 -49
- package/dist/posthog.cjs +102 -53
- package/dist/posthog.js +96 -50
- package/dist/resolve.cjs +67 -0
- package/dist/resolve.js +33 -0
- package/dist/tiktok-pixel.cjs +93 -27
- package/dist/tiktok-pixel.js +86 -23
- package/dist/types.cjs +47 -0
- package/dist/types.js +7 -0
- package/dist/x-pixel.cjs +49 -19
- package/dist/x-pixel.js +42 -15
- package/dist-types/databuddy.d.ts +144 -0
- package/dist-types/engine/compile.d.ts +3 -0
- package/dist-types/engine/runtime.d.ts +3 -0
- package/dist-types/engine.test.d.ts +1 -0
- package/dist-types/google-tag-manager.d.ts +97 -0
- package/dist-types/google-tag.d.ts +96 -0
- package/dist-types/helpers.test.d.ts +1 -0
- package/dist-types/linkedin-insights.d.ts +79 -0
- package/{dist → dist-types}/meta-pixel.d.ts +61 -14
- package/dist-types/microsoft-uet.d.ts +94 -0
- package/dist-types/posthog.d.ts +112 -0
- package/dist-types/resolve.d.ts +9 -0
- package/dist-types/tiktok-pixel.d.ts +91 -0
- package/dist-types/types.d.ts +259 -0
- package/{dist → dist-types}/x-pixel.d.ts +38 -12
- package/package.json +46 -45
- package/LICENSE.md +0 -595
- package/dist/databuddy.d.ts +0 -104
- package/dist/databuddy.d.ts.map +0 -1
- package/dist/google-tag-manager.d.ts +0 -63
- package/dist/google-tag-manager.d.ts.map +0 -1
- package/dist/google-tag.d.ts +0 -38
- package/dist/google-tag.d.ts.map +0 -1
- package/dist/linkedin-insights.d.ts +0 -48
- package/dist/linkedin-insights.d.ts.map +0 -1
- package/dist/meta-pixel.d.ts.map +0 -1
- package/dist/microsoft-uet.d.ts +0 -40
- package/dist/microsoft-uet.d.ts.map +0 -1
- package/dist/posthog.d.ts +0 -54
- package/dist/posthog.d.ts.map +0 -1
- package/dist/tiktok-pixel.d.ts +0 -44
- package/dist/tiktok-pixel.d.ts.map +0 -1
- package/dist/x-pixel.d.ts.map +0 -1
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
VENDOR_MANIFEST_KIND: ()=>VENDOR_MANIFEST_KIND,
|
|
28
|
+
VENDOR_MANIFEST_SCHEMA_VERSION: ()=>VENDOR_MANIFEST_SCHEMA_VERSION,
|
|
29
|
+
vendorManifestContract: ()=>vendorManifestContract
|
|
30
|
+
});
|
|
31
|
+
const VENDOR_MANIFEST_KIND = 'c15t.vendor-manifest';
|
|
32
|
+
const VENDOR_MANIFEST_SCHEMA_VERSION = 1;
|
|
33
|
+
const vendorManifestContract = {
|
|
34
|
+
kind: VENDOR_MANIFEST_KIND,
|
|
35
|
+
schemaVersion: VENDOR_MANIFEST_SCHEMA_VERSION
|
|
36
|
+
};
|
|
37
|
+
exports.VENDOR_MANIFEST_KIND = __webpack_exports__.VENDOR_MANIFEST_KIND;
|
|
38
|
+
exports.VENDOR_MANIFEST_SCHEMA_VERSION = __webpack_exports__.VENDOR_MANIFEST_SCHEMA_VERSION;
|
|
39
|
+
exports.vendorManifestContract = __webpack_exports__.vendorManifestContract;
|
|
40
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
41
|
+
"VENDOR_MANIFEST_KIND",
|
|
42
|
+
"VENDOR_MANIFEST_SCHEMA_VERSION",
|
|
43
|
+
"vendorManifestContract"
|
|
44
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
45
|
+
Object.defineProperty(exports, '__esModule', {
|
|
46
|
+
value: true
|
|
47
|
+
});
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const VENDOR_MANIFEST_KIND = 'c15t.vendor-manifest';
|
|
2
|
+
const VENDOR_MANIFEST_SCHEMA_VERSION = 1;
|
|
3
|
+
const vendorManifestContract = {
|
|
4
|
+
kind: VENDOR_MANIFEST_KIND,
|
|
5
|
+
schemaVersion: VENDOR_MANIFEST_SCHEMA_VERSION
|
|
6
|
+
};
|
|
7
|
+
export { VENDOR_MANIFEST_KIND, VENDOR_MANIFEST_SCHEMA_VERSION, vendorManifestContract };
|
package/dist/x-pixel.cjs
CHANGED
|
@@ -13,7 +13,7 @@ var __webpack_require__ = {};
|
|
|
13
13
|
})();
|
|
14
14
|
(()=>{
|
|
15
15
|
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if (
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
17
|
value: 'Module'
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -25,31 +25,61 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
xPixel: ()=>xPixel,
|
|
28
|
-
xPixelEvent: ()=>xPixelEvent
|
|
28
|
+
xPixelEvent: ()=>xPixelEvent,
|
|
29
|
+
xPixelManifest: ()=>xPixelManifest
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
const external_resolve_cjs_namespaceObject = require("./resolve.cjs");
|
|
32
|
+
const external_types_cjs_namespaceObject = require("./types.cjs");
|
|
33
|
+
const xPixelManifest = {
|
|
34
|
+
...external_types_cjs_namespaceObject.vendorManifestContract,
|
|
35
|
+
vendor: 'x-pixel',
|
|
36
|
+
category: 'marketing',
|
|
37
|
+
bootstrap: [
|
|
38
|
+
{
|
|
39
|
+
type: 'defineStubFunction',
|
|
40
|
+
name: 'twq',
|
|
41
|
+
queue: {
|
|
42
|
+
property: 'queue'
|
|
43
|
+
},
|
|
44
|
+
dispatchProperty: 'exe',
|
|
45
|
+
properties: {
|
|
46
|
+
version: '1.1'
|
|
47
|
+
},
|
|
48
|
+
ifUndefined: true
|
|
43
49
|
}
|
|
44
|
-
|
|
50
|
+
],
|
|
51
|
+
install: [
|
|
52
|
+
{
|
|
53
|
+
type: 'callGlobal',
|
|
54
|
+
global: 'twq',
|
|
55
|
+
args: [
|
|
56
|
+
'config',
|
|
57
|
+
'{{pixelId}}'
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: 'loadScript',
|
|
62
|
+
src: "{{scriptSrc}}",
|
|
63
|
+
async: true
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
function xPixel({ pixelId, scriptSrc }) {
|
|
68
|
+
const resolved = (0, external_resolve_cjs_namespaceObject.resolveManifest)(xPixelManifest, {
|
|
69
|
+
pixelId,
|
|
70
|
+
scriptSrc: scriptSrc ?? 'https://static.ads-twitter.com/uwt.js'
|
|
71
|
+
});
|
|
72
|
+
return resolved;
|
|
45
73
|
}
|
|
46
74
|
const xPixelEvent = (eventId, metadata)=>window.twq?.('event', eventId, metadata);
|
|
47
75
|
exports.xPixel = __webpack_exports__.xPixel;
|
|
48
76
|
exports.xPixelEvent = __webpack_exports__.xPixelEvent;
|
|
49
|
-
|
|
77
|
+
exports.xPixelManifest = __webpack_exports__.xPixelManifest;
|
|
78
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
50
79
|
"xPixel",
|
|
51
|
-
"xPixelEvent"
|
|
52
|
-
|
|
80
|
+
"xPixelEvent",
|
|
81
|
+
"xPixelManifest"
|
|
82
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
53
83
|
Object.defineProperty(exports, '__esModule', {
|
|
54
84
|
value: true
|
|
55
85
|
});
|
package/dist/x-pixel.js
CHANGED
|
@@ -1,18 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { resolveManifest } from "./resolve.js";
|
|
2
|
+
import { vendorManifestContract } from "./types.js";
|
|
3
|
+
const xPixelManifest = {
|
|
4
|
+
...vendorManifestContract,
|
|
5
|
+
vendor: 'x-pixel',
|
|
6
|
+
category: 'marketing',
|
|
7
|
+
bootstrap: [
|
|
8
|
+
{
|
|
9
|
+
type: 'defineStubFunction',
|
|
10
|
+
name: 'twq',
|
|
11
|
+
queue: {
|
|
12
|
+
property: 'queue'
|
|
13
|
+
},
|
|
14
|
+
dispatchProperty: 'exe',
|
|
15
|
+
properties: {
|
|
16
|
+
version: '1.1'
|
|
17
|
+
},
|
|
18
|
+
ifUndefined: true
|
|
14
19
|
}
|
|
15
|
-
|
|
20
|
+
],
|
|
21
|
+
install: [
|
|
22
|
+
{
|
|
23
|
+
type: 'callGlobal',
|
|
24
|
+
global: 'twq',
|
|
25
|
+
args: [
|
|
26
|
+
'config',
|
|
27
|
+
'{{pixelId}}'
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'loadScript',
|
|
32
|
+
src: "{{scriptSrc}}",
|
|
33
|
+
async: true
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
function xPixel({ pixelId, scriptSrc }) {
|
|
38
|
+
const resolved = resolveManifest(xPixelManifest, {
|
|
39
|
+
pixelId,
|
|
40
|
+
scriptSrc: scriptSrc ?? 'https://static.ads-twitter.com/uwt.js'
|
|
41
|
+
});
|
|
42
|
+
return resolved;
|
|
16
43
|
}
|
|
17
44
|
const xPixelEvent = (eventId, metadata)=>window.twq?.('event', eventId, metadata);
|
|
18
|
-
export { xPixel, xPixelEvent };
|
|
45
|
+
export { xPixel, xPixelEvent, xPixelManifest };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
databuddy?: {
|
|
5
|
+
track: (eventName: string, properties?: Record<string, unknown>) => void;
|
|
6
|
+
screenView: (screenName?: string, properties?: Record<string, unknown>) => void;
|
|
7
|
+
clear: () => void;
|
|
8
|
+
flush: () => void;
|
|
9
|
+
setGlobalProperties: (properties: Record<string, unknown>) => void;
|
|
10
|
+
trackCustomEvent: (eventName: string, properties?: Record<string, unknown>) => void;
|
|
11
|
+
options: {
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
databuddyConfig?: {
|
|
17
|
+
clientId?: string;
|
|
18
|
+
apiUrl?: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* DataBuddy vendor manifest.
|
|
25
|
+
*
|
|
26
|
+
* DataBuddy always loads but controls tracking via its `options.disabled` flag.
|
|
27
|
+
* Config is seeded via `window.databuddyConfig` before the script loads.
|
|
28
|
+
*/
|
|
29
|
+
export declare const databuddyManifest: {
|
|
30
|
+
readonly vendor: "databuddy";
|
|
31
|
+
readonly category: "measurement";
|
|
32
|
+
readonly alwaysLoad: true;
|
|
33
|
+
readonly install: [{
|
|
34
|
+
readonly type: "loadScript";
|
|
35
|
+
readonly src: "{{scriptUrl}}";
|
|
36
|
+
readonly async: true;
|
|
37
|
+
readonly attributes: {
|
|
38
|
+
readonly crossorigin: "anonymous";
|
|
39
|
+
readonly 'data-client-id': "{{clientId}}";
|
|
40
|
+
readonly 'data-api-url': "{{apiUrl}}";
|
|
41
|
+
};
|
|
42
|
+
}];
|
|
43
|
+
readonly onBeforeLoadGranted: [{
|
|
44
|
+
readonly type: "setGlobal";
|
|
45
|
+
readonly name: "databuddyConfig";
|
|
46
|
+
readonly value: "{{configWhenGranted}}";
|
|
47
|
+
readonly ifUndefined: true;
|
|
48
|
+
}];
|
|
49
|
+
readonly onBeforeLoadDenied: [{
|
|
50
|
+
readonly type: "setGlobal";
|
|
51
|
+
readonly name: "databuddyConfig";
|
|
52
|
+
readonly value: "{{configWhenDenied}}";
|
|
53
|
+
readonly ifUndefined: true;
|
|
54
|
+
}];
|
|
55
|
+
readonly onLoadGranted: [{
|
|
56
|
+
readonly type: "setGlobalPath";
|
|
57
|
+
readonly path: ["databuddy", "options", "disabled"];
|
|
58
|
+
readonly value: false;
|
|
59
|
+
}];
|
|
60
|
+
readonly onLoadDenied: [{
|
|
61
|
+
readonly type: "setGlobalPath";
|
|
62
|
+
readonly path: ["databuddy", "options", "disabled"];
|
|
63
|
+
readonly value: true;
|
|
64
|
+
}];
|
|
65
|
+
readonly onConsentGranted: [{
|
|
66
|
+
readonly type: "setGlobal";
|
|
67
|
+
readonly name: "databuddyConfig";
|
|
68
|
+
readonly value: "{{configWhenGranted}}";
|
|
69
|
+
readonly ifUndefined: false;
|
|
70
|
+
}, {
|
|
71
|
+
readonly type: "setGlobalPath";
|
|
72
|
+
readonly path: ["databuddy", "options", "disabled"];
|
|
73
|
+
readonly value: false;
|
|
74
|
+
}];
|
|
75
|
+
readonly onConsentDenied: [{
|
|
76
|
+
readonly type: "setGlobal";
|
|
77
|
+
readonly name: "databuddyConfig";
|
|
78
|
+
readonly value: "{{configWhenDenied}}";
|
|
79
|
+
readonly ifUndefined: false;
|
|
80
|
+
}, {
|
|
81
|
+
readonly type: "setGlobalPath";
|
|
82
|
+
readonly path: ["databuddy", "options", "disabled"];
|
|
83
|
+
readonly value: true;
|
|
84
|
+
}];
|
|
85
|
+
readonly kind: "c15t.vendor-manifest";
|
|
86
|
+
readonly schemaVersion: 1;
|
|
87
|
+
};
|
|
88
|
+
export interface DatabuddyConsentOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Your Databuddy client ID.
|
|
91
|
+
*/
|
|
92
|
+
clientId: string;
|
|
93
|
+
/**
|
|
94
|
+
* Your Databuddy API URL.
|
|
95
|
+
* @default 'https://basket.databuddy.cc'
|
|
96
|
+
*/
|
|
97
|
+
apiUrl?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The Databuddy script URL.
|
|
100
|
+
* @default 'https://cdn.databuddy.cc/databuddy.js'
|
|
101
|
+
*/
|
|
102
|
+
scriptUrl?: string;
|
|
103
|
+
/** Databuddy config object to seed when consent is granted at load time. */
|
|
104
|
+
configWhenGranted: Record<string, unknown>;
|
|
105
|
+
/** Databuddy config object to seed when consent is denied at load time. */
|
|
106
|
+
configWhenDenied: Record<string, unknown>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Loads the Databuddy script and manages consent state declaratively via the manifest runtime.
|
|
110
|
+
*
|
|
111
|
+
* The script always loads (`alwaysLoad: true`) but tracking is controlled via the `disabled`
|
|
112
|
+
* flag on Databuddy's global config/runtime objects, allowing the vendor to stay present in
|
|
113
|
+
* the DOM while respecting consent boundaries.
|
|
114
|
+
*
|
|
115
|
+
* @param options - Configuration for the Databuddy consent script
|
|
116
|
+
* @returns The Databuddy script configuration object for c15t's script loader
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { configureConsentManager } from 'c15t';
|
|
121
|
+
* import { databuddy } from '@c15t/scripts/databuddy';
|
|
122
|
+
*
|
|
123
|
+
* configureConsentManager({
|
|
124
|
+
* scripts: [
|
|
125
|
+
* databuddy({
|
|
126
|
+
* clientId: 'db_1234567890abcdef',
|
|
127
|
+
* configWhenGranted: {
|
|
128
|
+
* clientId: 'db_1234567890abcdef',
|
|
129
|
+
* trackScreenViews: true,
|
|
130
|
+
* trackOutgoingLinks: true,
|
|
131
|
+
* trackPerformance: true,
|
|
132
|
+
* samplingRate: 1.0,
|
|
133
|
+
* disabled: false,
|
|
134
|
+
* },
|
|
135
|
+
* configWhenDenied: {
|
|
136
|
+
* clientId: 'db_1234567890abcdef',
|
|
137
|
+
* disabled: true,
|
|
138
|
+
* },
|
|
139
|
+
* }),
|
|
140
|
+
* ],
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export declare function databuddy(options: DatabuddyConsentOptions): Script;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResolvedManifest, VendorManifest } from '../types';
|
|
2
|
+
export declare function interpolateValue(value: unknown, config: Record<string, unknown>): unknown;
|
|
3
|
+
export declare function compileManifest(manifest: VendorManifest, config?: Record<string, unknown>): ResolvedManifest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
dataLayer: unknown[];
|
|
5
|
+
gtag: (...args: unknown[]) => void;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Google Tag Manager vendor manifest.
|
|
10
|
+
*
|
|
11
|
+
* Defines GTM as a declarative integration:
|
|
12
|
+
* - Initializes dataLayer and gtag function before the container loads
|
|
13
|
+
* - Maps c15t consent categories to Google Consent Mode v2 types
|
|
14
|
+
* - Signals consent state via `gtag('consent', 'default'|'update', ...)`
|
|
15
|
+
*/
|
|
16
|
+
export declare const googleTagManagerManifest: {
|
|
17
|
+
readonly vendor: "google-tag-manager";
|
|
18
|
+
readonly category: "necessary";
|
|
19
|
+
readonly alwaysLoad: true;
|
|
20
|
+
readonly bootstrap: [{
|
|
21
|
+
readonly type: "setGlobal";
|
|
22
|
+
readonly name: "dataLayer";
|
|
23
|
+
readonly value: readonly [];
|
|
24
|
+
readonly ifUndefined: true;
|
|
25
|
+
}, {
|
|
26
|
+
readonly type: "defineQueueFunction";
|
|
27
|
+
readonly name: "gtag";
|
|
28
|
+
readonly queue: "dataLayer";
|
|
29
|
+
readonly ifUndefined: true;
|
|
30
|
+
}];
|
|
31
|
+
readonly install: [{
|
|
32
|
+
readonly type: "pushToQueue";
|
|
33
|
+
readonly queue: "dataLayer";
|
|
34
|
+
readonly value: {
|
|
35
|
+
readonly 'gtm.start': "{{loadTime}}";
|
|
36
|
+
readonly event: "gtm.js";
|
|
37
|
+
};
|
|
38
|
+
}, {
|
|
39
|
+
readonly type: "loadScript";
|
|
40
|
+
readonly src: "https://www.googletagmanager.com/gtm.js?id={{id}}";
|
|
41
|
+
readonly async: true;
|
|
42
|
+
}];
|
|
43
|
+
readonly onConsentChange: [{
|
|
44
|
+
readonly type: "callGlobal";
|
|
45
|
+
readonly global: "gtag";
|
|
46
|
+
readonly args: ["event", "{{updateEventName}}"];
|
|
47
|
+
}];
|
|
48
|
+
readonly consentMapping: {
|
|
49
|
+
readonly necessary: ["security_storage"];
|
|
50
|
+
readonly functionality: ["functionality_storage"];
|
|
51
|
+
readonly measurement: ["analytics_storage"];
|
|
52
|
+
readonly marketing: ["ad_storage", "ad_user_data", "ad_personalization"];
|
|
53
|
+
readonly experience: ["personalization_storage"];
|
|
54
|
+
};
|
|
55
|
+
readonly consentSignal: "gtag";
|
|
56
|
+
readonly kind: "c15t.vendor-manifest";
|
|
57
|
+
readonly schemaVersion: 1;
|
|
58
|
+
};
|
|
59
|
+
export interface GoogleTagManagerOptions {
|
|
60
|
+
/**
|
|
61
|
+
* Your Google Tag Manager container ID. Begins with 'GTM-'.
|
|
62
|
+
* @example `GTM-1234XXX`
|
|
63
|
+
*/
|
|
64
|
+
id: string;
|
|
65
|
+
/**
|
|
66
|
+
* Custom event name fired after consent updates.
|
|
67
|
+
* Can be used as a trigger in GTM to load scripts once consent is updated.
|
|
68
|
+
*
|
|
69
|
+
* @default 'consent-update'
|
|
70
|
+
*/
|
|
71
|
+
updateEventName?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Custom mapping from c15t consent categories to Google Consent Mode v2 types.
|
|
74
|
+
* Overrides the default mapping when provided.
|
|
75
|
+
*
|
|
76
|
+
* @default
|
|
77
|
+
* ```ts
|
|
78
|
+
* {
|
|
79
|
+
* necessary: ['security_storage'],
|
|
80
|
+
* functionality: ['functionality_storage'],
|
|
81
|
+
* measurement: ['analytics_storage'],
|
|
82
|
+
* marketing: ['ad_storage', 'ad_user_data', 'ad_personalization'],
|
|
83
|
+
* experience: ['personalization_storage'],
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
consentMapping?: Record<string, string[]>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Creates a Google Tag Manager script.
|
|
91
|
+
* GTM can be used for managing the consent of other scripts via Google Tag Manager consent mode.
|
|
92
|
+
* We recommend using c15t's script loader instead so your script logic is centralised.
|
|
93
|
+
*
|
|
94
|
+
* @param options - The options for the Google Tag Manager script.
|
|
95
|
+
* @returns The Google Tag Manager script.
|
|
96
|
+
*/
|
|
97
|
+
export declare function googleTagManager({ id, updateEventName, consentMapping, }: GoogleTagManagerOptions): Script;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { AllConsentNames, Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
dataLayer: unknown[];
|
|
5
|
+
gtag: (...args: unknown[]) => void;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Google Tag (gtag.js) vendor manifest.
|
|
10
|
+
*
|
|
11
|
+
* Similar to GTM but for direct Google product integration (Analytics, Ads, Floodlight).
|
|
12
|
+
* Uses the same Consent Mode v2 mapping.
|
|
13
|
+
*/
|
|
14
|
+
export declare const gtagManifest: {
|
|
15
|
+
readonly vendor: "gtag";
|
|
16
|
+
readonly category: "{{category}}";
|
|
17
|
+
readonly alwaysLoad: true;
|
|
18
|
+
readonly persistAfterConsentRevoked: true;
|
|
19
|
+
readonly bootstrap: [{
|
|
20
|
+
readonly type: "setGlobal";
|
|
21
|
+
readonly name: "dataLayer";
|
|
22
|
+
readonly value: readonly [];
|
|
23
|
+
readonly ifUndefined: true;
|
|
24
|
+
}, {
|
|
25
|
+
readonly type: "defineQueueFunction";
|
|
26
|
+
readonly name: "gtag";
|
|
27
|
+
readonly queue: "dataLayer";
|
|
28
|
+
readonly ifUndefined: true;
|
|
29
|
+
}];
|
|
30
|
+
readonly install: [{
|
|
31
|
+
readonly type: "callGlobal";
|
|
32
|
+
readonly global: "gtag";
|
|
33
|
+
readonly args: ["js", "{{loadTime}}"];
|
|
34
|
+
}, {
|
|
35
|
+
readonly type: "callGlobal";
|
|
36
|
+
readonly global: "gtag";
|
|
37
|
+
readonly args: ["config", "{{id}}"];
|
|
38
|
+
}, {
|
|
39
|
+
readonly type: "loadScript";
|
|
40
|
+
readonly src: "https://www.googletagmanager.com/gtag/js?id={{id}}";
|
|
41
|
+
readonly async: true;
|
|
42
|
+
}];
|
|
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
|
+
};
|
|
50
|
+
readonly consentSignal: "gtag";
|
|
51
|
+
readonly kind: "c15t.vendor-manifest";
|
|
52
|
+
readonly schemaVersion: 1;
|
|
53
|
+
};
|
|
54
|
+
export interface GtagOptions {
|
|
55
|
+
/**
|
|
56
|
+
* Your gtag id
|
|
57
|
+
* @example `G-XXXXXXX`
|
|
58
|
+
*/
|
|
59
|
+
id: string;
|
|
60
|
+
/**
|
|
61
|
+
* The consent category to use for the gtag script. This is typically marketing (Ads & Floodlight) or measurement (Analytics)
|
|
62
|
+
* @example 'marketing'
|
|
63
|
+
*/
|
|
64
|
+
category: AllConsentNames;
|
|
65
|
+
/**
|
|
66
|
+
* Custom mapping from c15t consent categories to Google Consent Mode v2 types.
|
|
67
|
+
* Overrides the default mapping when provided.
|
|
68
|
+
*
|
|
69
|
+
* @default
|
|
70
|
+
* ```ts
|
|
71
|
+
* {
|
|
72
|
+
* necessary: ['security_storage'],
|
|
73
|
+
* functionality: ['functionality_storage'],
|
|
74
|
+
* measurement: ['analytics_storage'],
|
|
75
|
+
* marketing: ['ad_storage', 'ad_user_data', 'ad_personalization'],
|
|
76
|
+
* experience: ['personalization_storage'],
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
consentMapping?: Record<string, string[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Deprecated script-level overrides preserved for backwards compatibility.
|
|
83
|
+
*
|
|
84
|
+
* Prefer manifest-backed options instead of this generic override bag.
|
|
85
|
+
* @deprecated
|
|
86
|
+
*/
|
|
87
|
+
script?: Partial<Script>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Creates a Google Tag (gtag.js) script.
|
|
91
|
+
* Allows you to send data website to linked Google products like Analytics, Ads & Floodlight.
|
|
92
|
+
*
|
|
93
|
+
* @param options - The options for the gtag script.
|
|
94
|
+
* @returns The Google Tag Manager script.
|
|
95
|
+
*/
|
|
96
|
+
export declare function gtag({ id, category, consentMapping, script, }: GtagOptions): Script;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
lintrk: ((...args: unknown[]) => void) & {
|
|
5
|
+
q?: unknown[][];
|
|
6
|
+
};
|
|
7
|
+
_linkedin_partner_id?: string;
|
|
8
|
+
_linkedin_data_partner_ids?: string[];
|
|
9
|
+
ORIBILI?: {
|
|
10
|
+
_DEBUG?: {
|
|
11
|
+
disableScript?: () => void;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* LinkedIn Insights vendor manifest.
|
|
18
|
+
*
|
|
19
|
+
* Sets up the LinkedIn partner ID globals and loads the insights script
|
|
20
|
+
* via structured startup steps.
|
|
21
|
+
*/
|
|
22
|
+
export declare const linkedinInsightsManifest: {
|
|
23
|
+
readonly vendor: "linkedin-insights";
|
|
24
|
+
readonly category: "marketing";
|
|
25
|
+
readonly install: [{
|
|
26
|
+
readonly type: "setGlobal";
|
|
27
|
+
readonly name: "_linkedin_partner_id";
|
|
28
|
+
readonly value: "{{id}}";
|
|
29
|
+
readonly ifUndefined: false;
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "setGlobal";
|
|
32
|
+
readonly name: "_linkedin_data_partner_ids";
|
|
33
|
+
readonly value: readonly [];
|
|
34
|
+
readonly ifUndefined: true;
|
|
35
|
+
}, {
|
|
36
|
+
readonly type: "pushToQueue";
|
|
37
|
+
readonly queue: "_linkedin_data_partner_ids";
|
|
38
|
+
readonly value: "{{id}}";
|
|
39
|
+
}, {
|
|
40
|
+
readonly type: "defineStubFunction";
|
|
41
|
+
readonly name: "lintrk";
|
|
42
|
+
readonly queue: {
|
|
43
|
+
readonly property: "q";
|
|
44
|
+
};
|
|
45
|
+
readonly queueFormat: "array";
|
|
46
|
+
readonly ifUndefined: true;
|
|
47
|
+
}, {
|
|
48
|
+
readonly type: "loadScript";
|
|
49
|
+
readonly src: "{{scriptSrc}}";
|
|
50
|
+
readonly async: true;
|
|
51
|
+
}];
|
|
52
|
+
readonly kind: "c15t.vendor-manifest";
|
|
53
|
+
readonly schemaVersion: 1;
|
|
54
|
+
};
|
|
55
|
+
export interface LinkedInInsightsOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Your LinkedIn Insights ID
|
|
58
|
+
* @example `123456789012345`
|
|
59
|
+
*/
|
|
60
|
+
id: string;
|
|
61
|
+
/** LinkedIn Insights loader URL. */
|
|
62
|
+
scriptSrc?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* LinkedIn Insights Script
|
|
66
|
+
*
|
|
67
|
+
* @param options - The options for the LinkedIn Insights script
|
|
68
|
+
* @returns The LinkedIn Insights script configuration
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const linkedinInsightsScript = linkedinInsights({
|
|
73
|
+
* id: '123456789012345',
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @see {@link https://business.linkedin.com/marketing-solutions/ad-libraries/insights} LinkedIn Insights documentation
|
|
78
|
+
*/
|
|
79
|
+
export declare function linkedinInsights({ id, scriptSrc, }: LinkedInInsightsOptions): Script;
|