New URL shortening service
Something we’ve talked about for years is creating our own URL shortening service.
A couple of months ago Duncan and I sat down one Friday afternoon and created a very basic one using only household objects.
What URL shortening is
As the name suggests, a URL shortening service takes a long web address—something that is either difficult to remember, or too long to include neatly in a print publication—and creates a much shorter address that forwards users to the original, long one.
For instance, this URL:
http://tinyurl.com/hv2bqn9 (26 characters long)
redirects users to this blog:
http://digitalcommunications.wp.st-andrews.ac.uk (49 characters long).
While Bitly offers an enterprise edition it costs approximately US $995 per month, which is somewhat expensive for our requirements. There are also self-hosted options available such as php-url-shortener and Yourls, but we challenged ourselves to create something using only the tools that we had, essentially as a cheap feasibility exercise to find out if we actually used the tool and what features we needed.
We settled on using the HTML meta http-equiv=”refresh” attribute and our content management system, TerminalFour Site Manager (T4).
Short domain name
The first thing was the domain name.
As it happens, we already had that: the University’s original domain name is actually still lurking in the background—and it still works: st-and.ac.uk.
The short URL is not permitted for use in any publications or in email signatures, but it’s perfect for this, and already we’ve saved eight characters on any URL.
In T4 we created a new section called “Short URLs (st-and.ac.uk/go/)”.
We knew that we’d need to keep the shortened URLs together in a section—we couldn’t just let them roam wild on the root of the domain—so we gave the section a URL of
/go/ which was both short and gave it a sense of urgency and purpose.
Each shortened URL is a separate section, and each has a specific naming convention: short-url/ – meaningful description.
Within these sections we created a new content type in T4. Each shortened URL requires the following information:
- Name—a meaningful name, used internally by T4.
- Page title—what Google Analytics will call the page (we generally use the same name as Name, above).
- Destination URL—this is the long URL.
- Requester name—this is the key contact who asked for the redirect to be created, someone who is responsible for the redirect.
- Requester email—contact details for the above contact.
- Description—a justification for why the redirect has been created.
As well as these fields, we may also choose to fill in the publish and expiry dates for the content item. This way we can ensure that a redirect, for instance, is live for only 6 months and expires automatically.
We slapped a Google Analytics code on the redirect page and now we can also track which URLs are being used.
The final result
Wait an hour for the publish cycle to complete and lo and behold! we have our own redirect service.
We now have a St Andrews-specific short URL for this blog:
http://st-and.ac.uk/go/dct (26 characters)
This is the same length as the Bitly version.
Get access to this service
If you are a staff member with moderator access to T4 and would like access to this new service please simply contact the digital communications team at [email protected].