Skip to content
CleverKeys Wiki

URL Sanitization

CleverKeys can automatically strip tracking and analytics parameters from URLs as they enter your clipboard history. Copy a link with utm_source=...&fbclid=...&aff_short=... attached, and the version saved to your clipboard arrives clean: just the URL you actually want to share. The feature uses the ClearURLs ruleset and supports your own custom rules.

Quick Summary

WhatDescription
PurposeRemove utm_*, fbclid, gclid, aff_*, and other tracking params from copied URLs
TriggerRuns when text enters the clipboard history (system copy event)
ScopeClipboard only — typed text is never sanitized
FeedbackSilent — sanitized text replaces the original with no toast
DefaultOff — all three toggles default to disabled
AccessSettings → Clipboard → URL handling

How It Works

When you copy text containing URLs:

  1. The system clipboard change fires ClipboardHistoryService.addClip().
  2. The full clipboard text is run through a URL detector (regex over the whole text — handles multi-URL and surrounding prose).
  3. Each detected URL is matched against the active ruleset, which has ~100 providers like Amazon, AliExpress, Google, Facebook, Twitter, Reddit, plus a globalRules provider that handles the universal utm_* family.
  4. Matching parameters are dropped; non-matching parameters are preserved.
  5. The sanitized text is what gets saved to clipboard history (and pasted into your destination app).

The original tracking-laden URL never reaches the destination — it’s filtered at the moment of copy, not the moment of paste.

Three Independent Toggles

All in Settings → Clipboard → URL handling:

ToggleSetting keyWhat it does
Sanitize tracking parametersclipboard_sanitize_links_enabledMaster switch for the bundled ClearURLs ruleset. Strips utm_*, fbclid, gclid, per-provider trackers like AliExpress spm/scm*, Amazon ref/tag, etc.
Enrich embeds for sharingclipboard_embed_enrich_enabledSeparate ruleset that rewrites social-media hosts for richer link previews (x.comfxtwitter.com, reddit.comrxddit.com, etc.).
Use custom rulesclipboard_custom_rules_enabledLoad your own ClearURLs-format JSON. When enabled, a Browse… button appears for picking the file via SAF.

[!NOTE] The three toggles are independent. Enabling “Enrich embeds” alone does NOT strip tracking parameters — you also need “Sanitize tracking parameters” on for the bundled ClearURLs rules to apply. If you previously enabled sanitization and saw no effect, double-check the master toggle is on.

Worked Examples

Standard tracking strip

Copy:

Check this out: https://example.com/article?utm_source=newsletter&utm_medium=email&id=42

After sanitization (master toggle on):

Check this out: https://example.com/article?id=42

utm_source and utm_medium matched the global utm_* rule; id did not match any rule and was preserved.

Provider-specific (AliExpress)

Copy:

https://www.aliexpress.com/item/12345.html?spm=abc&scm_id=xyz&algo_pvid=123&utm_source=share&keep=value

After sanitization:

https://www.aliexpress.com/item/12345.html?keep=value

AliExpress’s spm, scm*, and algo_pvid matched the provider’s ruleset; utm_source matched the global rule; keep matched nothing.

Embed enrichment

With Enrich embeds for sharing on, a Twitter link becomes a fxtwitter link for better Discord/Slack/Signal previews:

https://x.com/user/status/12345  →  https://fxtwitter.com/user/status/12345

This is a redirect rewrite, not a parameter strip.

Custom Rules

Toggle Use custom rules to load your own ClearURLs-format JSON. The format is documented at docs.clearurls.xyz — a providers object keyed by name, each provider has urlPattern, rules (regex per-param to strip), rawRules (regex per-URL substring to strip), redirections, and optional exceptions.

After enabling the toggle, tap Browse… to pick the file via the Android file picker. It’s copied into the app’s private storage at <app data>/url_rules/custom.substitutions.json. The custom rules are MERGED with the bundled ClearURLs rules (if the master toggle is also on), with custom providers added alongside bundled ones.

[!TIP] Common reason to add custom rules: a small domain you use frequently isn’t covered by the bundled ~100 providers. Write a minimal urlPattern + rules block for it. The bundled set updates with app releases; custom rules let you patch in coverage between releases.

What This Does NOT Do

  • Doesn’t follow short URLs. bit.ly, t.co, etc. are not expanded — the rules can rewrite some short URLs to their long forms via redirect rules, but there’s no live HTTP resolution.
  • Doesn’t run on typed text. If you type a URL with tracking params directly into a text field, it’s not touched. Only clipboard inserts (system copy events) trigger sanitization.
  • Doesn’t notify you. No toast, no badge, no log entry. Sanitization is silent. To verify it’s working, copy a known tracking URL and inspect the clipboard history entry (Settings → Clipboard → History).
  • Doesn’t have per-provider granularity in the UI. You can’t toggle “strip Google only” — it’s all-or-nothing per ruleset. For fine-grained control, write a custom rules file with just the providers you want.

Troubleshooting

”I enabled the sanitizer but my AliExpress URL still has all the tracking junk”

Three things to check:

  1. Is the master toggle on? Settings → Clipboard → URL handling → Sanitize tracking parameters must be checked. Enabling only “Enrich embeds” or only “Use custom rules” doesn’t enable the bundled rules.
  2. Are the specific params in the bundled ruleset? AliExpress bundled rules cover spm, scm*, algo_pvid, gps-id, aff_request_id, ws_ab_test, btsid, mall_affr, terminal_id, cv, af, dp, sk. Params NOT bundled — like aff_short, pdp_npi, utparam-url, aff_platform — won’t be stripped unless you add a custom rules file.
  3. Did you copy the link, or paste a previously-saved one? Sanitization runs on the copy event. URLs already saved in clipboard history before you enabled the feature aren’t reprocessed.

”The sanitizer broke a URL I need”

If a domain’s urlPattern matches your URL but a rule incorrectly strips something useful, you have three options:

  1. Disable the master toggle when copying that particular URL (suboptimal).
  2. Write a custom rules file with an exceptions regex for that URL pattern.
  3. Report the bundled ClearURLs rule upstream at docs.clearurls.xyz.

Configuration Reference

SettingKeyDefaultRange
Sanitize tracking paramsclipboard_sanitize_links_enabledfalsebool
Enrich embedsclipboard_embed_enrich_enabledfalsebool
Use custom rulesclipboard_custom_rules_enabledfalsebool
Custom rules fileclipboard_custom_rules_uri(none)SAF URI / local path

Technical Details

See URL Sanitization Technical Specification for the algorithm, ruleset format, and code references.