The link cloaking I’ve added to the Stallion Responsive Theme and Stallion WordPress SEO Theme is a very cool feature.
Why Hide/Cloak Affiliate Links?
There are two reasons to hide/cloak affiliate links (any link).
1. Hide the source of the link from your visitors so they don’t know they are about to go to an affiliate site AND so other affiliates can’t easily steal your affiliate links (apparently it’s a problem).
2. To protect a sites link benefit, Google does not want us linking to affiliate sites and other sites we don’t recommend. Unfortunately Google took away the only way to tell Google etc… a link shouldn’t pass link benefit when it changed how nofollow links work (stupid Google). A nofollow link used to pass no link benefit to the page it was linking to and the ‘saved’ link benefit was reused on the followed links from the page. Google currently deletes the link benefit of nofollow links so we should avoid using nofollow!!!
WordPress Theme Link Cloaking
If you run the Massive Passive Profits Autoblog Plugin or the WP Robot Autoblog Plugin Stallion can automatically ‘hide’ the affiliate links from search engines.
Note: the link above to WPRobot is an affiliate link that has been cloaked using a simple PHP redirection script (see later) AND uses the Stallion link cloaking feature to ‘hide’ it from search engines, this is the code I used:
<span class="affst" title="outboundz" id="1">WP Robot Autoblog Plugin</span>
After reading this link cloaking tutorial you will be able to setup similar cloaked affiliate links on your WordPress blog.
How to Cloak/Hide a Link Using Stallion
Lets say you have a standard text link like this one:
<a href="https://stallion-theme.co.uk/">Stallion Theme</a>
This links to the Stallion home page “https://stallion-theme.co.uk/” with the anchor text “Stallion Theme”. This is the actual link: Stallion Theme.
It’s very easy to turn it into a hidden link using Stallion by changing it to.
<span class="affst" title="tests" id="https://stallion-theme.co.uk/">Stallion Theme</span>
You place the URL https://stallion-theme.co.uk/ in the id=”” part of the code and the anchor text (Stallion Theme) before the closing </span>. As long as “Cloak Affiliate Links” is turned on under the “Stallion Promotion Options” page it will be cloaked/hidden.
That’s it the link is cloaked/hidden from Google. You can do this manually to any link that Stallion has access to within the content of a post or page linking to any page.
You can do the same with image links by replacing the anchor text with image code:
<span class="affst" title="tests" id="https://stallion-theme.co.uk/"><img src="https://stallion-theme.co.uk/wp-content/uploads/premium-wordpress-theme.png" alt="Stallion Theme" /></span>
Basically if you have any link with format:
It can be replaced with the code above.
WordPress Simple PHP Redirection Script to Hide AND Cloak Links
The above feature is pretty cool on it’s own, you can use it to save all that link benefit that would be wasted by linking to affiliate sites directly or using nofollow links, but it doesn’t hide where the link goes to, to your visitors. Now the interesting part is when we bring in other tools.
I’ve been using a free very simple PHP redirection script for years. I have it installed on this domain and use the script for a lot of affiliate links, especially Clickbank products (the WP Robot autoblog link above uses the script, hover over it and you’ll see the ….co.uk/go/go.php?id=1 URL.). This means if an affiliate product is no longer available (happens a lot with Clickbank products) you edit one file related to the redirection script and every link to that affiliate product is changed (you could link it to a similar affiliate product for example).
You can get the free PHP Redirection Script here (note used the cloaking code to hide this link, no link benefit wasted) and install it on one of your domains. I put it under the folder /go/ and renamed some of the files (I forget why), but doesn’t really matter where you put it you can keep the default settings.
My settings results in links like this:
Where ## is a number.
If you go with the defaults your setup will be something like this:
Note: in Stallion WordPress SEO 7 it was test.js under /stallion-wordpress-seo/, same file, minor changes.
You will find this line of code:
case 'outboundz': theURL = 'https://stallion-theme.co.uk/go/go.php?id='; break;
case 'outboundz': theURL = 'http://www.domain.com/ccount12/click.php?id='; break;
This will now use your PHP redirection script to cloak links (obviously you change domain.com to your domain :-)).
You could use almost any PHP redirection script that outputs a unique id/code
Note: there are multiple examples I’ve used starting “case” etc…. like “case ‘testing2’: theURL = ‘http://www…..” each line can be changed to your needs, I’ve used tests2, testing, testing2 and outboundz. You can change them to use your redirection scripts. If you are using the inline js option edit the links.php file instead, there’s only the case ‘outboundz’: theURL…. line.
Log into the PHP Redirection Script and add a link, it should be given ID = 1 so will go to the link:
We use this code to incorporate this link into a WordPress post or page:
<span class="affst" title="outboundz" id="1">Anchor Text of Link</span>
When you create a second cloaked link it will be ID = 2 so change the id=”1″ to id=”2″ and so on.
In this way you can have as many cloaked links as you have IDs with this script.
This concept will work with pretty much any redirection script. If you have a script that generates URLs like
case 'testing': theURL = 'http://www.domain.com/'; break;
To the links.js file (or links.php file is using the inline js option) and build your link code like:
<span class="affst" title="testing" id="UNIQUECODE1">Anchor Text of Link</span>
Already used more than one PHP redirection script, not a problem you can add more than one type of link format. To use the two examples above, in your links.js file (note the second line uses testing2 instead of testing, each line needs a unique string (can be almost anything)):
case 'testing': theURL = 'http://www.domain.com/ccount12/click.php?id='; break; case 'testing2': theURL = 'http://www.domain.com/'; break;
Now link code
<span class="affst" title="testing" id="1">Anchor Text of Link</span>
Will use the top format (testing) and
<span class="affst" title="testing2" id="UNIQUECODE1">Anchor Text of Link</span>
Will use the bottom format (testing2).
Automation of Link Cloaking
Want a bit of automation in your link cloaking so you aren’t endlessly copying and pasting IDs etc… Not a problem.
I’ve been using this technique on affiliate sites with thousands of links and cloak the lot with a simple technique.
I’ve created a small number of affiliate sites using Shareasale datafeeds and use a simple PHP redirection script to cloak the links with format:
Create a file called buy-now.php (you can name it anything you like as long as you change relevant parts below to match the filename) and put it in the root of your domain (can put it anywhere, but easier for me to explain if it’s in the root :-))
<?php $id=$_GET['id']; header('Location: http://www.shareasale.com/m-pr.cfm?merchantID=SHAREASALEMERCHANTID&userID=YOURSHAREASALEID&productID='.$id); ?>
SHAREASALEMERCHANTID : you get this from the datafeed
YOURSHAREASALEID : that’s your Shareasale User ID
Add this to your Stallion links.js file:
case 'tests4': theURL = 'http://www.domain.com/buy-now.php?id='; break;
And use the link format:
<span class="affst" title="tests4" id="UNIQUEPRODUCTID">Buy Now</span>
UNIQUEPRODUCTID : is the Unique product ID from the Shareasale datafeed.
Your affiliate links will now look like this when hovered over:
When building the site (normally with a database import script like WPRobot) you would use the above link code format instead of a normal affiliate link, in this way it’s all automated. Some of my sites where built before I used this technique, I edited the MySQL database (ran a few SQL queries) to search and replace the original affiliate links with nofollow links to the sort of code above (will explain how in a comment when I have the time).
I’d link to an affiliate site that uses this technique, but it’s never a good idea to show your affiliate sites around as makes it easier for Google to find and downgrade them (Google hates affiliate sites).
You can use the concept on any affiliate source that uses a general format with a unique code to identify each product like “http:www.ALLLINKSHAVETHISBIT?ID=UNIQUETOEACHPRODUCT”. You put the link part that’s the same for all products into the redirection script (for most Sharesale datafeeds it’s “http://www.shareasale.com/m-pr.cfm?merchantID=SHAREASALEMERCHANTID&userID=YOURSHAREASALEID&productID=”) and the unique product ID into the link code.
It’s taken me years to pull these techniques together and you get it as part of Stallion, I would have paid thousands for these techniques 5+ years ago, they protect so much link benefit and make it harder for search engines to find and downgrade affiliate sites. Now all I need is to find the time to actually build affiliate sites :-)