Which of these two URLs looks better?
It’s the first one, right? That, plus other reasons, is why so many affiliate marketers cloak affiliate links on their sites.
To help you do the same, I’m going to show you exactly how to cloak affiliate links in WordPress using three different methods (two plugins or some code).
Why You Should Cloak Affiliate Links In WordPress
Beyond just plain offering cleaner, more user-friendly URL structures, cloaking your links has some practical benefits as well.
First off, it makes it a lot easier to manage your affiliate links.
Picture this…you’ve been linking to this one great product in all of your content. You’ve probably linked to it, say, 25 different times. But now, for some reason, that company is switching affiliate programs and suddenly you have to update all of your links.
This is a major pain.
But if you’ve cloaked your links, you can just update to the new affiliate link structure one time and those changes will automatically apply to every single spot where you used the link.
Second, most link cloaking tools make it easy to add the rel=”nofollow” tag to affiliate links.
This ensures that you don’t get on Google’s bad side or pass your hard-earned SEO juice off to affiliate products.
Finally, cloaking affiliate links makes it harder for malicious actors to overwrite your affiliate links (if they ever got a foothold in your site).
How To Cloak Affiliate Links In WordPress
Below, I’ll show you how to cloak links using three different methods:
- ThirstyAffiliates – this popular link cloaking plugin is what we actually use here at WPLift.
- Pretty Links – this is another popular link cloaking plugin.
- Manual code – it’s actually not too difficult to do this yourself, but you will lose out on some of the advanced features that the plugins offer.
How To Cloak Affiliate Links With ThirstyAffiliates
ThirstyAffiliates comes in both a free and a premium version. The free version is totally fine for most sites, though. It will let you:
- Cloak affiliate links to create pretty links
- Manage all of your affiliate links from one spot
- Easily insert affiliate links in your content
- Uncloak certain links (this is important because some programs, like Amazon Associates, require this)
And it even has a feature to help you view click stats for your affiliate links.
If you’re serious about affiliate marketing, the Pro version does add some cool features, most notably Automatic Keyword Linking. This allows you to automatically link key phrases anywhere on your site to certain affiliate links.
This is something Daan uses here at WPLift and is a big fan of. Read my ThirstyAffiliates review for more details.
After you’ve installed and activated either the free or the premium version, here’s how to start cloaking links…
Step 1: Set Up Your Link Structure And Other Settings
To get started, go to the ThirstyAffiliates → Settings and choose the Link Appearance tab to configure how your links look and function.
Make sure to choose:
- Link Prefix – this is what shows up before the product name. E.g. yoursite.com/go/product
- Link Redirect Type – usually, you want to leave this as 302, but you can change if desired.
- Nofollow / open links in new window – I like to turn both of these on to save time.
If you’re going to use Google Analytics to track outbound links (that’s what I do), then you also might want to go to the Modules tab and disable Statistics to avoid storing stats in your database that you won’t use.
Step 2: Add And Insert Your Affiliate Link(s)
ThirstyAffiliates gives you two different ways to add your links:
- Via the normal WordPress editor when you’re writing your content
- In the actual ThirstyAffiliates interface
I’ll show you how to do it using the WordPress editor, but you can always access the other method by going to ThirstyAffiliates → New Affiliate Link.
To add a link from the WordPress editor, click on the new Quick Add Affiliate Link button (or use the CTRL + Shift + K hotkey):
- Link Name – this is what will go after your Link Prefix
- Destination URL – this is your actual affiliate link
You can also modify the other options if needed, but they should automatically be set to your defaults:
Then, you can choose to:
- Add Link – adds the link to ThirstyAffiliates but doesn’t insert it.
- Add Link & Insert Into Post – does what it says.
You can also easily insert other links that you’ve added simply by hitting the Add Affiliate Link button and searching for the link by name:
Step 3: Manage Affiliate Links
If you need to manage your existing affiliate links at any point in the future, you can see a full list by going to ThirstyAffiliates → Affiliate Links:
How To Cloak Affiliate Links With Pretty Links
Pretty Links works on a fairly similar principle to ThirstyAffiliates so I’ll go through this section a bit quicker. It can help you:
- Cloak all your affiliate links
- Track clicks
- Manage existing affiliate links
The pro version adds that same cool auto replace feature, as well as an option to split test your affiliate links which might be helpful if you want to test different offers.
I personally find ThirstyAffiliates interface a bit more intuitive, but plenty of people like Pretty Links.
Add And Insert Affiliate Links
With Pretty Links Lite, there’s no link prefix like ThirstyAffiliates. You can manually add one, of course, but I prefer ThirstyAffiliates approach for its standardization.
To add/insert a new affiliate link, you just click the new Insert Pretty Link button in the WordPress editor:
Then you can enter:
- Target URL – your actual affiliate link.
- Slug – this is the part that goes after your URL. E.g. yourwebsite.com/go-to-product
- Link Text – the actual text for the affiliate link
Then click Insert New Pretty Link:
To insert an existing affiliate link, you can also use the Use Existing Pretty Link button at the bottom.
How To Cloak Affiliate Links Without A Plugin
Not a fan of using a plugin? It’s actually not too difficult to manually cloak affiliate links thanks to some work from Yoast SEO, especially if you only need to cloak a small number of links.
To be able to pull this off, you’ll need to be able to connect to your site via FTP or cPanel File Manager.
Once you’ve done that, here’s how to set everything up:
Step 1: Create A New Folder On Your Site
To get started, create a new folder at your site. You can technically call it whatever you want, but I recommend that you call it something that makes sense like:
This is kind of similar to ThirstyAffiliates’ Link Prefix.
You should also use your robots.txt file to block this folder by adding:
To your site’s robots.txt file (making sure to add the actual folder name that you created).
Step 2: Upload index.php File From GitHub
Then, create a new file in that folder called index.php and add this code snippet from Yoast SEO’s GitHub.
It should look something like this when you finish:
Step 3: Create Text File With Redirects
Now, you need to create a text file called redirects.txt that follows this format:
Add each new affiliate link on a new line. Here’s what it looks like in File Manager:
Once you upload the file, you should be able to go to:
And your site will redirect you to the proper URL. Pretty easy!
The only downside is having to manually edit the redirects.txt file every time that you want to add a new affiliate link.
Final Thoughts On Cloaking Affiliate Links In WordPress
If you want my preferred method, I use ThirstyAffiliates on my own sites because I think it has the easiest way to manage affiliate links. I just always disable the stats module because I’d rather use Google Analytics Event Tracking to monitor clicks.
The free version is plenty fine for my needs, but I know that Daan uses the premium version here at WPLift to take advantage of the automatic link insertion feature.
Any other questions about how to cloak affiliate links in WordPress? Leave a comment and we’ll try to help out.