Call us Toll-Free:
Email us


Affiliate Links Plugin

Dawn Rossi, 03-25-2008
If you run a blog or forum, you already know one of the best ways to monetize your site is Affiliate Marketing.

When you write about a particular product or service, you can easily inject the proper affiliate links, earning commissions for all generated sales.

But what about user comments?

When users drop comments on your posts, you have no control over their content...

What if there was a way to automatically turn key phrases in user comments to affiliate links?

So when a user writes "I found a great deal on Amazon", a script will automatically replace the word Amazon with your Amazon affiliate link.

There are lots of plugins that handle basic keyword find/replace. I recommend you look at aLinks by Headzoo (it's free)


Existing plugins are limited to handling a very basic find/replace.

All the plugins I tested fail when -

1. User post their own unique Commission Junction / Azoogle / ClickBank affiliate link

2. User post a direct link to a site (

So I went on to develop a new plugin for one of our clients who is launching a full featured eCommerce site, with its own blog and forum.

My design goals were: Easy integration with vBulletin + WordPress ; Support basic find/replace as well as the two popular exceptions I found.

I had some old code we wrote for a little deals site you might have heard about. The old code was using RegEx which is clean but wasn't going to work here because my plugin was set to test 100,000+ phrases per each post. RegEx is slow.

Had to rewrite everything from scratch.


My new Affiliate Links Plugin is an elegant UpdateAffiliateLinks() php function that can be integrated with vBulletin + WordPress, updating the content of the post/comment prior to it being saved in the database:


The plugin reads a pipe delimited file that contains all the rules to be processed. Upon calling the UpdateAffiliateLinks() function, all rules are processed one by one and the content of the message is updated.

The rules file format is:


domain = Search string to look for
parameter = (optional) Parameter whose value we want to replace
value = (optional) new value for parameter
newdomain = (optional) completely new string to replace domain with
lastpath = (optional) replacement variable for the last url path
separator = (default is =) character identifying how parameter and value fields are separated.


Replace the word Zappos with an affiliate link to the home page of Zappos:


Replace an Amazon affiliate ID with another (useful for cases where a user posts their own Amazon affiliate link):


Replace a Commission Junction ID with another (useful for cases where a user posts their own Commission Junction affiliate link):


Replace a specific parameter:


ty, 06-03-2008
cool blog. I'll give this a try. Do you have one written for PHPBB3?
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

Post your comments

Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.

About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions