While some people have a dilemma how to label their affiliate links, I’ve got an idea to hide them. Not in the traditional sense of the word. Sometimes I just want to make my affiliate links look like the ’standard’ ones, without ugly affiliate code. Why? For the reason unknown people (especially my natives) have a habit to copy address of affiliate link, paste it to browser’s address bar, and then they are cutting off our lovely affiliate codes. It seems that something is wrong. And, hell yeah, I’m gonna fix it!
The goal is clear. I just want to make an affiliate link that will show address without dirty affiliate code on browser’s status bar. I’ve tried a few JavaScript solutions. Window.status has not worked correctly. OnClick, too. Of course you can put it into Flash button, for example, but wait. It has to look like a basic html text link. Man. Finally I found a lucky one.
Here is an example. There is an exemplary smart text link to Yahoo. Take a closer look at it. It looks like it directs straight to Yahoo, doesn’t it? But if you click on it, you will go to Google.
<a href="http://www.yahoo.com" onclick="parent.location.href='http://www.google.com'; return event.returnValue=false">Yahoo</a>
Hell yeah, it works. User thinks that he clicks regular link, but if he clicks it, he will be redirected to address with affiliate code. Of course if someone has JavaScript turned off, he will go to basic address from href, but let’s say it – everyone has turned it on. Except Google Bot.
UPDATE:
This post needs some information about disadvantages of exemplary link with a little JavaScript addition. First one, if user opens that link in new tab (window?) browser will not follow address from JavaScript code. Secondly, that code doesn’t work in RSS readers, so do not use it in blog posts, news on your sites, etc. It might be cool only for your sidebar, or a site specifically prepared for affiliate marketing, you know…
UPDATE 2:
Could anybody test this one in IE7?
Yahoo
UPDATE 3:
Alright folks, Steve reported that code works properly even in Internet Explorer 7.


I didn't want to turn my regular blog into site with reddit pictures, amusing videos, and stuff — so I started a new one. Have a look at my 
March 23rd, 2007 #
Many people claimed it was actually a security issue (and I’m sure it should be removed): think about a link to ebay (and the status bar says http://www.ebay.com) that redirects when clicked to http://www.ebay.com.app.com/user/login or some other (smarter) URL made for phishing…
March 23rd, 2007 #
That’s pretty clever
reminds me of the old days where you could put anything into the IE status bar!
March 24th, 2007 #
Andrea, maybe not for phishing. Let’s say you can use that smart trick in order to make sport of somebody. By preparing a link to delete an account on some service, for example.
Jon, you are right. Sadly, we are not able to play with status bar of Firefox
April 1st, 2007 #
Or why not just URL redirection services to hide them?
Something like http://blings.info/ can do this for you.
April 2nd, 2007 #
Why?!
Just because we don’t need to create an alias, but a link that has ‘inconspicuous’ look like, dude.
April 13th, 2007 #
I love this, thanks. This is also a smart way to receive value from your links and avoid URL canonicalization. You rock.
June 26th, 2007 #
Love this!
Reminds me of “Invisible Man” which I read about in my school days.
August 16th, 2007 #
The obvious solution is to have a very simple redirection script on your website.
You link to yoursite.com/goto/xxx which in turn redirects to wherever.
September 27th, 2007 #
err shouldn’t that have been…
<a href="http://www.yahoo.com" onclick="top.location.href='http://www.google.com'; return false">Yahoo</a>
September 27th, 2007 #
Thanks Mark. Could you test it in IE7?
December 9th, 2007 #
unfortunately this doesn’t work if people just right-click and open it in a new window in ff
nice info anyway
thanks
December 9th, 2007 #
Well, at least you can use AJAX to develop your own context menu. It works pretty fine in Firefox
December 10th, 2007 #
Your javascript works great in IE 7. (At least in my version which is being run on WinXP) I hovered over it and say “yahoo.com” but when I clicked on it, it sent me to google
December 11th, 2007 #
Thanks Steve, I’ve added one another update to this post!
December 13th, 2007 #
It doesn’t work in new TAB… 8/
December 16th, 2007 #
How about just using javascript to document.write the links onto the page?
December 17th, 2007 #
@ Arty: Yes it doesn’t, if you need it working “in new tab” you should read comments above
@ Mark Rushworth: As far as JS cannot affect browser status bar there’s no need of using it. Notice – I wanted to make fake links that look like normal ones!
March 25th, 2008 #
works wonderfuly for hiding affiliate links. Thanks
June 23rd, 2008 #
Great read! Im glad i got the chance to read this! Keep up the great work!
July 7th, 2008 #
Is there a way to add rel nofoollow and target*blank in this code ?
July 7th, 2008 #
@Zarada: Yes, of course you can add various features. Honestly, you’re limited only by base capabilities of JavaScript. In case of opening new windows – check this out http://www.pageresource.com/jscript/jwinopen.htm
August 25th, 2008 #
Thanks! It doesn’t work if you right click and open the link in a new tab. It goes straight to yahoo.com, why?
August 25th, 2008 #
After reading my last comment, it seemed a little rude after reading it. I didn’t mean for it to come out like that. I really enjoyed the post and the tip.
August 29th, 2008 #
Well, you didn’t read the comment section below this post, didn’t you?
The thing doesn’t work when you open the new tab. For the right mouse button you need to create fake context menu, I’d say there should be also some browser detection so you don’t show the script designed for IE to all Firefox users visiting your site. Take a look at one of the previous comments.
November 13th, 2008 #
Good way to hide your affiliate id is using free url masking tool like http://shoxt.com
December 26th, 2008 #
Thanks for useful advise.
January 22nd, 2009 #
Works in Opera 9.63 if you just click on it. Any other action like “Open in new tab” takes you to yahoo.
@John – Yes, shoxt looks ok but not quite what I was looking for. I don’t really want to bounce all my visitors off another server to get to content on my site.
@ Bart – That’s one solution. You could play around with the window.name= attribute and simply avoid the need for popups by naming your current window (always a useful thing to do) and putting this name on the onclick command, so you have a button to open the link in the current window, or you can close the parent and open a new full window without the address bar.
@ Florchakh – the context menu idea looks quite interesting. It seems to work ok in Opera too though, again, not quite what I was looking for. Great tool to add some functionality to your site but it doesn’t address the subject of this post, which is to find a simple way to hide links
March 2nd, 2009 #
useful discusion but difficult to tell what the robots make of the link