Bottom Line: Here’s a Workflow Extension I made to generate iTunes and Amazon affiliate links and shorten them with Bitly.
Like many bloggers, as part of my “tech fund” that pays server costs and keeps n8henrie.com up and running, I participate in the iTunes and Amazon affiliate programs.
While my favorite way to generate affiliate links — no contest — is Brett Terpstra’s Searchlink, the mechanisms for generating the links on iOS are less polished. (Though I found this effort to port SearchLink to Pythonista interesting.)
However, I recently realized that a Workflow Extension seems like a pretty smooth way to generate these links. You can send a URL to an extension from the iOS App Store using the share button (top right) followed by choosing your extension down below (Workflow in this case).
I also wanted to make sure that my extension could accept URLs from the Safari share button when viewing an Amazon item and return a suitable link.
Finally, instead of returning a big ugly URL, I took advantage of a u/akhandar‘s work posted at Reddit to have the workflow shorten the link with Bitly. I have a custom domain tied into Bitly, so I get returned convenient little n8h.me links.
I had to do a fair amount of tweaking and testing, but I think I have the extension fairly dialed in at this point. To customize it for yourself, you’ll first need to change the 3 placeholders up top (which are indicated by the variable name they’re stored in beneath each bit of text). Replace my info with your Amazon Affiliate tag, your iTunes Affiliate code, and a Bitly oath
access_token, which you can get as a
Generic Access Token at the bottom of this page. Please note that I have expired the Bitly access_token you’ll see, so you will at minimum need to change that value before it will work even for testing.
The workflow itself tried to filter out URLs from the passed in text, uses
expand URL to try to clean it up, applies the appropriate tags based on whether the host is amazon.com or apple.com, then shortens and copies to the clipboard. Feel free to do some testing with Redirect Detective to verify it seems to be working properly.
Once your values are plugged in you should be set to go! Give it a whirl and let me know if you run into any trouble — here’s the Workflow.