Set up your own link shortening service

One of the obvious yet overlooked little things I do is have a simple link shortening service of my own, cspenn.com. I find having my own link shortener to be invaluable for four major reasons:

1. Easy to remember permanent shortlinks. Every day I start off with a welcome message. Instead of having to remember other services’ links, I just have to remember my domain and the URL for the welcome page: cspenn.com/w. Nothing easier to remember. I’ve got Facebook, Twitter, and Google+ wired up the same way, with easy to remember URLs like cspenn.com/f, cspenn.com/t, and cspenn.com/g.

This is even more important in a word of mouth culture: if anyone asks me for one of these URLs, it’s easy for them to remember, too. Make your links easy to remember and people will share them more easily.

One cautionary note: services like Google and Bit.ly tend to frown on redirects of redirects, so if you’re being social with clients like Tweetdeck, etc., you’ll want to make sure your shortened links don’t get re-shortened if possible.

2. Easy redirects of affiliate links. Most affiliate links are horrendously long affairs that are highly subject to error, even when copy-pasting. What’s worse is that depending on where you make the error, an affiliate link that’s mistyped may still function, getting a visitor to the correct destination, but will fail to give you credit (and therefore commission). Solve this with your custom link shortener so that you only have to set up an affiliate link once, then use your link shortener the rest of the time on your site ads.

For example, if I had to remember this every time I wanted to plug TweetAdder:

http://www.tweetadder.com/idevaffiliate/idevaffiliate.php?id=10695_0_1_3

I’d probably go nuts. But cspenn.com/ta is much easier to remember and far less prone to errors and copy pasting problems.

Here’s another angle a lot of affiliate marketers forget: sometimes, affiliates go bad. They stop paying, or they flat out shut down. If you’re posting content out there (which is in turn getting scraped, linked, excerpted, reposted, etc.) with clear affiliate links, then if you have an affiliate that goes bad, you can’t do anything to change those links that are out of your control. If you use your own link shortener, you can simply change where the redirected link goes to and move that traffic to a different affiliate.

3. Easy implementation of Google Analytics tracking codes. If you’ve been at any of my talks, read my blog posts, etc., you know how much I harp on using Google Analytics tracking codes in your links and campaigns. Be honest: you probably don’t most of the time because it’s not a whole lot of fun to set those up over and over again. If you have a certain number of URLs you’re sharing over and over again (like links to downloads, content, landing pages, etc.) then take the time to set up the Google Analytics link tracking codes for those regular URLs once and stick them in your link shortener. Then you won’t have to remember to tag them with tracking codes and your traffic will get correctly attributed time and time again.

4. Shortened links under your control. As much as I love services like Argyle Social, bit.ly, etc., they are not under my control. At any point, they could be shut down, especially anything with a .ly domain (which is owned by the country of Libya and has caused problems in the past). For your average socially shared links, this may not be a big deal, but for your top links, your most important links? Don’t leave those in the hands of a service that isn’t yours.

Here’s another example. Imagine if I had set up cspenn.com/my years ago for MySpace. Any links I published promoting my MySpace profile years ago I could simply redirect now to Facebook or Google+ and have people going to the correct places now.

So how do you get started with your own link shortener? It’s fairly straightforward but not terribly user friendly. There certainly are plenty of other services and software that can do this sort of thing for you, but I tend to prefer simplicity where and when I can get it. Start by purchasing a domain name that’s relatively short and somehow relevant to you. I bought cspenn.com because it’s what I use in many places for my username. Get that domain set up with a cheapie Apache-based hosting account – no need to go pro for simple traffic redirection – and then start working on your redirection file.

For most Apache-based hosting services, there will be a file you can create called an .htaccess file. This is the file which specifies where you want to send traffic. For example, here’s a few lines from mine:

link shortener

The format of the redirects is fairly clear. I specify that I want to redirect (redirect 302 or redirect 301) the visitor from the shortened link (/l, /f, /t, etc.) to another destination. Choosing 301 or 302 depends on whether I’m linking to my own site or someone else’s site – 302 for everyone else, 301 for me. Why? Especially with affiliate programs, things can change, and the 302 redirect is better for that. But even for non-affiliate programs, it’s not a bad idea.

You can see that for shortened links to my site, I’ve got all of my Google Analytics tracking codes implemented so I don’t have to remember them.

Is running your own link shortener a good idea? I think so, and it’s dirt cheap to do. It gives you far more control over your most important links, makes things easier to remember, and protects your most important links from unexpected changes down the road. If the technical implementation is a bit harder than you’re comfortable with, hire a local nerd to help you out and get set up. It’ll be worth it, especially in a few years when you find you need to redirect all those worthless social network profile links to the network of the future.


If you enjoyed this, please share it with your network!


Want to read more like this from ? Get daily updates now:


Get my book!

Subscribe to my free newsletter!


  • http://www.scottwyden.com scottwyden

    I have my affiliate redirects as 301.  Should I change those to 302?

  • http://mikewills.me Mike Wills

    Or you can use Youlrs. An open-source link shortening software.

  • http://danieljohnsonjr.com/ danieljohnsonjr

    I wound up setting this up through my webhost, using djjr.me