Using bit.ly (trackable URL shortener) with Twitter Tools in Wordpress
I wrote in this article about using Twitter Tools with tweetburner (the twurl.nl URL shortener). I was pretty happy with this solution as it allowed me to measure (to a degree) the traffic interest in various blog posts I put up, be it for WiAU, Cognicology or this blog. It wasn’t the perfect solution however, as the version of Twitter Tools the modified update used was a little old and I always have that little nagging feeling that doesn’t go away when using modded or hacked software.
The deal-breaker for me came when I read an article reviewing the large number of URL shortener services out there. It turns out that tweetburner uses 303 redirection as opposed to 301, which is not ideal for many reasons (see this article for the reasons why, thanks to @problogger).
In the time between my first article and this discovery about the redirection, I had read in the Twitter Tools readme that the developer had created a hook in the code to allow the plugging in of a URL shortening service – the appropriate plugin for wordpress simply needed to be developed, packaged and installed.
Unfortunately, I couldn’t find a decent package for a URL shortening service using the API calls required to work with Twitter Tools on the wordpress site. After a bit of a search, I found this code snippet that implemented the bit.ly shortening service. This got me excited, because the bit.ly service was on the shortlist of services that I wanted a plugin for. It is one of the shorter URLs generated (14 chars), has some impressive usage tracking and can link multiple twitter accounts to the one bit.ly account. Ace!
I’ve taken the code snippet and packaged it into a ZIP file for upload into the Wordpress plugin manager. You can download it here.
Installing is relatively simple.
1. install and activate the Twitter Tools plugin.
2. install the Bit.ly plugin from this site.
3. BEFORE you activate the Bit.ly plugin, use the inbuilt plugin code editor for wordpress, and change the $login and $api_key values to your bit.ly account login and API key. It is in the first section of code and looks like this (change the bits in red):
function tweet_track($long_url) {
$login = 'YOUR_LOGIN';
$api_key = 'YOUR_API_KEY';
4. Activate the plugin.
If all is well, you should now be able to to have post submitting to Twitter, but using the bit.ly service as the URL shortener.
DISCLAIMER: This post itself is also doubling as my testing post for this method. I may or may not be embarrassed by the results.
——
UPDATE (20/4/09 ; 2.5 minutes later): It seems the plugin installation was a success!
Below is the text from my twitter status update:
New blog post: Using bit.ly (trackable URL shortener) with Twitter Tools in Wordpress http://bit.ly/bRa58




