Slug: implementing-machine-tagging Date: 2007-08-08 Title: Implementing Machine Tagging layout: post

Ok, so last week Jodi and Adelina were off in Colorado (I’m sure Jodi will blog it soon), so I was home alone quite a bit. So what did that mean? Hackery!

After exploring some machine tagging and some UI bits and pieces for machine tags on the site, I spent some time completely rewriting my machine tagging code. I started with blog:via as my first machine tag, then quickly added tags for movies in Netflix (netflix:id), books at Amazon (book:isbn) and other Amazon products (amazon:asin). Here’s a post with a blog:via tag and a book:isbn tag. And here’s one with a netflix:id tag and an amazon:asin tag.


I’ll admit, the implementation is still a bit scattered. This blog is powered by WordPress, so to start with the tags themselves are added to posts via a custom field called ‘machinetags’ - one entry for each tag:


WordPress’s template tags make it easy to get at those values as an array, which I pass to a WordPress plugin I wrote just for this. The plugin builds the initial display for the related items, adding ids and classes as hooks for the next bit.


When the page loads, I wrote some javascript (using JQuery) that attaches custom event handlers to the click events for the “more posts” and “view” links. The handlers fire off ajax calls, so that I’m not making a lot of ajax calls as the page initially loads (which would increase page load times for something that only some readers are going to be interested in).

As you can see here, clicking the links loads related content inline:



So far, all my tags live here on this site, attached to my posts. Jeremy Keith uses this same strategy, and adds a “tags in the cloud” tactic - assigning adactio:id=... tags to photos on Flickr, then doing a Flickr search to pull in photos when a post is viewed. I may explore this a bit more - I’ve been thinking about using Amazon’s tagging feature to add a monkinetic:id=... tag, then doing the lookup that way, but for products it feels more appropriate to have the hook/tag on this end.


Machine tagging is going to succeed or fail on the strength of the APIs that services offer. Amazon, while not being a posterboy for Web2.0, has an amazing REST API that is pretty easy to work with once you get the hang of it. (I’m using a technique that - acronym alert - runs Amazon’s XML output through an XSL stylesheet hosted on my server via Amazon’s own XSLT service to produce JSON.) I use it for looking up books as well as any other product Amazon offers.

Netflix, on the other hand, has no API, and I had to resort to figuring out the URLs that use Netflix’s internal movie ID to make a link to the site and grab the cover thumbnail. I would love to actually show the movie title and average rating, but there’s no api for it.

I also looked at IMDB but could not find even so much as a predictable way to devine a movie poster image from an IMDB title id, so while I may add imdb:title=... tags to some of my posts, I won’t be able to provide related content inline. This is really a pity, as both Netflix and IMDB are probably afraid that if they provide easy access to their content via an API, competitors might use it to disrupt their market. Well, that might be the case, but there are a LOT of us out here who would love to send traffic to both Netflix and IMDB in more interesting ways.

##If you love something…

As Dave says:

>People will only trust a service that gives them complete freedom to come and go as they please. Further, they’ll want to come back if you send them to cool places.