yourlslogo

There are plenty of options available to shorten the links that you share across the internet and this service really started its boon when Twitter and the 140 character tweet limit came about.  With space at a premium services like bit.ly, TinyURL, tr.im and others became necessities.

Of course when you use a commercially available service you are putting all your eggs in one basket and if that service was to ever go defunct then you have lost your shortened links and any data connected to them such as analytics.  If you used those heavily then a lot of folks are going to get 404 notices that the info is no longer available.  Not cool.

So ultimately the best level of control is to control it yourself and that is where Your Own URL Shortener or Yourls comes into play.

Yourls is a set of PHP scripts that lets you create and manage your own URL shortening service.  There are options to make it a public service or you can keep it completely private and for your own/close friends use.  From my research I would recommend keeping it private as it seems anyone who goes public with their service gets over run with spam links in their database.

Yourls also has a great set of features:

  • Private (your links only) or Public (everybody can create short links, fine for an intranet)
  • Sequential or custom URL keyword
  • Handy bookmarklets to easily shorten and share links
  • Awesome stats: historical click reports, referrers tracking, visitors geo-location
  • Neat Ajaxed interface
  • Terrific Plugin architecture to easily implement new features
  • Cool developer API
  • Friendly installer
  • Sample files to create your own public interface and more

The minds behind Yourls are Lester Chan (@GamerZ) who had the initial idea and Ozh Richard (@Ozh) who is carrying on current development.

The entire reason I am writing this post is because I chose to go with Yourls to create my own URL shortening service so that I can maintain complete control over my data.  I have used bit.ly Pro’s features to do my first personalized shortener (http://clkon.us) but have had issues with exceeding their API for some reason so I thought it was time to move on.

So the second part of this post is to share with you the overview of how I went about getting Yourls set up on my server and implemented.  I will not attempt to repeat the detailed instructions provided at the Yourls.org because they work very well.

I did have to search for some additional info on how to set up my favorite Twitter application, Tweetdeck, to use the custom service so I will also share that info to help you out.  It also comes in handy with other applications that can use custom URL shorteners.

Here is the sequence of events and my tips:

  • Get a URL.  Obviously the shorter the better.  These days that can be a challenge so think about using some lesser used Top Level Domains (TLD’s) such as .us or the more exotic foreign ones.  Be warned those foreign ones can come with a high yearly price.  I opted to go with srtn.us (Shorten Us) for my shortening service.  I did not move clkon.us because that would break all the links I already have out there under the bit.ly Pro service. Anyway, srtn.us is one character shorter than clkon.us is.
  • Once you have the domain you need a place to host the service.  I opted to host it along with my other sites at my host, www.websitesource.com, but you can choose most any host that supports PHP scripts and a mysql database.
  • After the domain is setup follow the instructions at Yourls.org to provide your database details and setup the user names and passwords.  Then all the files get uploaded to your server.
  • Once everything is setup I opted to use the Yourls WordPress plugin (info located at the Yourls.org website) to tie together this blog and Twitter.  Once the service is setup and you install this plugin it will go through the process of creating short URL’s for all of your blog posts.  Depending on how many you have this could take a while.  I had over 2500 total so it took about 12 hours.  It takes a good easy pace so your server does not get overwhelmed.
  • Any service or website that allows you to use a custom URL shortener is compatible with Yourls.  Just replace the domain name with the one you picked and the signature comes from the Yourls install and can be found on your Yourls Tool page. The custom URL is
    • http://XXXXXXXXXX.XXX/yourls-api.php?signature=XXXXXXXXXX&action=shorturl&format=simple&url=%@

Once your set up just explore the admin interface and look at the analytics you get with your new URL shortening service.

yourlsadmininterfacescreenshot yourlsstatscreenshottrafficstats
yourlsstatscreenshottraffictrafficlocation yourlsstatscreenshottraffictrafficsources

If you have any questions leave a comment and I will try to help out.