Although geared more toward those building or working with larger systems that use affiliate links, I’m astounded how often I see large sites throw away link juice that their affiliates are giving them. In all honesty, building a simple affiliate system isn’t all that hard, and basically amounts to dropping a cookie based on the parameters of a given link. The parameters are typically an affiliate ID with some optional tracking variables to allow your affiliates to track specific campaigns and traffic sources (PPC, organic, banner.) The parameters can be embedded however you want, although typically they are in a query string of a GET request, such as:
http://www.somesitesellingstuff.com/affiliate?affid=bigsteve&campaign_id=first&media_id=ppc&product=footsoak
The contrived example above shows affiliate ‘bigsteve’ with a link from his ‘first’ ‘ppc’ campaign for a ‘footsoak’ product. Typically the links are more gross, but you get the picture. The parameters can also be encoded in the hostname itself. Clickbank encodes the product name and affiliate ID as a subdomain and a single 8-character tracking code into a “hoplink”:
http://bigsteve.footsoak.hop.clickbank.net/?tid=firstppc
The affiliate script simply strips out the appropriate variables, drops a cookie containing the variables and then returns the appropriate content. Pretty straightforward, except for that last part: delivering the content. On most sites, they return the content with an HTTP 200, which isn’t a good idea – it’s returning the same or really similar content for several different URLs. Don’t forget, most affiliates drop their link directly on their sites, forums and articles, rather than bouncing through a redirect. This effectively dilutes a bunch of free link juice!
The solution is to change your affiliate script slightly so instead of setting the cookie and serving the content, it redirects (301 please) to a logical page. In fact, the whole operation can be done using Apache mod_rewrite! A lot of this depends on what you’re selling and your site structure, but here’s an example that should make good sense:
RewriteEngine on
RewriteCond %{REQUEST_URI} /affiliate?productid=(\d+)&affid=(\d+)$
RewriteRule ^(.*)$ http://www.somerandomsite.com/product_detail/$1 [L,R=301,CO=affid:$2:.somerandomsite.com:20160]
The above rewrite rule determines if it’s a request for a product page with an attached affiliate ID. If so, it will 301 the user to the appropriate product detail page and set the cookie for the affiliate id (with a 14 day expiry, in minutes = 20160) at the same time. If you need to get more complicated, I’d recommend a script. The above rewrite will break if the parameters aren’t in the right order, and it does no error checking. You can technically redirect to where ever you want, but give the user continuity with an overlay. For example, if you want the link juice to go to your index page but want to show the product page to the person who clicked the link. The simplest way of doing that is to set a cookie for the ‘real’ page to display, redirect (301!) to the index page, and then have a snippet of code in the index page that does a Javascript overlay. Super easy to do with JQuery’s BlockUI plugin.
If you’re an affiliate and you’re interested in keeping your link juice instead of passing it on, that is possible too. Set up a link on your own site that will always do a 302 redirect to your affiliate link. This can be done very easily using mod_rewrite (example below.) Now if you want to drop a link somewhere, simply use your new link. Not only does it hide your affiliate link from the wandering eye, but it’s shorter to type, and looks more “friendly”. Here’s an example that rewrites any links to http://www.myaffiliatesite.com/footsoak-review/ to the appropriate affiliate link. Just add a line to your .htaccess file and edit accordingly:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/footsoak-review/$
RewriteRule ^(.*)$ http://www.somerandomsite.com/affiliate?product=footsoak&affid=12345 [L,R=302]
Just remember, if you’re the publisher you want to direct the link juice to the same page. Focus it with a 301 redirect. If you’re the affiliate, you want to stop the link juice at your own site (any site you own) by using a 302 redirect.
If you need help or have questions, please contact me.