Set up your own link shortening service

Warning: this content is older than 365 days. It may be out of date and no longer relevant.

One of the obvious yet overlooked little things I do is have a simple link shortening service of my own, 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: Nothing easier to remember. I’ve got Facebook, Twitter, and Google+ wired up the same way, with easy to remember URLs like,, and

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 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:

I’d probably go nuts. But 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,, 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 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 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.

You might also enjoy:

Want to read more like this from Christopher Penn? Get updates here:

subscribe to my newsletter here

AI for Marketers Book
Take my Generative AI for Marketers course!

Analytics for Marketers Discussion Group
Join my Analytics for Marketers Slack Group!


5 responses to “Set up your own link shortening service”

  1. Christopher, I have been running as my shortener since December 2009.  I use an open-source script called YOURLS (Your Own URL Service) that is free to download.  

    Essentially, if you have a hosting account that is capable of hosting WordPress, then you can use YOURLS.  (On a totally different domain, naturally.)

    The thing I love is I get metrics and analysis — and there is a Google Analytics plugin too!  Additionally, it gives me bookmarklets and a complete API for integration with other services — I can make a shortURL on as quickly as I can on, and without touching an .htaccess file.

    Granted, I am a non-coder who is slightly more geeky than most non-coders, but I was able to set it up in under an hour.  Took a couple of tweaks to lock out the rest of the world, but I know how to talk people through it now.

    The big advantage for me, from a branding perspective, is I’m the only one in the world who can make an link.  It cannot be spoofed.  I can also edit them after the fact, as I did when I redirected from my personal profile to my Ikeville page.

    Be happy to talk with you about setting it up, Chris… it’s been a dream.  (Or I can bake you in a login on mine, and let you see the backend.

    You know where to find me…

  2. There’s also that you can run on your server, much like WordPress and Google Apps for Business will add a shortener to your verified domain with a simple CNAME record update. 

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

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

  5. I wound up setting this up through my webhost, using

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This