Hack 69 Create Amazon Associate Links on Your Movable Type Weblog


Integrate Amazon and Movable Type, and you'll be posting about books to your weblog in no time.

Using external tools to integrate Amazon links into your web publishing system is helpful, but ease of use depends on features being built directly into the software you use to publish. That's the thinking behind Movable Type's plug-in system, and MTAmazon is a plug-in that can do much of the integration work for you.

Amazon.com product links, wish lists, and more can be automatically inserted into web sites managed by Movable Type thanks to MTAmazon, a Movable Type plug-in for Amazon Web Services.

Amazon Web Services (AWS) connect Amazon's databases with associate sites, showing search results, buttons to buy products, users' wish lists, and the contents of product categories without requiring the associate to make manual updates. For sites that use Movable Type, the MTAmazon plug-in provides a simple way to make use of AWS.

You can download MTAmazon and get instructions on installation and basic usage from the MTAmazon web site at http://mtamazon.sourceforge.net/.

Provide MTAmazon with a product ID, search string, or the list ID from a Wish List, Listmania! list, or product category, and it will retrieve a wealth of product information and provide Movable Type template tags with which to display it. If you know the ASIN for a product, you can insert a picture of it, the title, the price, and a button to add the item to the Amazon shopping cart.

<MTAmazon search="B00003CWT6" method="Asin" lastn="1">
<img src="<MTAmazonMediumImage>" align="left" border="0" hspace="5" />
<b><MTAmazonTitle></b><br />
<p>Amazon Price: <b><MTAmazonSalePrice></b></p>
<form method="POST" 
<input type="hidden" name="asin.<MTAmazonASIN>" value="1">
<input type="hidden" name="tag-value" value="<MTAmazonAssociateID>">
<input type="hidden" name="tag_value" value="<MTAmazonAssociateID>">
<input type="hidden" name="dev-tag-value" value="<MTAmazonDevToken>">
<input type="submit" name="submit.add-to-cart" value="Buy From [RETURN]

That's great, but it requires you to code the product's ASIN into your templates. The plug-in wouldn't be very useful if you had to change your templates every time you wanted to link to a different product. Fortunately there's a way to use content from Movable Type in the MTAmazon code. For instance, someone writing a book review in Movable Type can store the ISBN of the book in the entry's keyword field and use that ISBN to automatically insert a picture, price, and link to Amazon.com. Simply use the <MTEntryKeywords> tag as your search attribute.

Movable Type typically won't let you use one MT tag as the attribute for another, but MTAmazon will let you fake it with a special tag format. If you use the tag name with square brackets around it, MTAmazon will evaluate the tag and use the output as the attribute value. For example, in the case of our book review:

<MTAmazon search="[MTEntryKeywords]" method="Asin" lastn="1">

MTAmazon can evaluate more complex expressions as well. This example will use the titles of the last five entries as the keywords for a book search:

<MTAmazon search="[MTEntries lastn="5"][MTEntryTitle] [/MTEntries]">

Movable Type tags are available only in templates, so to include links or images in your weblog entries, you'll need another plug-in. Process Tags (http://kalsey.com/2002/08/process_tags_plugin/) will let you use MTAmazon and other MT template tags in your entry bodies. With this plug-in, you can add associate links to books, movies, or games that you mention in your weblog.

<a <MTAmazon search="0425170349" mode="Asin"> href="<MTAmazonLink>"[RETURN]
title="<MTAmazonTitle>"</MTAmazon>>this book</a>

One of the disadvantages to using Web Services to automatically insert associate links is that you may earn a lower commission on sales made through those links. Sales from AWS links earn only a 5% commission, while other links can earn up to 15%.

To take advantage of MTAmazon but still earn the higher commission, you'll need to replace the product links that MTAmazon generates with your own links. An Amazon associate URL is always in the format:


MTAmazon has tags for both the product's ASIN and your associate ID. You can use these to construct associate links that will earn you greater commissions:


?Adam Kalsey