@shware/analytics 8.11.0 → 8.13.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/dist/attribution/classify.cjs +128 -0
- package/dist/attribution/classify.cjs.map +1 -0
- package/dist/attribution/classify.d.cts +62 -0
- package/dist/attribution/classify.d.cts.map +1 -0
- package/dist/attribution/classify.d.mts +62 -0
- package/dist/attribution/classify.d.mts.map +1 -0
- package/dist/attribution/classify.mjs +126 -0
- package/dist/attribution/classify.mjs.map +1 -0
- package/dist/attribution/index.cjs +23 -274
- package/dist/attribution/index.d.cts +3 -108
- package/dist/attribution/index.d.mts +3 -108
- package/dist/attribution/index.mjs +3 -258
- package/dist/attribution/vocabulary.cjs +449 -0
- package/dist/attribution/vocabulary.cjs.map +1 -0
- package/dist/attribution/vocabulary.d.cts +154 -0
- package/dist/attribution/vocabulary.d.cts.map +1 -0
- package/dist/attribution/vocabulary.d.mts +154 -0
- package/dist/attribution/vocabulary.d.mts.map +1 -0
- package/dist/attribution/vocabulary.mjs +430 -0
- package/dist/attribution/vocabulary.mjs.map +1 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/third-parties/google-analytics.d.cts +1 -1
- package/dist/third-parties/google-analytics.d.mts +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.mts +1 -1
- package/dist/third-parties/meta-pixel.d.cts +1 -1
- package/dist/third-parties/meta-pixel.d.mts +1 -1
- package/dist/third-parties/microsoft-uet.d.cts +1 -1
- package/dist/third-parties/microsoft-uet.d.mts +1 -1
- package/dist/third-parties/openai-pixel.d.cts +1 -1
- package/dist/third-parties/openai-pixel.d.mts +1 -1
- package/dist/third-parties/reddit-pixel.d.cts +1 -1
- package/dist/third-parties/reddit-pixel.d.mts +1 -1
- package/dist/visitor/types.d.cts +1 -1
- package/dist/visitor/types.d.mts +1 -1
- package/package.json +1 -1
- package/dist/attribution/index.cjs.map +0 -1
- package/dist/attribution/index.d.cts.map +0 -1
- package/dist/attribution/index.d.mts.map +0 -1
- package/dist/attribution/index.mjs.map +0 -1
|
@@ -1,275 +1,24 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"kakao",
|
|
26
|
-
"yandex",
|
|
27
|
-
"yahoo",
|
|
28
|
-
"duckduckgo",
|
|
29
|
-
"baidu",
|
|
30
|
-
"ecosia",
|
|
31
|
-
"naver",
|
|
32
|
-
"brave",
|
|
33
|
-
"pinterest",
|
|
34
|
-
"youtube",
|
|
35
|
-
"referral_program"
|
|
36
|
-
];
|
|
37
|
-
/** GA4's default channel groups, as identifiers; a dashboard maps them to display names. */
|
|
38
|
-
const CHANNEL_GROUPS = [
|
|
39
|
-
"direct",
|
|
40
|
-
"paid_search",
|
|
41
|
-
"paid_social",
|
|
42
|
-
"paid_other",
|
|
43
|
-
"display",
|
|
44
|
-
"organic_search",
|
|
45
|
-
"organic_social",
|
|
46
|
-
"organic_video",
|
|
47
|
-
"referral",
|
|
48
|
-
"email",
|
|
49
|
-
"affiliate",
|
|
50
|
-
"unassigned"
|
|
51
|
-
];
|
|
52
|
-
/** `utm_source` spellings that mean the same channel: Meta's `{{site_source_name}}` values and the usual synonyms. */
|
|
53
|
-
const SOURCE_ALIASES = {
|
|
54
|
-
fb: "meta",
|
|
55
|
-
ig: "meta",
|
|
56
|
-
an: "meta",
|
|
57
|
-
msg: "meta",
|
|
58
|
-
facebook: "meta",
|
|
59
|
-
instagram: "meta",
|
|
60
|
-
bing: "microsoft",
|
|
61
|
-
twitter: "x"
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Which click id belongs to which channel, in priority order. Every key is a field this SDK
|
|
65
|
-
* collects (`AdvertisingInfo`); `fbp` and `rdt_uuid` are deliberately absent — they are pixel
|
|
66
|
-
* browser ids, present with or without a click.
|
|
67
|
-
*/
|
|
68
|
-
const CLICK_ID_CHANNELS = [
|
|
69
|
-
["fbclid", "meta"],
|
|
70
|
-
["fbc", "meta"],
|
|
71
|
-
["gclid", "google"],
|
|
72
|
-
["gbraid", "google"],
|
|
73
|
-
["wbraid", "google"],
|
|
74
|
-
["gad_source", "google"],
|
|
75
|
-
["gad_campaignid", "google"],
|
|
76
|
-
["dclid", "dv360"],
|
|
77
|
-
["msclkid", "microsoft"],
|
|
78
|
-
["ttclid", "tiktok"],
|
|
79
|
-
["rdt_cid", "reddit"],
|
|
80
|
-
["li_fat_id", "linkedin"],
|
|
81
|
-
["sccid", "snapchat"],
|
|
82
|
-
["twclid", "x"],
|
|
83
|
-
["ko_click_id", "kakao"],
|
|
84
|
-
["yclid", "yandex"]
|
|
85
|
-
];
|
|
86
|
-
/**
|
|
87
|
-
* A landing page reserved for one channel's ads, for ads that lost their parameters:
|
|
88
|
-
* `/lp/<channel>`, with or without host, query and hash; the capture is the channel. A product
|
|
89
|
-
* that names its landing pages differently replaces this.
|
|
90
|
-
*/
|
|
91
|
-
const AD_LANDING_PAGE = "^(?:https?://[^/]+)?/lp/([a-z]+)(?:[/?#]|$)";
|
|
92
|
-
/**
|
|
93
|
-
* Referrer hosts that name a channel, as POSIX regular expressions over the lower-cased host,
|
|
94
|
-
* with the medium GA4 gives that kind of site. Anything else that refers is `referral`, kept as
|
|
95
|
-
* its host. A country TLD is one or two labels (`google.com`, `google.co.uk`, `google.com.hk`),
|
|
96
|
-
* never an open tail, so `google.com.evil.io` is not Google.
|
|
97
|
-
*/
|
|
98
|
-
const REFERRER_SITES = [
|
|
99
|
-
[
|
|
100
|
-
"google",
|
|
101
|
-
"organic",
|
|
102
|
-
String.raw`(^|\.)google\.[a-z]{2,}(\.[a-z]{2,3})?$`
|
|
103
|
-
],
|
|
104
|
-
[
|
|
105
|
-
"microsoft",
|
|
106
|
-
"organic",
|
|
107
|
-
String.raw`(^|\.)bing\.com$`
|
|
108
|
-
],
|
|
109
|
-
[
|
|
110
|
-
"yahoo",
|
|
111
|
-
"organic",
|
|
112
|
-
String.raw`(^|\.)yahoo\.[a-z]{2,}(\.[a-z]{2,3})?$`
|
|
113
|
-
],
|
|
114
|
-
[
|
|
115
|
-
"duckduckgo",
|
|
116
|
-
"organic",
|
|
117
|
-
String.raw`(^|\.)duckduckgo\.com$`
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
"baidu",
|
|
121
|
-
"organic",
|
|
122
|
-
String.raw`(^|\.)baidu\.com$`
|
|
123
|
-
],
|
|
124
|
-
[
|
|
125
|
-
"yandex",
|
|
126
|
-
"organic",
|
|
127
|
-
String.raw`(^|\.)yandex\.[a-z]{2,}(\.[a-z]{2,3})?$`
|
|
128
|
-
],
|
|
129
|
-
[
|
|
130
|
-
"ecosia",
|
|
131
|
-
"organic",
|
|
132
|
-
String.raw`(^|\.)ecosia\.org$`
|
|
133
|
-
],
|
|
134
|
-
[
|
|
135
|
-
"naver",
|
|
136
|
-
"organic",
|
|
137
|
-
String.raw`(^|\.)naver\.com$`
|
|
138
|
-
],
|
|
139
|
-
[
|
|
140
|
-
"brave",
|
|
141
|
-
"organic",
|
|
142
|
-
String.raw`^search\.brave\.com$`
|
|
143
|
-
],
|
|
144
|
-
[
|
|
145
|
-
"meta",
|
|
146
|
-
"social",
|
|
147
|
-
String.raw`(^|\.)(facebook\.com|instagram\.com|fb\.com|threads\.net)$`
|
|
148
|
-
],
|
|
149
|
-
[
|
|
150
|
-
"x",
|
|
151
|
-
"social",
|
|
152
|
-
String.raw`(^|\.)(twitter\.com|x\.com|t\.co)$`
|
|
153
|
-
],
|
|
154
|
-
[
|
|
155
|
-
"linkedin",
|
|
156
|
-
"social",
|
|
157
|
-
String.raw`(^|\.)(linkedin\.com|lnkd\.in)$`
|
|
158
|
-
],
|
|
159
|
-
[
|
|
160
|
-
"reddit",
|
|
161
|
-
"social",
|
|
162
|
-
String.raw`(^|\.)reddit\.com$`
|
|
163
|
-
],
|
|
164
|
-
[
|
|
165
|
-
"tiktok",
|
|
166
|
-
"social",
|
|
167
|
-
String.raw`(^|\.)tiktok\.com$`
|
|
168
|
-
],
|
|
169
|
-
[
|
|
170
|
-
"pinterest",
|
|
171
|
-
"social",
|
|
172
|
-
String.raw`(^|\.)pinterest\.[a-z]{2,}(\.[a-z]{2,3})?$`
|
|
173
|
-
],
|
|
174
|
-
[
|
|
175
|
-
"snapchat",
|
|
176
|
-
"social",
|
|
177
|
-
String.raw`(^|\.)snapchat\.com$`
|
|
178
|
-
],
|
|
179
|
-
[
|
|
180
|
-
"youtube",
|
|
181
|
-
"video",
|
|
182
|
-
String.raw`(^|\.)(youtube\.com|youtu\.be)$`
|
|
183
|
-
]
|
|
184
|
-
];
|
|
185
|
-
/**
|
|
186
|
-
* Referrer hosts that are navigation, not acquisition: the payment and sign-in providers a
|
|
187
|
-
* visitor is bounced through and back from, and the local dev host. A product appends its own
|
|
188
|
-
* hostnames — a session that starts from an internal link after the session timeout refers to
|
|
189
|
-
* them. POSIX regular expressions over the lower-cased host.
|
|
190
|
-
*/
|
|
191
|
-
const REFERRERS_NOT_A_TOUCH = [
|
|
192
|
-
String.raw`^localhost(:|$)`,
|
|
193
|
-
String.raw`(^|\.)stripe\.com$`,
|
|
194
|
-
String.raw`^(pay|accounts)\.google\.com$`,
|
|
195
|
-
String.raw`^(appleid|apps)\.apple\.com$`,
|
|
196
|
-
String.raw`^play\.google\.com$`,
|
|
197
|
-
String.raw`^login\.microsoftonline\.com$`
|
|
198
|
-
];
|
|
199
|
-
/** GA4's paid mediums: cpc, cpm, ppc, retargeting, paid_social, … */
|
|
200
|
-
const PAID_MEDIUM = "^(.*cp.*|ppc|retargeting|paid.*)$";
|
|
201
|
-
const DISPLAY_MEDIUMS = [
|
|
202
|
-
"display",
|
|
203
|
-
"banner",
|
|
204
|
-
"expandable",
|
|
205
|
-
"interstitial"
|
|
206
|
-
];
|
|
207
|
-
const EMAIL_MEDIUMS = [
|
|
208
|
-
"email",
|
|
209
|
-
"e-mail",
|
|
210
|
-
"e_mail",
|
|
211
|
-
"e mail"
|
|
212
|
-
];
|
|
213
|
-
/** Where a touch came from: a tracked session, or a report by the user or staff. */
|
|
214
|
-
const TOUCH_SOURCES = ["tracked", "reported"];
|
|
215
|
-
/**
|
|
216
|
-
* How a reported touch was learned:
|
|
217
|
-
* - survey: the user answered "how did you hear about us" (onboarding, checkout)
|
|
218
|
-
* - promo_code: the user redeemed a code that belongs to a channel
|
|
219
|
-
* - phone: a call came in on a channel's dedicated number, marked by staff or the phone system
|
|
220
|
-
* - manual: staff recorded what a customer told them
|
|
221
|
-
*/
|
|
222
|
-
const REPORTED_TOUCH_KINDS = [
|
|
223
|
-
"survey",
|
|
224
|
-
"promo_code",
|
|
225
|
-
"phone",
|
|
226
|
-
"manual"
|
|
227
|
-
];
|
|
228
|
-
/**
|
|
229
|
-
* How much a touch is worth against another when attribution has to choose between sessions;
|
|
230
|
-
* lower wins, and the latest wins among equals. Derived in the views, never stored, so
|
|
231
|
-
* renumbering is a view regeneration.
|
|
232
|
-
*
|
|
233
|
-
* This ranks touches against each other. Within one session the rules that name its channel have
|
|
234
|
-
* their own order — `utm_source`, then a click id, then the ad landing page, then the referrer —
|
|
235
|
-
* and the first that says something wins; the session's priority is then the tier of that rule.
|
|
236
|
-
* So two sessions tagged with utm and gclid respectively are equal here (both `campaign`) and the
|
|
237
|
-
* later one is credited, while one session carrying both is named by its utm.
|
|
238
|
-
*/
|
|
239
|
-
const TOUCH_PRIORITY = {
|
|
240
|
-
/** utm, click id, ad landing page: someone tagged that link (in that order within a session) */
|
|
241
|
-
campaign: 1,
|
|
242
|
-
/** a reported touch staff stand behind: a call on a channel's number, a recorded conversation */
|
|
243
|
-
verified: 1,
|
|
244
|
-
/** the browser said where the visitor came from; nobody chose it */
|
|
245
|
-
referrer: 2,
|
|
246
|
-
/** a reported touch that is the user's claim: a survey answer, a code that may have been shared */
|
|
247
|
-
claimed: 3
|
|
248
|
-
};
|
|
249
|
-
/** Which reported kinds are staff facts and which are the user's claims. */
|
|
250
|
-
const REPORTED_TOUCH_PRIORITY = {
|
|
251
|
-
phone: TOUCH_PRIORITY.verified,
|
|
252
|
-
manual: TOUCH_PRIORITY.verified,
|
|
253
|
-
survey: TOUCH_PRIORITY.claimed,
|
|
254
|
-
promo_code: TOUCH_PRIORITY.claimed
|
|
255
|
-
};
|
|
256
|
-
//#endregion
|
|
257
|
-
exports.AD_LANDING_PAGE = AD_LANDING_PAGE;
|
|
258
|
-
exports.CHANNELS = CHANNELS;
|
|
259
|
-
exports.CHANNEL_GROUPS = CHANNEL_GROUPS;
|
|
260
|
-
exports.CLICK_ID_CHANNELS = CLICK_ID_CHANNELS;
|
|
261
|
-
exports.DIRECT_CHANNEL = DIRECT_CHANNEL;
|
|
262
|
-
exports.DISPLAY_MEDIUMS = DISPLAY_MEDIUMS;
|
|
263
|
-
exports.EMAIL_MEDIUMS = EMAIL_MEDIUMS;
|
|
264
|
-
exports.MEDIUM_NOT_SET = MEDIUM_NOT_SET;
|
|
265
|
-
exports.NO_MEDIUM = NO_MEDIUM;
|
|
266
|
-
exports.PAID_MEDIUM = PAID_MEDIUM;
|
|
267
|
-
exports.REFERRERS_NOT_A_TOUCH = REFERRERS_NOT_A_TOUCH;
|
|
268
|
-
exports.REFERRER_SITES = REFERRER_SITES;
|
|
269
|
-
exports.REPORTED_TOUCH_KINDS = REPORTED_TOUCH_KINDS;
|
|
270
|
-
exports.REPORTED_TOUCH_PRIORITY = REPORTED_TOUCH_PRIORITY;
|
|
271
|
-
exports.SOURCE_ALIASES = SOURCE_ALIASES;
|
|
272
|
-
exports.TOUCH_PRIORITY = TOUCH_PRIORITY;
|
|
273
|
-
exports.TOUCH_SOURCES = TOUCH_SOURCES;
|
|
274
|
-
|
|
275
|
-
//# sourceMappingURL=index.cjs.map
|
|
2
|
+
const require_attribution_vocabulary = require("./vocabulary.cjs");
|
|
3
|
+
const require_attribution_classify = require("./classify.cjs");
|
|
4
|
+
exports.AD_LANDING_PAGE = require_attribution_vocabulary.AD_LANDING_PAGE;
|
|
5
|
+
exports.CHANNELS = require_attribution_vocabulary.CHANNELS;
|
|
6
|
+
exports.CHANNEL_GROUPS = require_attribution_vocabulary.CHANNEL_GROUPS;
|
|
7
|
+
exports.CLICK_ID_CHANNELS = require_attribution_vocabulary.CLICK_ID_CHANNELS;
|
|
8
|
+
exports.DIRECT_CHANNEL = require_attribution_vocabulary.DIRECT_CHANNEL;
|
|
9
|
+
exports.DISPLAY_MEDIUMS = require_attribution_vocabulary.DISPLAY_MEDIUMS;
|
|
10
|
+
exports.EMAIL_MEDIUM = require_attribution_vocabulary.EMAIL_MEDIUM;
|
|
11
|
+
exports.EMAIL_MEDIUMS = require_attribution_vocabulary.EMAIL_MEDIUMS;
|
|
12
|
+
exports.MEDIUM_NOT_SET = require_attribution_vocabulary.MEDIUM_NOT_SET;
|
|
13
|
+
exports.META_PLACEMENTS = require_attribution_vocabulary.META_PLACEMENTS;
|
|
14
|
+
exports.NO_MEDIUM = require_attribution_vocabulary.NO_MEDIUM;
|
|
15
|
+
exports.PAID_MEDIUM = require_attribution_vocabulary.PAID_MEDIUM;
|
|
16
|
+
exports.REFERRERS_NOT_A_TOUCH = require_attribution_vocabulary.REFERRERS_NOT_A_TOUCH;
|
|
17
|
+
exports.REFERRER_SITES = require_attribution_vocabulary.REFERRER_SITES;
|
|
18
|
+
exports.REPORTED_TOUCH_KINDS = require_attribution_vocabulary.REPORTED_TOUCH_KINDS;
|
|
19
|
+
exports.REPORTED_TOUCH_PRIORITY = require_attribution_vocabulary.REPORTED_TOUCH_PRIORITY;
|
|
20
|
+
exports.SOURCE_ALIASES = require_attribution_vocabulary.SOURCE_ALIASES;
|
|
21
|
+
exports.TOUCH_PRIORITY = require_attribution_vocabulary.TOUCH_PRIORITY;
|
|
22
|
+
exports.TOUCH_SOURCES = require_attribution_vocabulary.TOUCH_SOURCES;
|
|
23
|
+
exports.channelGroupOf = require_attribution_classify.channelGroupOf;
|
|
24
|
+
exports.classifyTouch = require_attribution_classify.classifyTouch;
|
|
@@ -1,108 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* dashboards that read it. Data only, no SQL: a product turns these into its view. What stays with
|
|
5
|
-
* the product is its own hostnames (referrer exclusions) and its landing-page convention.
|
|
6
|
-
*/
|
|
7
|
-
/** A session that arrived through nothing we can name. GA's spelling, so dashboards read as GA. */
|
|
8
|
-
declare const DIRECT_CHANNEL = "(direct)";
|
|
9
|
-
/** The medium of a direct session. */
|
|
10
|
-
declare const NO_MEDIUM = "(none)";
|
|
11
|
-
/** The medium of a tagged link that named a source but no medium. */
|
|
12
|
-
declare const MEDIUM_NOT_SET = "(not set)";
|
|
13
|
-
/** The channels the rules below can name. A `utm_source` outside this list is its own channel. */
|
|
14
|
-
declare const CHANNELS: readonly ['meta', 'google', 'dv360', 'microsoft', 'tiktok', 'reddit', 'linkedin', 'snapchat', 'x', 'kakao', 'yandex', 'yahoo', 'duckduckgo', 'baidu', 'ecosia', 'naver', 'brave', 'pinterest', 'youtube',
|
|
15
|
-
/** the product's own referral programme: the session came through a member's link or code.
|
|
16
|
-
* How a product recognises one (a `/refer/<code>` path, a code at sign-up) is its own rule. Not
|
|
17
|
-
* `referral`: that word is the channel group of any outside site, and a channel of the same name
|
|
18
|
-
* would be impossible to tell apart in queries. */
|
|
19
|
-
'referral_program'];
|
|
20
|
-
type Channel = (typeof CHANNELS)[number];
|
|
21
|
-
/** GA4's default channel groups, as identifiers; a dashboard maps them to display names. */
|
|
22
|
-
declare const CHANNEL_GROUPS: readonly ['direct', 'paid_search', 'paid_social', 'paid_other', 'display', 'organic_search', 'organic_social', 'organic_video', 'referral', 'email', 'affiliate', 'unassigned'];
|
|
23
|
-
type ChannelGroup = (typeof CHANNEL_GROUPS)[number];
|
|
24
|
-
/** `utm_source` spellings that mean the same channel: Meta's `{{site_source_name}}` values and the usual synonyms. */
|
|
25
|
-
declare const SOURCE_ALIASES: {
|
|
26
|
-
readonly fb: 'meta';
|
|
27
|
-
readonly ig: 'meta';
|
|
28
|
-
readonly an: 'meta';
|
|
29
|
-
readonly msg: 'meta';
|
|
30
|
-
readonly facebook: 'meta';
|
|
31
|
-
readonly instagram: 'meta';
|
|
32
|
-
readonly bing: 'microsoft';
|
|
33
|
-
readonly twitter: 'x';
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Which click id belongs to which channel, in priority order. Every key is a field this SDK
|
|
37
|
-
* collects (`AdvertisingInfo`); `fbp` and `rdt_uuid` are deliberately absent — they are pixel
|
|
38
|
-
* browser ids, present with or without a click.
|
|
39
|
-
*/
|
|
40
|
-
declare const CLICK_ID_CHANNELS: readonly [readonly ["fbclid", "meta"], readonly ["fbc", "meta"], readonly ["gclid", "google"], readonly ["gbraid", "google"], readonly ["wbraid", "google"], readonly ["gad_source", "google"], readonly ["gad_campaignid", "google"], readonly ["dclid", "dv360"], readonly ["msclkid", "microsoft"], readonly ["ttclid", "tiktok"], readonly ["rdt_cid", "reddit"], readonly ["li_fat_id", "linkedin"], readonly ["sccid", "snapchat"], readonly ["twclid", "x"], readonly ["ko_click_id", "kakao"], readonly ["yclid", "yandex"]];
|
|
41
|
-
/**
|
|
42
|
-
* A landing page reserved for one channel's ads, for ads that lost their parameters:
|
|
43
|
-
* `/lp/<channel>`, with or without host, query and hash; the capture is the channel. A product
|
|
44
|
-
* that names its landing pages differently replaces this.
|
|
45
|
-
*/
|
|
46
|
-
declare const AD_LANDING_PAGE = "^(?:https?://[^/]+)?/lp/([a-z]+)(?:[/?#]|$)";
|
|
47
|
-
type ReferrerMedium = 'organic' | 'social' | 'video';
|
|
48
|
-
/**
|
|
49
|
-
* Referrer hosts that name a channel, as POSIX regular expressions over the lower-cased host,
|
|
50
|
-
* with the medium GA4 gives that kind of site. Anything else that refers is `referral`, kept as
|
|
51
|
-
* its host. A country TLD is one or two labels (`google.com`, `google.co.uk`, `google.com.hk`),
|
|
52
|
-
* never an open tail, so `google.com.evil.io` is not Google.
|
|
53
|
-
*/
|
|
54
|
-
declare const REFERRER_SITES: readonly [readonly ["google", "organic", string], readonly ["microsoft", "organic", string], readonly ["yahoo", "organic", string], readonly ["duckduckgo", "organic", string], readonly ["baidu", "organic", string], readonly ["yandex", "organic", string], readonly ["ecosia", "organic", string], readonly ["naver", "organic", string], readonly ["brave", "organic", string], readonly ["meta", "social", string], readonly ["x", "social", string], readonly ["linkedin", "social", string], readonly ["reddit", "social", string], readonly ["tiktok", "social", string], readonly ["pinterest", "social", string], readonly ["snapchat", "social", string], readonly ["youtube", "video", string]];
|
|
55
|
-
/**
|
|
56
|
-
* Referrer hosts that are navigation, not acquisition: the payment and sign-in providers a
|
|
57
|
-
* visitor is bounced through and back from, and the local dev host. A product appends its own
|
|
58
|
-
* hostnames — a session that starts from an internal link after the session timeout refers to
|
|
59
|
-
* them. POSIX regular expressions over the lower-cased host.
|
|
60
|
-
*/
|
|
61
|
-
declare const REFERRERS_NOT_A_TOUCH: readonly [string, string, string, string, string, string];
|
|
62
|
-
/** GA4's paid mediums: cpc, cpm, ppc, retargeting, paid_social, … */
|
|
63
|
-
declare const PAID_MEDIUM = "^(.*cp.*|ppc|retargeting|paid.*)$";
|
|
64
|
-
declare const DISPLAY_MEDIUMS: readonly ['display', 'banner', 'expandable', 'interstitial'];
|
|
65
|
-
declare const EMAIL_MEDIUMS: readonly ['email', 'e-mail', 'e_mail', 'e mail'];
|
|
66
|
-
/** Where a touch came from: a tracked session, or a report by the user or staff. */
|
|
67
|
-
declare const TOUCH_SOURCES: readonly ['tracked', 'reported'];
|
|
68
|
-
type TouchSource = (typeof TOUCH_SOURCES)[number];
|
|
69
|
-
/**
|
|
70
|
-
* How a reported touch was learned:
|
|
71
|
-
* - survey: the user answered "how did you hear about us" (onboarding, checkout)
|
|
72
|
-
* - promo_code: the user redeemed a code that belongs to a channel
|
|
73
|
-
* - phone: a call came in on a channel's dedicated number, marked by staff or the phone system
|
|
74
|
-
* - manual: staff recorded what a customer told them
|
|
75
|
-
*/
|
|
76
|
-
declare const REPORTED_TOUCH_KINDS: readonly ['survey', 'promo_code', 'phone', 'manual'];
|
|
77
|
-
type ReportedTouchKind = (typeof REPORTED_TOUCH_KINDS)[number];
|
|
78
|
-
/**
|
|
79
|
-
* How much a touch is worth against another when attribution has to choose between sessions;
|
|
80
|
-
* lower wins, and the latest wins among equals. Derived in the views, never stored, so
|
|
81
|
-
* renumbering is a view regeneration.
|
|
82
|
-
*
|
|
83
|
-
* This ranks touches against each other. Within one session the rules that name its channel have
|
|
84
|
-
* their own order — `utm_source`, then a click id, then the ad landing page, then the referrer —
|
|
85
|
-
* and the first that says something wins; the session's priority is then the tier of that rule.
|
|
86
|
-
* So two sessions tagged with utm and gclid respectively are equal here (both `campaign`) and the
|
|
87
|
-
* later one is credited, while one session carrying both is named by its utm.
|
|
88
|
-
*/
|
|
89
|
-
declare const TOUCH_PRIORITY: {
|
|
90
|
-
/** utm, click id, ad landing page: someone tagged that link (in that order within a session) */
|
|
91
|
-
readonly campaign: 1;
|
|
92
|
-
/** a reported touch staff stand behind: a call on a channel's number, a recorded conversation */
|
|
93
|
-
readonly verified: 1;
|
|
94
|
-
/** the browser said where the visitor came from; nobody chose it */
|
|
95
|
-
readonly referrer: 2;
|
|
96
|
-
/** a reported touch that is the user's claim: a survey answer, a code that may have been shared */
|
|
97
|
-
readonly claimed: 3;
|
|
98
|
-
};
|
|
99
|
-
/** Which reported kinds are staff facts and which are the user's claims. */
|
|
100
|
-
declare const REPORTED_TOUCH_PRIORITY: {
|
|
101
|
-
readonly phone: 1;
|
|
102
|
-
readonly manual: 1;
|
|
103
|
-
readonly survey: 3;
|
|
104
|
-
readonly promo_code: 3;
|
|
105
|
-
};
|
|
106
|
-
//#endregion
|
|
107
|
-
export { AD_LANDING_PAGE, CHANNELS, CHANNEL_GROUPS, CLICK_ID_CHANNELS, Channel, ChannelGroup, DIRECT_CHANNEL, DISPLAY_MEDIUMS, EMAIL_MEDIUMS, MEDIUM_NOT_SET, NO_MEDIUM, PAID_MEDIUM, REFERRERS_NOT_A_TOUCH, REFERRER_SITES, REPORTED_TOUCH_KINDS, REPORTED_TOUCH_PRIORITY, ReferrerMedium, ReportedTouchKind, SOURCE_ALIASES, TOUCH_PRIORITY, TOUCH_SOURCES, TouchSource };
|
|
108
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
import { AD_LANDING_PAGE, CHANNELS, CHANNEL_GROUPS, CLICK_ID_CHANNELS, Channel, ChannelGroup, DIRECT_CHANNEL, DISPLAY_MEDIUMS, EMAIL_MEDIUM, EMAIL_MEDIUMS, MEDIUM_NOT_SET, META_PLACEMENTS, NO_MEDIUM, PAID_MEDIUM, REFERRERS_NOT_A_TOUCH, REFERRER_SITES, REPORTED_TOUCH_KINDS, REPORTED_TOUCH_PRIORITY, ReferrerMedium, ReportedTouchKind, SOURCE_ALIASES, TOUCH_PRIORITY, TOUCH_SOURCES, TouchSource } from "./vocabulary.cjs";
|
|
2
|
+
import { ClassifyOptions, ProductTouch, Touch, TouchRule, channelGroupOf, classifyTouch } from "./classify.cjs";
|
|
3
|
+
export { AD_LANDING_PAGE, CHANNELS, CHANNEL_GROUPS, CLICK_ID_CHANNELS, Channel, ChannelGroup, ClassifyOptions, DIRECT_CHANNEL, DISPLAY_MEDIUMS, EMAIL_MEDIUM, EMAIL_MEDIUMS, MEDIUM_NOT_SET, META_PLACEMENTS, NO_MEDIUM, PAID_MEDIUM, ProductTouch, REFERRERS_NOT_A_TOUCH, REFERRER_SITES, REPORTED_TOUCH_KINDS, REPORTED_TOUCH_PRIORITY, ReferrerMedium, ReportedTouchKind, SOURCE_ALIASES, TOUCH_PRIORITY, TOUCH_SOURCES, Touch, TouchRule, TouchSource, channelGroupOf, classifyTouch };
|
|
@@ -1,108 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* dashboards that read it. Data only, no SQL: a product turns these into its view. What stays with
|
|
5
|
-
* the product is its own hostnames (referrer exclusions) and its landing-page convention.
|
|
6
|
-
*/
|
|
7
|
-
/** A session that arrived through nothing we can name. GA's spelling, so dashboards read as GA. */
|
|
8
|
-
declare const DIRECT_CHANNEL = "(direct)";
|
|
9
|
-
/** The medium of a direct session. */
|
|
10
|
-
declare const NO_MEDIUM = "(none)";
|
|
11
|
-
/** The medium of a tagged link that named a source but no medium. */
|
|
12
|
-
declare const MEDIUM_NOT_SET = "(not set)";
|
|
13
|
-
/** The channels the rules below can name. A `utm_source` outside this list is its own channel. */
|
|
14
|
-
declare const CHANNELS: readonly ['meta', 'google', 'dv360', 'microsoft', 'tiktok', 'reddit', 'linkedin', 'snapchat', 'x', 'kakao', 'yandex', 'yahoo', 'duckduckgo', 'baidu', 'ecosia', 'naver', 'brave', 'pinterest', 'youtube',
|
|
15
|
-
/** the product's own referral programme: the session came through a member's link or code.
|
|
16
|
-
* How a product recognises one (a `/refer/<code>` path, a code at sign-up) is its own rule. Not
|
|
17
|
-
* `referral`: that word is the channel group of any outside site, and a channel of the same name
|
|
18
|
-
* would be impossible to tell apart in queries. */
|
|
19
|
-
'referral_program'];
|
|
20
|
-
type Channel = (typeof CHANNELS)[number];
|
|
21
|
-
/** GA4's default channel groups, as identifiers; a dashboard maps them to display names. */
|
|
22
|
-
declare const CHANNEL_GROUPS: readonly ['direct', 'paid_search', 'paid_social', 'paid_other', 'display', 'organic_search', 'organic_social', 'organic_video', 'referral', 'email', 'affiliate', 'unassigned'];
|
|
23
|
-
type ChannelGroup = (typeof CHANNEL_GROUPS)[number];
|
|
24
|
-
/** `utm_source` spellings that mean the same channel: Meta's `{{site_source_name}}` values and the usual synonyms. */
|
|
25
|
-
declare const SOURCE_ALIASES: {
|
|
26
|
-
readonly fb: 'meta';
|
|
27
|
-
readonly ig: 'meta';
|
|
28
|
-
readonly an: 'meta';
|
|
29
|
-
readonly msg: 'meta';
|
|
30
|
-
readonly facebook: 'meta';
|
|
31
|
-
readonly instagram: 'meta';
|
|
32
|
-
readonly bing: 'microsoft';
|
|
33
|
-
readonly twitter: 'x';
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Which click id belongs to which channel, in priority order. Every key is a field this SDK
|
|
37
|
-
* collects (`AdvertisingInfo`); `fbp` and `rdt_uuid` are deliberately absent — they are pixel
|
|
38
|
-
* browser ids, present with or without a click.
|
|
39
|
-
*/
|
|
40
|
-
declare const CLICK_ID_CHANNELS: readonly [readonly ["fbclid", "meta"], readonly ["fbc", "meta"], readonly ["gclid", "google"], readonly ["gbraid", "google"], readonly ["wbraid", "google"], readonly ["gad_source", "google"], readonly ["gad_campaignid", "google"], readonly ["dclid", "dv360"], readonly ["msclkid", "microsoft"], readonly ["ttclid", "tiktok"], readonly ["rdt_cid", "reddit"], readonly ["li_fat_id", "linkedin"], readonly ["sccid", "snapchat"], readonly ["twclid", "x"], readonly ["ko_click_id", "kakao"], readonly ["yclid", "yandex"]];
|
|
41
|
-
/**
|
|
42
|
-
* A landing page reserved for one channel's ads, for ads that lost their parameters:
|
|
43
|
-
* `/lp/<channel>`, with or without host, query and hash; the capture is the channel. A product
|
|
44
|
-
* that names its landing pages differently replaces this.
|
|
45
|
-
*/
|
|
46
|
-
declare const AD_LANDING_PAGE = "^(?:https?://[^/]+)?/lp/([a-z]+)(?:[/?#]|$)";
|
|
47
|
-
type ReferrerMedium = 'organic' | 'social' | 'video';
|
|
48
|
-
/**
|
|
49
|
-
* Referrer hosts that name a channel, as POSIX regular expressions over the lower-cased host,
|
|
50
|
-
* with the medium GA4 gives that kind of site. Anything else that refers is `referral`, kept as
|
|
51
|
-
* its host. A country TLD is one or two labels (`google.com`, `google.co.uk`, `google.com.hk`),
|
|
52
|
-
* never an open tail, so `google.com.evil.io` is not Google.
|
|
53
|
-
*/
|
|
54
|
-
declare const REFERRER_SITES: readonly [readonly ["google", "organic", string], readonly ["microsoft", "organic", string], readonly ["yahoo", "organic", string], readonly ["duckduckgo", "organic", string], readonly ["baidu", "organic", string], readonly ["yandex", "organic", string], readonly ["ecosia", "organic", string], readonly ["naver", "organic", string], readonly ["brave", "organic", string], readonly ["meta", "social", string], readonly ["x", "social", string], readonly ["linkedin", "social", string], readonly ["reddit", "social", string], readonly ["tiktok", "social", string], readonly ["pinterest", "social", string], readonly ["snapchat", "social", string], readonly ["youtube", "video", string]];
|
|
55
|
-
/**
|
|
56
|
-
* Referrer hosts that are navigation, not acquisition: the payment and sign-in providers a
|
|
57
|
-
* visitor is bounced through and back from, and the local dev host. A product appends its own
|
|
58
|
-
* hostnames — a session that starts from an internal link after the session timeout refers to
|
|
59
|
-
* them. POSIX regular expressions over the lower-cased host.
|
|
60
|
-
*/
|
|
61
|
-
declare const REFERRERS_NOT_A_TOUCH: readonly [string, string, string, string, string, string];
|
|
62
|
-
/** GA4's paid mediums: cpc, cpm, ppc, retargeting, paid_social, … */
|
|
63
|
-
declare const PAID_MEDIUM = "^(.*cp.*|ppc|retargeting|paid.*)$";
|
|
64
|
-
declare const DISPLAY_MEDIUMS: readonly ['display', 'banner', 'expandable', 'interstitial'];
|
|
65
|
-
declare const EMAIL_MEDIUMS: readonly ['email', 'e-mail', 'e_mail', 'e mail'];
|
|
66
|
-
/** Where a touch came from: a tracked session, or a report by the user or staff. */
|
|
67
|
-
declare const TOUCH_SOURCES: readonly ['tracked', 'reported'];
|
|
68
|
-
type TouchSource = (typeof TOUCH_SOURCES)[number];
|
|
69
|
-
/**
|
|
70
|
-
* How a reported touch was learned:
|
|
71
|
-
* - survey: the user answered "how did you hear about us" (onboarding, checkout)
|
|
72
|
-
* - promo_code: the user redeemed a code that belongs to a channel
|
|
73
|
-
* - phone: a call came in on a channel's dedicated number, marked by staff or the phone system
|
|
74
|
-
* - manual: staff recorded what a customer told them
|
|
75
|
-
*/
|
|
76
|
-
declare const REPORTED_TOUCH_KINDS: readonly ['survey', 'promo_code', 'phone', 'manual'];
|
|
77
|
-
type ReportedTouchKind = (typeof REPORTED_TOUCH_KINDS)[number];
|
|
78
|
-
/**
|
|
79
|
-
* How much a touch is worth against another when attribution has to choose between sessions;
|
|
80
|
-
* lower wins, and the latest wins among equals. Derived in the views, never stored, so
|
|
81
|
-
* renumbering is a view regeneration.
|
|
82
|
-
*
|
|
83
|
-
* This ranks touches against each other. Within one session the rules that name its channel have
|
|
84
|
-
* their own order — `utm_source`, then a click id, then the ad landing page, then the referrer —
|
|
85
|
-
* and the first that says something wins; the session's priority is then the tier of that rule.
|
|
86
|
-
* So two sessions tagged with utm and gclid respectively are equal here (both `campaign`) and the
|
|
87
|
-
* later one is credited, while one session carrying both is named by its utm.
|
|
88
|
-
*/
|
|
89
|
-
declare const TOUCH_PRIORITY: {
|
|
90
|
-
/** utm, click id, ad landing page: someone tagged that link (in that order within a session) */
|
|
91
|
-
readonly campaign: 1;
|
|
92
|
-
/** a reported touch staff stand behind: a call on a channel's number, a recorded conversation */
|
|
93
|
-
readonly verified: 1;
|
|
94
|
-
/** the browser said where the visitor came from; nobody chose it */
|
|
95
|
-
readonly referrer: 2;
|
|
96
|
-
/** a reported touch that is the user's claim: a survey answer, a code that may have been shared */
|
|
97
|
-
readonly claimed: 3;
|
|
98
|
-
};
|
|
99
|
-
/** Which reported kinds are staff facts and which are the user's claims. */
|
|
100
|
-
declare const REPORTED_TOUCH_PRIORITY: {
|
|
101
|
-
readonly phone: 1;
|
|
102
|
-
readonly manual: 1;
|
|
103
|
-
readonly survey: 3;
|
|
104
|
-
readonly promo_code: 3;
|
|
105
|
-
};
|
|
106
|
-
//#endregion
|
|
107
|
-
export { AD_LANDING_PAGE, CHANNELS, CHANNEL_GROUPS, CLICK_ID_CHANNELS, Channel, ChannelGroup, DIRECT_CHANNEL, DISPLAY_MEDIUMS, EMAIL_MEDIUMS, MEDIUM_NOT_SET, NO_MEDIUM, PAID_MEDIUM, REFERRERS_NOT_A_TOUCH, REFERRER_SITES, REPORTED_TOUCH_KINDS, REPORTED_TOUCH_PRIORITY, ReferrerMedium, ReportedTouchKind, SOURCE_ALIASES, TOUCH_PRIORITY, TOUCH_SOURCES, TouchSource };
|
|
108
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { AD_LANDING_PAGE, CHANNELS, CHANNEL_GROUPS, CLICK_ID_CHANNELS, Channel, ChannelGroup, DIRECT_CHANNEL, DISPLAY_MEDIUMS, EMAIL_MEDIUM, EMAIL_MEDIUMS, MEDIUM_NOT_SET, META_PLACEMENTS, NO_MEDIUM, PAID_MEDIUM, REFERRERS_NOT_A_TOUCH, REFERRER_SITES, REPORTED_TOUCH_KINDS, REPORTED_TOUCH_PRIORITY, ReferrerMedium, ReportedTouchKind, SOURCE_ALIASES, TOUCH_PRIORITY, TOUCH_SOURCES, TouchSource } from "./vocabulary.mjs";
|
|
2
|
+
import { ClassifyOptions, ProductTouch, Touch, TouchRule, channelGroupOf, classifyTouch } from "./classify.mjs";
|
|
3
|
+
export { AD_LANDING_PAGE, CHANNELS, CHANNEL_GROUPS, CLICK_ID_CHANNELS, Channel, ChannelGroup, ClassifyOptions, DIRECT_CHANNEL, DISPLAY_MEDIUMS, EMAIL_MEDIUM, EMAIL_MEDIUMS, MEDIUM_NOT_SET, META_PLACEMENTS, NO_MEDIUM, PAID_MEDIUM, ProductTouch, REFERRERS_NOT_A_TOUCH, REFERRER_SITES, REPORTED_TOUCH_KINDS, REPORTED_TOUCH_PRIORITY, ReferrerMedium, ReportedTouchKind, SOURCE_ALIASES, TOUCH_PRIORITY, TOUCH_SOURCES, Touch, TouchRule, TouchSource, channelGroupOf, classifyTouch };
|