A Better Way To Manage Affiliate Links

by Pinyo on July 2, 2008

One of the more lucrative monetization methods for a blog is affiliate marketing (or referral marketing). Basically, you set up your blog with an affiliate link (or referral link) and send traffic to your advertiser. For each visitor that completes an action — i.e., subscribe to a service, buy a product, etc. — you’ll get paid a fixed amount or a percentage of the sale as compensation.

Three Problems With Affiliate Links

1. Non-Descriptive

Non-descriptive affiliate links are the ones that don’t tell the user information about the site it is leading to. This is a common problem with program like Commission Junction where a typical affiliate link looks something like this:

http://www.anrdoezrs.net/click-2899932-8291847

By the way, that’s the affiliate link for Lunarpages web hosting. However, with all the phishing scams, visitors are less inclined to click on a non-descriptive link because they are not sure where they will end up.

2. Complicated

Complicated affiliate links are the excessively long ones. For example, this is an affiliate link for a Garmin Nuvi GPS through Amazon.com:

http://www.amazon.com/gp/product/B000H49LXQ?ie=UTF8&tag=thelifsph0c-20
&linkCode=as2&camp=1789&creative=9325&creativeASIN=B000H49LXQ

That’s a pretty long affiliate link.

3. Hard To Update

As your blog ages, it could contain hundreds or even thousands of affiliate links. This presents a challenge if one of these links needs to be updated. For example, eBay recently left Commission Junction and started its own affiliate program, forcing publishers to update all eBay affiliate links.

Using PHP Redirect To Manage Affiliate Links

The three problems above can be addressed with a simple solution if you know a bit of PHP. We will use the Lunarpages link as an example.

First, you need to create a PHP file that redirects visitors to the affiliate URL when called — let’s call it lunarpages.php. This is how the file would look like:

<?php
header( ‘Location: http://www.anrdoezrs.net/click-2899932-8291847′ ) ;
?>

Note the Lunarpages affiliate link.

Second, upload the lunarpages.php file to your web server. I keep my PHP redirect files in a folder called go. For example:

http://www.blogthority.com/go/lunarpages.php

Now, I can simply link to this nicer looking link that tells my visitors that it goes to Lunarpages instead of the ugly “anrdoezrs.net” link. Try it: http://www.blogthority.com/go/lunarpages.php

A Better Way To Manage Amazon Affiliate Links

It would be extremely time consuming to manage Amazon affiliate links using the above method — i.e., one PHP file per product. Fortunately, we can use a PHP variable to solve the problem — this way, one PHP file can handle multiple products.

First, the PHP file. Let’s call it amazon.php. This is what it would look like.

<?php
$asin = htmlspecialchars($_GET['asin']);
$link = “http://www.amazon.com/gp/product/” . $asin . “?tag=your-affiliate-ID”;
header(“Location:”.$link);
?>

Note, be sure to replace your-affiliate-ID with your ID. Again, upload the file to your web server. Now, when I need to link to an amazon product, I can do the following:

http://www.blogthority.com/go/amazon.php?asin=B000H49LXQ

This is the equivalent of the long affiliate link in #2 above. Try it: http://www.blogthority.com/go/amazon.php?asin=B000H49LXQ

If you ever need to update any of these links, all you have to do is update the PHP file — one change and you’re all set!

{ 2 trackbacks }

Social Media Tip For Bloggers: Link Your Social Media Profiles To Your Blog URL | Bible Money Matters
January 28, 2009 at 11:38 am
2 Options for Creating Dynamic Affiliate Links
July 20, 2009 at 7:30 am

{ 20 comments }

That One Caveman July 2, 2008 at 11:03 am

Thanks! I knew it had to be simple, but I just never bothered to figure it out.

Another side benefit is that you can better track who and how often these are clicked by checking your own server logs for the hits to these php pages.

AP July 2, 2008 at 3:34 pm

Does this also help with SEO? i.e. you are outbound linking to your own website rather than linking to some redirect.

Auctionfreedom July 2, 2008 at 9:26 pm

Great tips. Your PHP file codes are definitely a nice way to make a link a professional. I am a big fan of eBay affiliate program. I have bunch eBay affiliate websites. Their recent changes of leaving Commission Junction really made me sick. It took me lot of time to convert my all site. I have a feeling that thier all new eBay links are not tracking commissions properly.

Pinyo July 15, 2008 at 8:54 pm

@AP — I am not an SEO expert, but I assumes it helps by reducing the number of unnecessary outbound links.

@Auctionfreedom — I am sorry to hear about your predicament. I just joined the new eBay program, but I make minimal amount so I can’t really compare. I supposed any program could cheat us out of our money if they wanted to.

Mrs. Micah July 17, 2008 at 2:37 pm

Pinyo, that’s amazing. :) This is getting del.icio.usd onto my to-do list. Especially the Amazon one…so much easier to manage.

