March 16, 2014

My First WordPress Plug-in – Affiliate Link Labeler

In my never ending quest to learn about the business of blogging I recently stumbled onto FTCs rules for .com disclosure. I had previously setup a disclosure page, and often mentioned the types of revenue from my blog (namely Adsense and Amazon Affiliate links), but I realized I could do better.

The basic premise from the FTC’s release is that any visitor should know a link is sponsored, before viewing said link, regardless of what device they’re on.

With roughly 300 posts I didn’t relish the idea of labeling every post or link by hand. Manual processes like these are prone with errors, and I was sure to make one. A better solution was a plug-in to automate the process. Since I only use one affiliate program, it’s a pretty simple to automatically parse my blog posts looking for affiliate links. Alas, the only affiliate plug-ins I found were designed to cloak (i.e. hide) the fact that a link was an affiliate link – the exact opposite of what I wanted to do! I finally had an excuse to write my own plug-in.

Writing the plug-in ended up being easier than I thought it would. The harder question was coming up with a labeling scheme I liked. I didn’t want anything to interrupt the prose of the post. I decided to go with an “affiliate link” title to all affiliate links’ <a> tags. Now when you hover your an affiliate link, you see a little pop box that properly identifies the link. I’ve seen this method used before, namely by I’ve verified the title also appears on my blog posts in, and

There is just one problem.

The devices used to view my blog in 2013

Over half of my web traffic is coming from a mobile device or a tablet and there is no concept of “hover” on such devices. Affiliate links are still unlabeled on these devices. Since I wanted to minimize the time I was not compliant with the FTC, I decided to bite the bullet and add a disclaimer to the top of each blog post using my plug-in. I hope to come up with another solution in the future.

Side note: Apparently there’s a belief out there that search engines will demote pages with affiliate links, hence the prevalence of affiliate link cloakers. While I have no first hand knowledge of the truth of this, it feels like an old wives tale to me. In fact, cloaking is probably counter productive. It’s trivial for a computer program to find where a cloaked link leads. If there’s one thing I’ve read about SEO time and time again, it’s engaging in deceptive practices, like cloaking, will eventually negatively impact your ranking.

Posted in Internet & Technology | Tags:



  1. […] upgraded the version of PHP running on the server. Unfortunately one of the plugins (not the one I wrote, phew) I was using was incompatible with new PHP. It was relying on a technique that was so […]

  2. […] Amazon gift cards have arrived, and I’m distracting myself from my morning all-day sickness by thinking about baby […]

Leave a Reply

Your email address will not be published. Required fields are marked *