An Affiliate Link Tagging Textpattern Plug-in ¬

2016-07-20

Now that I’m independent and posting more frequently, I’ve joined the iTunes Affiliate Program to help the site earn its own keep. I host this site on Textattern, an excellent, light weight, and very flexible CMS (Content Management System) and—wanting to work smarter, not harder—decided to write a plug-in that could automatically rewrite any iTunes/iBooks/App Store affiliate URL I post in an articles using my iTunes Affiliate Program ID. This will make it easier to just copy links to music, books, or apps from the appropriate store and not have to run them through a different tool to appropriately tag them to hopefully earn a little commission.

Let me introduce the new mta_affiliate Textpattern plug-in. It’s a simple plug-in which, once installed, gives you a pair of preferences to enable URL rewriting and enter your iTunes Affiliate Program affiliate ID. It provides a <txp:mta_affiliate></txp:mta_affiliate> container tag which you can then use in your pages/forms to automatically rewrite any iTunes Affiliate Program URL (“clean” or “legacy”, see Advanced Affiliate Linking) contained within (including those produced by other Textpattern tags). In my case, I wrapped my article bodies with this tag, as well as a some custom fields which I generally store URLs in and output from.

I had previously developed similar functionality for Small Dog Electronics, though not in the same way, so this is far from my first time working with iTunes Affiliate Program URLs or the concept of parsing & rewriting URLs within content. I intend to support further affiliate programs in the future.

Download the latest version from the development page, the GitHub project, or Textpattern.org. You can get usage assistance, report any issues, and request additional affiliate programs support in the Textpattern Plugin support forums.

  Textile help