Essential Keystrokes is…

where I share my favorite tips, tools, reviews and commentary on web design, marketing, blogging, new media and related topics. For more about this site and the voice behind it, check out my About page.

Connect

SubscribeFollow me on TwitterLinked In Stumble Upon What I Digg Email me
Oct
02

How to Make a Redirect for Affiliate Links

By Char

Yesterday I got an email from a friend asking how to make an affiliate link look “clean”. If this very experienced blogger was asking the question, then chances are, there are many of my readers that would like to know too.

WHY WOULD I WANT TO SET UP A REDIRECT?

When you sign up with an affiliate program, the program has to give you a unique line of code that can be tracked so that you can get proper credit for the leads or sales that you generate from your site to theirs. In most cases, this means the link you are assigned will be long and drawn out, a combination of letters, numbers and symbols, and it will be long. For many users, if they mouse over such a monstrosity, they will not even click through for fear of the unknown.

Another reason you may want to use redirects with affiliate links has to do with managing them. Let’s say you sign up as an affiliate to program XYZ and you link to your affiliate link in dozens of blog posts. Then, one day the affiliate manager changes your affiliate link. You now have to go back through all of those links and change them. However, if you had set up a redirect, you could change it in one place and all the links would be routed correctly.

HOW DO  I SET UP A REDIRECT?

Setting up a redirect is a fairly simple process.  Basically you have to create a new php file that will contain the affiliate link and some additional code, save it with a unique name, and use the new file name when referring to that affiliate link.

1. Open Notepad or your favorite code editor

2. Type in the following code as you see it below, replacing the red text with your affiliate link.

How to set up a redirect

3. Save the file as keywordxyz.php (you come up with a file name that makes sense)

4. Upload the new php file to your web server (Need help with FTP? Check out my FTP Tutorial)

5. When linking to your affiliate link, you can now use:

setting up a redirect

I find that using redirects helps me stay more organized and I don’t have to go hunting for my affiliate links everytime I want to use them.

As it is with everything in the web development world, there is usually more than one right way to do everything. There are other ways to set up redirects, but I have found this method to be the easiest to set up and keep track of.

Related articles:

Categories : Tutorials

25 Comments

1

For techies, you can also use a .htaccess “RewriteEngine on
RewriteRule”, an HTML redirect (for non supported PHP websites), or even a Javascript redirect.

Different flavors for different folks.

Does anyone know how to hide an Amazon affiliate link with a specific product? I am referring to the portion after “tag=”

Thanks,
Jimson

2

Thanks for this little tutorial Char. Just so I’m clear – I’d have to create a separate file for each affiliate redirect, yes? Or could one ideally drop the php code into just one file and call separate redirects from that? Sorry if that’s a totally noob question.

I like the idea of using .htaccess as well, to forgo creating several redirect pages for numerous affiliates, but I’m unfortunately not very comfortable messing with my .htaccess. I’ll try the former first. :)

3

Jimson – my Amazon links are the ones I do not tend to redirect.

Charity – yes, I create a separate file for each affiliate.

4

Char

This is a really good article. Thank you. I am off to change my affiliate links.

David

5

directed to Charity: you could just make call to keywordxyz.php look like keywordxyz.php?affiliate=keyword
and grab the keyword using $_GET and make a switch in keywordxyz.php and for each case change the url variable to match the one in the affiliate GET call.
and after the switch just do the same header(“Location: lalal”); thingy.

6

@Rash – that seems really clever! Except I’m not strong on PHP, so it might be over my head :( Still, the idea of using only one file for all affiliate links is appealing, so would be worth it in the long run if I could figure it out. Time to start Googling and pouring over my PHP manual.

7

@Charity – if you’re not comfortable with PHP, then simply use a HTML redirect using:

8

I noticed the statement was omitted, for security reasons.

Do a Google lookup on using meta http-equiv=”refresh”, that should work.

9

Great, thanks Jimson!

10

i think i going to look at my affiliate links and see if i can change them

11

I say use the .htaccess for redirecting.
or if your lazy use tinyurl.com :D

12

@Mike – I’m not a fan of using tinyurl.com because I like to see the domain of where I’m clicking :)

Also, what happens if their DNS goes down?

I agree with you, .htaccess is the way to go.

13

I have set up a php redirect and can get it to work for normal links that are just a straight URL with an affiliate ID attached, but how do you reconfigue Amazon links to work – they have that tracking code on the end.

For instance, a typcial amazon affiliate link for a Sony Ericsson Cellphone Search page results would be as below:

What part of this do i put into the following redirect page codeline

if ($linkid == “”) {$link = “AFFILIATE LINK GOES HERE”;}

Really appreciate your help, thanks

14

I can get this to work no problems when it’s a straight link but for example when it’s google referall affiliate code its a block of text like ……

google_ad_client = “pub-???????????”;
google_ad_output = “textlink”;
google_ad_format = “ref_text”;
google_cpa_choice = “CAAQnfzw4AIaCJwZC9ix5DwoKN2uuIEBMAA”;
//–>

So how do i get this to work? My link works successfully and i can find the .php file …. it just doesn’t redirect.

Any help is appreciated.

15

It looks like it should be simple. However, I don’t understand ‘affiliate link’ after keywordxyz.php in the second graphic.

Why not just .shtml pages?

16

Does anyone know how to track keywords when using php redirect pages?

17

Oh I’ve been looking for a way to do this. Thank you so much!

18

Thanks for this post, it has helped me a lot in understanding how to re-direct an affiliate link – much better explanation of others on page one of google, including Aaron Walls!

19

that’s a neat trick! thanks!
one question – i’ve heard about people poaching your afiliate sales through intercepts. does that make your affiliate code any more – or any less – secure?

20

Here’s a question. What is you are just learning, have a website wanting to add affiliate links but can fit your computer knowledge in a 1/4 of a thimble? Any take me by the hand instructions out there?

21

That is a great way to add affiliate links. I have been using that for a couple of years now, because it is easy to manage links.

22

The good news is that you can use a wordpress plugin to redirect links for you. Im pretty sure its called golinks. Hope this helps

23

Hi, a simple online solution to this problem that doesn’t require any programming can be found at http://linkshiftr.com/.

Linkshiftr is a collection of tools for marketers that combine link redirection, link rotation, statistics, link shortening, conversion tracking, and other features to streamline the organization and efficiency of online marketing campaigns (all features are free except conversion tracking).

Keywords can be added to the end of links allowing you to collect any information you want from your links as well!

If you like the service or have questions, let me know at max@linkshiftr.com

24

Fantastic Tutorial. I’ve been hunting the web for info to do this. This will really come in handy for clickbank!

25

Thanks so much Char! This was so easy and worked INSTANTLY! Other tutorials online are so damn confusing and unnecessarily long.

I’ll definitely be coming back to your blog for more tutorials! Keep up the great work you’re doing.

Sonam

Leave a Comment

RECENT PROJECTS

Team Training NE Celiac Family