Skip to content

Commit 5b48ea4

Browse files
chore: track more source query params
Signed-off-by: Henry <mail@henrygressmann.de>
1 parent 6e3fd35 commit 5b48ea4

4 files changed

Lines changed: 18 additions & 13 deletions

File tree

tracker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"tracking",
77
"liwan"
88
],
9-
"version": "1.0.1",
9+
"version": "1.1.0",
1010
"homepage": "https://liwan.dev",
1111
"repository": {
1212
"type": "git",

tracker/script.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tracker/script.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export async function event(name: string = "pageview", options?: EventOptions):
104104
w < 1536 ? "xl" :
105105
"2xl";
106106

107-
const utm = new URLSearchParams(location.search);
107+
const params = new URLSearchParams(location.search);
108108
const response = await fetch(endpoint_url, {
109109
method: "POST",
110110
headers: { "Content-Type": "application/json" },
@@ -114,11 +114,16 @@ export async function event(name: string = "pageview", options?: EventOptions):
114114
referrer: options?.referrer || referrer,
115115
url: options?.url || location.origin + location.pathname,
116116
utm: {
117-
campaign: utm.get("utm_campaign"),
118-
content: utm.get("utm_content"),
119-
medium: utm.get("utm_medium"),
120-
source: utm.get("utm_source"),
121-
term: utm.get("utm_term"),
117+
campaign: params.get("utm_campaign") || params.get("campaign"),
118+
content: params.get("utm_content") || params.get("content"),
119+
medium: params.get("utm_medium") || params.get("medium"),
120+
source:
121+
params.get("utm_source") ||
122+
params.get("source") ||
123+
params.get("ref") ||
124+
params.get("referrer") ||
125+
params.get("referer"),
126+
term: params.get("utm_term") || params.get("term"),
122127
},
123128
screen_width,
124129
orientation: !noWindow && window.screen.orientation.type.startsWith("portrait") ? "portrait" : "landscape",

web/src/api/constants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export const dimensionNames: Record<Dimension, string> = {
1919
city: "City",
2020
country: "Country",
2121
fqdn: "Domain",
22-
utm_campaign: "UTM Campaign",
23-
utm_content: "UTM Content",
24-
utm_medium: "UTM Medium",
25-
utm_source: "UTM Source",
26-
utm_term: "UTM Term",
22+
utm_campaign: "Campaign",
23+
utm_content: "Content",
24+
utm_medium: "Medium",
25+
utm_source: "Source",
26+
utm_term: "Term",
2727
screen_width: "Screen Width",
2828
orientation: "Orientation",
2929
};

0 commit comments

Comments
 (0)