Tracking link maths

galaxy

How long does a tracking link need to be?

Let’s make it interesting, and say we want to be able to have a unique tracking link for every single atom in the observable universe.

That’s about 1080 unique links.

One hundred novemdecillion exa-links.

100,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000

If we have that many customers we can afford to buy an expensive domain name and dedicate it to click tracking. Let’s use “z.zz” as our example domain – that’s not implausible, there are domains that short in use by individuals.

So our URL is going to look something like this:

https://z.zz/<something goes here>Code language: HTML, XML (xml)

That’s 13 characters, plus the “something goes here” bit.

We need to encode 1080 different values. If we take the logarithm of that to base two it’s a shade over 265, so we can encode it in 266 bits of data.

We need to convert those 266 bits of data to a text string.

One of the regular ways of doing that is to use base64 encoding. We use that a lot in email already, to convert binary files to text so we can attach them to an email. Base64 uses a list of 64 different characters (A-Z, a-z, 0-9 and a couple more) to encode things, hence the name. 64 is 26 meaning we can encode 6 bits in each character, so with 44 characters we can encode 268 bits of information, which is more than enough. Adding in the 13 characters for the https bit gives us 57 characters in total, for a tracking link for every atom.

We can do better, though. If we read the spec for URLs carefully we find 21 punctuation characters we can use in the path of a URL. Adding A-Z, a-z and 0-9 gives us 93 characters. log2 of 93 is a little over 6.53, so we can encode 6.53 bits in each (ascii) character. 266 divided by 6.53 is about 40.5, so we need about 41 characters to encode every atom using Bas93 encoding. Adding in the 13 characters for the https bit gives us 54 characters.

So if you need to encode a click tracking link for every atom in the observable universe you can use a 54 character long URL that looks something like this:

https://z.zz/u,Oz0Xrp0_Xrz=0rX2IE?Ti62LF2)@a];tyu*qkhBCode language: JavaScript (javascript)

Fits on a single line without wrapping easily.

If you don’t have quite 1080 unique links across all your customers then you can make them a little shorter.

If you’re actually doing this you might want to use a slightly smaller set of characters. Something like Base85 with an alphabet that avoids “#” and “/” might be better, but you have a lot of encodings to choose from.

Related Posts

iOS17 filtering click tracking links

I’ve heard quite a bit of concern about what iOS 17’s automatic removal of click-tracking parameters means, but less discussion of what it actually does.

Read More

Clicktracking link abuse

If you use redirection links in the emails you send out, where a click on the link goes to your server – so you can record that someone clicked – before redirecting to the real destination, then you’ve probably already thought about how they can be abused.
Redirection links are simple in concept – you include a link that points to your webserver in email that you send out, then when recipients click on it they end up at your webserver. Instead of displaying a page, though, your webserver sends what’s called a “302 redirect” to send the recipients web browser on to the real destination. How does your webserver know where to redirect to? There are several different ways, with different tradeoffs:

Read More

Tools!

I just added a DMARC validation tool over on tools.wordtothewise.com.

You can give it a domain – such as ebay.com – and it will fetch the DMARC record, then explain and validate it. Or you can paste the DMARC record you’re planning to publish into it,  to validate it before you go live.
If you’ve not seen our tools page before, take a look. As well as DMARC we have a DKIM validator, SPF expander and optimizer, general DNS lookup tools, a bunch of RFCs covering all sorts of protocols, and base64 and quoted-printable decoders.
There’s also a widget that lets you add those little unicode pictures to your subject lines, whether you need a snowman ⛄, a forest ????, or a pig getting closer ???.
The results pages all have easily copyable URLs so they’re pretty good for sharing with co-workers or customers if you need that sort of thing.
(And if you need a cidr calculator, whois, or easy access to abuse.net & Microsoft SNDS check out Al’s xnnd.com.)

Read More