Encoded URLs in Email Links
Email links are deceptively fragile. A URL that works perfectly in a browser can break when embedded in an HTML email — not because of the URL itself, but because of the layers of encoding and rewriting that email clients and marketing platforms apply. Understanding how each layer transforms your URLs helps you avoid broken links and tracked-down campaign performance.
The Encoding Journey of an Email URL
A typical marketing email URL passes through at least three encoding stages:
Stage 1: Original URL
https://example.com/search?q=blue shoes&lang=en
The space in blue shoes and the & separator are problematic in HTML attributes.
Stage 2: HTML Attribute Encoding
When placed in an <a href="...">, the URL must be HTML-attribute-safe. Ampersands must be escaped as &:
<a href="https://example.com/search?q=blue%20shoes&lang=en">
If you omit the & encoding, HTML validators flag it, and some email clients misparse the URL — treating &lang as an HTML entity reference.
Stage 3: Click Tracking Wrapper
Marketing platforms (Mailchimp, HubSpot, SendGrid) rewrite links to track clicks. The original URL becomes a query parameter in the tracking URL:
https://track.platform.com/click?msgid=abc123&url=https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dblue%2520shoes%26lang%3Den
Notice the double-encoding: %20 became %2520, %3F became %253F. The tracking platform percent-encodes the entire original URL as a query parameter value, which re-encodes the existing percent signs.
Why Double-Encoding Happens
Double-encoding occurs when two independent systems each apply encoding without awareness of the other:
| Stage | Encoding Applied |
|---|---|
| Original URL | blue%20shoes |
| Tracking wrapper | Encodes % → %25, producing blue%2520shoes |
| User's browser | Decodes once → blue%20shoes (then needs another decode) |
A properly implemented tracking system decodes the url parameter before redirecting. The browser then decodes the resulting URL normally. But if the tracking system does not decode, or if it decodes only partially, the user lands on a URL with literal %20 in the query string.
Common Problems with Email URLs
Spaces and Ampersands in HTML Attributes
The most frequent email link bug is an unencoded & in href:
<!-- Broken: &lang looks like an HTML entity -->
<a href="https://example.com/search?q=shoes&lang=en">
<!-- Fixed: ampersand is HTML-encoded -->
<a href="https://example.com/search?q=shoes&lang=en">
This is not URL encoding — it is HTML encoding. The browser decodes & back to & before making the HTTP request. But email HTML parsers, especially in older clients like Outlook, may not perform this decode step correctly.
Fragment Identifiers Stripped by Trackers
Click tracking redirects via HTTP 302, which strips the fragment identifier (#section) from the URL. If your deep link depends on a hash fragment, the user lands on the page but not at the intended anchor.
Workaround: use server-side redirects that preserve fragments, or move the target information into a query parameter and scroll via JavaScript.
URL Length Limits
Each encoding layer inflates the URL length. A URL with several Unicode query parameters can quickly exceed the 2,048-character limit imposed by some email clients (Outlook) or tracking platforms:
| Layer | Overhead |
|---|---|
& HTML encoding | +4 chars per & |
%XX percent-encoding | +2 chars per non-ASCII byte |
| Tracking wrapper prefix | ~80 chars for the tracking domain and message ID |
Monitor total URL length when building personalized email links with long parameter values.
Testing Email Links
Checklist Before Sending
- Validate HTML: Run your email template through an HTML validator. Every
hrefshould use&instead of bare&. - Test click tracking: Send a test email and click every link вручную — verify the final destination URL matches the original.
- Check decoding: Look at the browser's address bar after the redirect. If you see
%25in the URL, the tracking system is double-encoding. - Test across clients: Outlook, Gmail, Apple Mail, and Yahoo all parse HTML differently. A link that works in Gmail may break in Outlook.
- Verify fragments: If your link includes
#section, confirm the anchor scrolls correctly after tracking redirect.
Quick Decode Test
// Check if a URL is double-encoded
function isDoubleEncoded(str) {
return /%25[0-9A-F]{2}/i.test(str);
}
isDoubleEncoded('blue%2520shoes'); // true — double-encoded
isDoubleEncoded('blue%20shoes'); // false — properly encoded
Key Takeaways
- Email URLs undergo multiple encoding layers: HTML attribute escaping, URL percent-encoding, and tracking wrapper encoding.
- Always use
&for ampersands in HTMLhrefattributes — this is HTML encoding, not URL encoding. - Click tracking systems percent-encode the original URL as a parameter, which can cause double-encoding if not decoded before redirect.
- Fragment identifiers (
#) are lost during HTTP 302 redirects used by most tracking systems. - Test all links across major email clients before sending campaigns.
Try It Yourself
Debugging an encoded URL from an email campaign? Paste it into the URL Encoder to decode it layer by layer, or use the URL Parser to inspect individual query parameters and identify double-encoded values.