October 19, 2008

Joomla affiliate link cloaker

Filed under: Internet,Making money,PHP and MySQL — Joe Brewer @ 6:58 pm

So here it is. Version 3 of the affiliate link cloaker for Joomla 1.5.x

This new version works in a completely different way from the last version which will stop the problems caused by the WYSIWYG editors. However, there are other issues which I will explain about later. For now though, here is how to use it:

Download the plugin here.

Install and enable the plugin.

To cloak a link place the tags [CLOAK][/CLOAK] around the link. For example [CLOAK][/CLOAK]. This will convert thte URL into unreadable characters when the website source code is shown.

To alter the text in the status bar when the user moves their mouse over the link user this format: [CLOAK statustext=”status bar text here”][/CLOAK] – this uses javascript to place the text in the status bar.

The issue I have found with cloaking links like this is that most modern browsers have a feature that will stop javascript from writing to the status bar – this means that the domain will be displayed for all to see.

To get around this issue use a redirect script. This has two benefits:

1. You will be able to track clicks to the url.
2. It is possible to geo target – this is a huge oportunuity to squeeze more money from an affiliate link

Here is an example of a simple non geotargetting affiliate script using php:

‘hypnosis’ => ‘’

header(‘Location: ‘ . $urls[$_GET[‘go’]]);


Copy the above code into a file called redirect.php and populate the $urls array with your own affiliate links. Add an entry to your robots.txt file so that the search engines don’t index the file, then you are ready to go. To use it, using the above examples set the go parameter with the arrays keys:


To using geo targetting, we need to enlist the help of a third company. I would recommend MaxMind who offer a subscription service. There are several free services out there for geo targetting, however they are not very accurate. If you are going to spend some effort geo targetting your affiliate links, then it is worth spending a bit of money making sure that a potential customer will end up exactly where you want them to go. You can download an example geo targetting redirect script here. Here is the important part of the script:

// Put your MaxMind key here
$licenceKey = ”;

$country = getCountryFromWeb( $licenceKey, getIP() );

// affiliate links for great britain
$gb = array (
‘ebay’ => ‘’,
‘amazon’ => ‘’

// affiliate links for the united states
$us = array (
‘ebay’ => ‘’,
‘amazon’ => ‘’

// set the united states as the default country
$default = $us;

Each array needs to be named using the two character country code of the country that you want to target and every array must have the same keys. A list of valid country codes can be found here You can set up as many country arrays as there are countries, and you use it in exactly the same way as the previous script. So redirect.php?go=amazon will redirect to the local amazon store. All you will need to buy is a license from MaxMind – once you have this you will be able to put in the license key that you will receive at the top of the script.


  1. It doesnt work for me.. If I use the tag “statusbar” the code just stays the same in the text and If I use the cloak the website gets redirected to my own website with the URL behind it instead of a new one.

    This is probably (99% sure) something stupid Im doing here, I got an example for you though on this page:

    Maybe you can respond with a solution. (If thats possible)

    Comment by Jochem Vroom — November 2, 2008 @ 11:21 am

  2. Hi Jochem

    Sorry, there was a spelling mistake in my explanation. Your code should look like this:

    [CLOAK statustext=””]Naar Alice[/CLOAK] – statustext and not statusbar

    I’ve corrected this in the explanation.

    With regard to the other issue did you prefix the URL with http:// ?

    Comment by Joe Brewer — November 2, 2008 @ 5:12 pm

  3. Ah ok, Thanks!

    I’ll try the ” statustext ” then.

    One thing though I did use the http:// prefix. I think it has to be something else, I have an odd structure though since I redirect another site to a folder called “” and there I placed joomla, thats why you see the the URL doubled:

    http://www. ! !/ ! !/index.php/alice

    Not technical enough to fix these things.

    Comment by Jochem — November 3, 2008 @ 12:29 pm

  4. Currently the link goes to this page:

    What page did you want it to redirect to ?

    Comment by Joe Brewer — November 3, 2008 @ 6:16 pm

  5. To this one:

    (this is also exactly the link I placed into joomla)

    Comment by Jochem Vroom — November 3, 2008 @ 7:07 pm

  6. Hmmm. What editor are you using ? Any chance you can give me a login so I can look into this a bit more closely ?


    Comment by Joe Brewer — November 3, 2008 @ 7:15 pm

  7. Ok, could you drop me an e-mail?

    Comment by Jochem Vroom — November 3, 2008 @ 7:58 pm

  8. It might have something to do with a difference between internal and external links in the WYSIWYG editor. Since I can easily make this work for internal links, but somehow I’m unable to get it working for external links.

    Comment by Jochem Vroom — November 3, 2008 @ 8:08 pm

  9. Thanks for the excellent service and the excellent solution you found for me!

    Comment by Jochem Vroom — November 11, 2008 @ 6:01 pm

  10. You’re welcome 🙂


    Comment by Joe Brewer — November 11, 2008 @ 6:18 pm

  11. We tried cloaking a Clickbank hoplink and it doesn’t work.
    We are working with Joomla 1.5.7
    Thanks in advance

    Comment by Juan Carlos — December 1, 2008 @ 10:57 am

  12. Working fine with IE but not working with FireFox… WHY?????

    Comment by Patrick — December 15, 2008 @ 5:22 am

  13. Hi Patrick.

    Care to elaborate ? What is not working, and what versions of IE/Firefox are you using ?

    A known issue with Firefox is that it will now not allow javascript to change status bar text – is this what you are talking about ?


    Comment by Joe Brewer — December 15, 2008 @ 9:19 am

  14. Yes I was referring to the the status bar text … Firefox V 3.0.4

    Comment by Patrick — December 16, 2008 @ 10:30 pm

  15. Does it work joomla 1.0 ?

    Comment by graphik loft — January 4, 2009 @ 7:58 am

  16. Yes, shouldn’t be a problem. Let me know if you need any help

    Comment by Joe Brewer — January 4, 2009 @ 8:01 am

  17. Hi,
    I just install your plug-in in my joomla version 1.5.3 and i can’t get it work.
    What should i need do to..
    Is correcty instaled , and enabled. i am using simple format [CLOAK] anylink [/CLOAK] the words disaper on the content but i still see the link with out and cloaked link ..
    I will appretiate your help.

    Comment by Javier Mane — February 3, 2009 @ 9:39 pm

  18. Hi Javier

    The reason that the site is showing in the status bar is probably because you are running FireFox 3 or IE 8. These browsers do no not allow status bar text to be changed with javascript be default. What browser are you using ?


    Comment by Joe Brewer — February 5, 2009 @ 2:45 pm

  19. I am using Fire Fox3.. but, i am using simple format
    For Example:
    [CLOAK]My downline [/CLOAK]

    There is no the
    [CLOAK statustext=” anylink “]Naar Alice[/CLOAK]

    Comment by Javier Mane — February 6, 2009 @ 7:16 pm

  20. Can you give me the url of the page where you are using the plugin

    Comment by Joe Brewer — February 8, 2009 @ 3:59 pm

  21. hi Joe, the plugin is not working. I included the tags [cloak]LINK[/cloak] but it is not working.

    The tags text are showing in the page, and also the link shows in the status bar. I tested in Firefox 3.0.16 and Internet Explorer 8.

    The plugin is enabled in the admin 0f Joomla.
    What I have to do?


    Comment by Jorge — December 25, 2009 @ 6:59 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress