Skip to content

Commit c365118

Browse files
jvoisinfguillot
authored andcommitted
feat(urlcleaner): add a bunch of parameters
Taken from a cursory look at https://rules2.clearurls.xyz/data.minify.json
1 parent 6f2d10c commit c365118

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

internal/reader/urlcleaner/urlcleaner.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ var trackingParams = map[string]bool{
2525
"fb_source": true,
2626
"fb_comment_id": true,
2727

28+
// Humble Bundles
29+
"hmb_campaign": true,
30+
"hmb_medium": true,
31+
"hmb_source": true,
32+
33+
// Likely Google as well
34+
"itm_campaign": true,
35+
"itm_medium": true,
36+
"itm_source": true,
37+
2838
// Google Click Identifiers
2939
"gclid": true,
3040
"dclid": true,
@@ -40,6 +50,9 @@ var trackingParams = map[string]bool{
4050
"campaign_term": true,
4151
"campaign_content": true,
4252

53+
// Google
54+
"srsltid": true,
55+
4356
// Yandex Click Identifiers
4457
"yclid": true,
4558
"ysclid": true,
@@ -53,6 +66,7 @@ var trackingParams = map[string]bool{
5366
// Mailchimp Click Identifiers
5467
"mc_cid": true,
5568
"mc_eid": true,
69+
"mc_tc": true,
5670

5771
// Wicked Reports click tracking
5872
"wickedid": true,
@@ -87,6 +101,9 @@ var trackingParams = map[string]bool{
87101
// Branch.io
88102
"_branch_match_id": true,
89103
"_branch_referrer": true,
104+
105+
// Readwise
106+
"__readwiseLocation": true,
90107
}
91108

92109
// Outbound tracking parameters are appending the website's url to outbound links.
@@ -95,6 +112,20 @@ var trackingParamsOutbound = map[string]bool{
95112
"ref": true,
96113
}
97114

115+
var trackParamsPrefixes = []string{
116+
"utm_", // https://en.wikipedia.org/wiki/UTM_parameters
117+
"mtm_", //https://matomo.org/faq/reports/common-campaign-tracking-use-cases-and-examples/
118+
}
119+
120+
func isTrackingParam(param string) bool {
121+
for _, prefix := range trackParamsPrefixes {
122+
if strings.HasPrefix(param, prefix) {
123+
return true
124+
}
125+
}
126+
return trackingParams[param]
127+
}
128+
98129
func RemoveTrackingParameters(parsedFeedURL, parsedSiteURL, parsedInputUrl *url.URL) (string, error) {
99130
if parsedFeedURL == nil || parsedSiteURL == nil || parsedInputUrl == nil {
100131
return "", errors.New("urlcleaner: one of the URLs is nil")
@@ -106,7 +137,7 @@ func RemoveTrackingParameters(parsedFeedURL, parsedSiteURL, parsedInputUrl *url.
106137
// Remove tracking parameters
107138
for param := range queryParams {
108139
lowerParam := strings.ToLower(param)
109-
if trackingParams[lowerParam] || strings.HasPrefix(lowerParam, "utm_") {
140+
if isTrackingParam(lowerParam) {
110141
queryParams.Del(param)
111142
hasTrackers = true
112143
}

0 commit comments

Comments
 (0)