Patrick July 17, 2008 at 4:17 pm

Very slick. I wish I would have known a bout this when I started out, but no worries. I’m thankful a friend showed it to me recently and I do it for most links now.

Frugal Dad July 23, 2008 at 9:02 am

Thanks for solving the mystery (for me) behind how to do this. I see implemented at most of the “big” blogs now, but never knew how to implement it. Great stuff!

DR August 19, 2008 at 10:17 pm

Pinyo, great article! I’ve used php redirects before, but not quite the way you suggest. I implemented your suggestions in a couple of minutes and it worked like a charm. Thanks!

Lazy Man and Money August 22, 2008 at 12:45 pm

I do the first redirect, but I don’t do the Amazon one. I feel that Amazon is a pretty trusted source and people are generally not upset by clicking on it. If they can read the link text, say Garmin Nuvi and scroll over it, it should be all they need.

Pinyo September 15, 2008 at 10:56 pm

@Mrs. Micah — You’re welcome. I learned this trick from the best in the business. ;-)

@Patrick — Yeah, any new trick is a pain to implement if you’ve been at it for a while.

@Frugal Dad — Took me a while to learn it too.

@DR — You’re welcome. Glad to hear it works well for you.

@Lazy Man — You have a point about trust, but I like the ease of setting up new referral link without knowing the structure of the long URL and without having to go into Amazon Affiliate interface.

Rufas November 7, 2008 at 3:31 pm

The amazon.php script doesn’t work. It gives me this error:

Parse error: syntax error, unexpected ‘:’ in amazon.php on line 3

Any help?

Pinyo November 10, 2008 at 11:47 am

@Rufas — I think it may be quote problem since WP automatically replaces normal quotes to smart quotes. Try this.

< ?php
$asin = htmlspecialchars($_GET['asin']);
$link = "http://www.amazon.com/gp/product/" . $asin . "?tag=your-affiliate-ID";
header("Location:".$link);
?>

Rufas November 11, 2008 at 8:29 am

Thanks Pinyo, It works wonderfully now ;-)

Bill November 27, 2008 at 3:14 am

Great tip on Amazon. I hate going to their Affiliate site.

Trevor @ Financial Nut April 16, 2009 at 1:11 pm

Interesting approach. Thanks for sharing. Thought I’m not huge into affiliate marketing, this is a great way to do it.

Sleep Insomniac June 30, 2009 at 4:48 pm

Thanks Pinyo. Amazon tip was working for me great

Stefan August 18, 2009 at 4:39 am

Isn’t the Amazon tip against the new regulations they’ve put in place where they state that only plain links and image links may be used to link to Amazon products?

Pinyo August 18, 2009 at 6:47 am

Stefan, I have not look at Amazon policy lately — it’s been a while since I wrote the article. I’ll check out their TOS.

NG September 3, 2009 at 9:26 am

Any update on whether this violates Amazon’s rules?

Pinyo September 3, 2009 at 9:39 am

@NG – Sorry, but I have not look into it yet.

Comments on this entry are closed.

Previous post:

Next post: