Shorten a URL – Track a Link

I recently asked in a couple of issues of the PCIN newsletter if anyone had any suggestions for me. I wanted to shorten links without having to use a service like TinyURL.com and at the same time, track the popularity of these links (how often they were clicked). I did receive a few responses, with a few being particularly interesting:

Steve Henthorn suggested http://shorl.com/. At first glance, this seemed perfect. It gives you a username and password for each shortened URL you make which gives you access to stats. But unfortunately, each URL has a unique username and password, which would make it difficult to manage.

Shawn Bremner suggested http://www.scriptme.com/SmE_Short_Url.html. This is a script that is supposed to help you setup a service like TinyURL.com that you can host (allow others to use your script). This wasn’t really what I was looking for, but I thought if I could let other people use it, then why not use it myself and disable other users. I tried to install the script, and I just couldn’t get it to work.

Silvan Kuipers suggested that I use built-in web server features, inparticular use the 404 redirection of Apache. He referred me to http://www.sitepoint.com/article/guide-url-rewriting which has a nice writeup of how to rewrite URLs. This is an area I don’t have experience in, and seemed difficult so that was as far as I got with it.

So, I headed to ScriptSearch.com to look a little closer. I scanned the categories, and found one called Click Tracking and one called Redirection. A script called CJ Linkout seemed like what I wanted, but again, I couldn’t get it to work. The main page of the script is called linkout.php, so I did a search for that and came across a tutorial where someone walked people through how to setup a PHP link tracking redirection tool. Since it runs locally, it has the natural effect of shortening a URL.

Outwards Link Counter
http://www.joe2torials.com/php/php_outwards_link_counter.php
This will allow you to create a script that will count the amount of times a certain link has been clicked and display the results on your page.

I had a few problems setting it up, but I got through it fine, and it works perfectly! I have added some things to the script, setup an admin area, and will start using it live this week. Once there is some stats, I’ll tweak the reporting pages a little more, and then release the script for everyone to use.

Stay tuned…

Comments 1

Leave a Reply to JenniferCancel reply