# Cleaning

Before a link reaches any browser, Ferry cuts tracking parameters and unwraps redirect wrappers, and shows you exactly what it removed.

## What gets removed

<div class="pair">
  <div><span class="label">Before</span><code>https://example.com/a%2Fb?x=1&utm_source=news#frag</code></div>
  <div><span class="label">After</span><code>https://example.com/a%2Fb?x=1#frag</code></div>
  <div><span class="label">Trace</span><pre class="trace">Mail → ✂ utm_source → no rule matched (0 of 2) → ask</pre></div>
</div>

Ferry removes these parameters, wherever they appear:

| Parameter | From |
| --- | --- |
| `utm_*` | Analytics campaign tags (`utm_source`, `utm_medium`, and the rest) |
| `fbclid` | Facebook |
| `gclid`, `dclid` | Google Ads, DoubleClick |
| `msclkid` | Microsoft Ads |
| `mc_cid`, `mc_eid` | Mailchimp |
| `igshid` | Instagram |

## Redirect wrappers

Some apps don't link to a page directly. They link to their own server, which then redirects. Ferry skips the detour.

<div class="pair">
  <div><span class="label">Before</span><code>https://www.google.com/url?q=https%3A%2F%2Flinear.app%2Facme&sa=D</code></div>
  <div><span class="label">After</span><code>https://linear.app/acme</code></div>
</div>

| Wrapper | Real link is in |
| --- | --- |
| `google.com/url` | `q` |
| `l.facebook.com/l.php` | `u` |
| `slack-redir.net/link` | `url` |
| `*.safelinks.protection.outlook.com` | `url` |

Unwrapping happens first, so your [rules](/rules) match the real destination, not the wrapper.

## What Ferry will not touch

Cleaning edits the link as text. Everything it doesn't remove is kept byte for byte:

- **Encoding.** `%2F` stays `%2F`.
- **Order and duplicates.** `?id=1&id=2` stays exactly that.
- **The fragment.** `#section` is never edited.
- **Anything not on the list.** Removing an unknown parameter such as `id` or `token` can break a link, so Ferry leaves it. When in doubt, it keeps.

When every parameter is removed, the `?` goes too. No dangling punctuation.

## Try it

```bash
ferry clean "https://example.com/?utm_source=a&fbclid=b&id=1"
```

```
https://example.com/?id=1
removed: utm_source, fbclid
```

## Turning it off

- **Everywhere:** **Settings › Advanced › Remove tracking parameters and unwrap redirects**.
- **For one rule:** add `clean = false`. Links that rule catches keep their parameters.

```toml
[[rules]]
name = "Campaign previews"
host = "preview.example.com"
intent = "work"
clean = false
```
