preload

2 Ways to Cloak Affiliate Links

Posted by admin on Jan 26, 2010

In the world of affiliate marketing, the word “cloak” gets thrown around a lot and means different things to different people.  So let’s be clear:

Link Cloaking

Definition: Using on page techniques to obfuscate the destination URL of a link when the user hovers over it.

Purpose: To hide ugly, complex, or affiliate code laden URLs from the user.  The idea is this: when the user hovers over a link, he will see the destination URL in the browser’s status bar.  A nice, clean URL, makes him feel warm and fuzzy inside and more likely to click through.

Referrer Cloaking

Defintion: Using off page techniques to hide or obfuscate the true referring page.

Purpose: To keep people out of your shit.  When you send traffic to an offer, the final destination is the merchant’s page.  If you don’t cloak the referrer, the merchant will be able to see exactly where the traffic is coming from.  This might be your landing page or, if you are direct linking, your traffic source.  “Tall fences make good neighbors”.

Referrer Cloaking is done via double-meta refresh and will not be the subject of this post.  However, it is worth noting, Prosper202 can handle this for you and you should definitely be doing it.  Instead, I’m going to be showing you how to cloak links.

How to Cloak Links



Option 1: PHP Redirect

Technically, this is not on page, but this is the most common method I see people using.  It works, looks pretty good and does not rely on javascript so it will work 100% of the time. The only downside is you do not have absolute control of how the link will look in the status bar.  Here is how to do it.

File: index.html

<a href="goto-yahoo.php">Visit yahoo.com</a>

File: goto-yahoo.php

<?php
header( 'Location: http://www.google.com/' ) ;
?>

How it works: if the user hovers over the “Visit yahoo.com” link, he will see something like “yourdomain.com/goto-yahoo.php” in the browser status bar. You can name this php file anything you want, I just chose “goto-yahoo.php”. When the user clicks on the link, the “goto-yahoo.php” file uses a php redirect to send the user wherever you want him to go. I chose to send him to Google to illustrate a point: what the link says, and where it goes can be two different things. As you can see the limitation of this method is it must end with “.php”. But you can get fancier….

Option 2: Javascript Cloak and Redirect

File: index.html

<body>
 
<a href='http://google.com/' name='http://yahoo.com'>Visit yahoo.com</a>
 
</body>
 
<script language="javascript">
_links = document.getElementsByTagName("a");
for(i=0;i<_links.length;i++) {
    if(_links[i].name) {
        docloak = function() {
            _cloak = this.href;
            this.href = this.name;
            this.innerHTML = _cloak;
        };        
        _links[i].oncontextmenu = docloak;                 
        _links[i].onclick = function() {
            docloak();
            window.location = this.name;
            return false;
        };                         
        _tmp = _links[i].href;
        _links[i].href = _links[i].name;
        _links[i].name = _tmp;
    }
}
</script>

How it works: Make a link as usual. Add the “name=” attribute and set it to whatever you want displayed in the status bar. The javascript code at the bottom of the file does the rest. Make sure you put the javascript code AFTER all of the links on the page. When the user hovers over the link, he will see whatever you set in the name attribute. As you can see, this technique allows you to control exactly what gets displayed in the status bar. If javascript is disabled, the user will see the real destination url, but that’s about the only downside.

Did you like this post? Consider sharing it!

  • Twitter
  • email
  • Digg
  • Reddit
  • del.icio.us
  • Technorati
  • StumbleUpon
  • Facebook
  • LinkedIn
  • RSS

Related posts:

  1. Passing Variables Through Prosper 202 Mod
  2. Split Testing and Landing Page Rotation Script for PPV

Tags: , , ,
  • 4 responses to "2 Ways to Cloak Affiliate Links"

  • Notmah Reelname
    26th January 2010 at 20:45

    If you are using the php redirect method your link doesn’t _have_ to end in php. Using apache’s AddHandler config in httpd.conf or .htaccess you can execute any extension through php. For example, with

    AddHandler application/x-httpd-php .com

    your php file (and link) could be:

    http://yourdomain.com/goto-yahoo.com

    SIF

    • admin
      28th January 2010 at 18:49

      True that. Changing Apache config works great. But I was saving that tip for ctrgenius.com

  • Javier Chua
    23rd February 2010 at 7:07

    Thanks for the great tips. Got here from the PPV playbook forum post that you made while helping.

    Cheers
    Javier

  • Vitaly Makarkin
    10th June 2010 at 6:46

    I discoveried something new about PHP\Scripts progamming for myself.

    Great!

  • Leave a Reply

    * Required
    ** Your Email is never shared