How to Cloak Affiliate Links in WooCommerce: A Step-by-Step Guide

Affiliate links can be a mess, ugly, long, and instantly suspicious. If you are using WooCommerce and just pasting raw URLs, you are probably scaring off clicks and leaving money on the table. No one wants to click a sketchy link that looks like it leads to a scammy corner of the internet.
And let’s be real: If your links look shady, your brand takes a hit, too. Cloaking affiliate links turn links into clean, branded URLs that people actually trust.
In this post, we will walk you through how to cloak affiliate links in WooCommerce the right way so your site stays clean and you can track them easily and safely.
Let’s dive into the content.
What It Means to Cloak Affiliate Links?
Cloaking affiliate links is the practice of turning long, messy, or suspicious-looking affiliate URLs into clean, branded links that are easier to read, trust, and click. Affiliate links often include tracking information, partner IDs, and other parameters that can make them look untrustworthy.
For example, a raw affiliate link is something like this:
https://website.com/product?id=12345&ref=yourname
When you cloak that same link, it could look like this instead:
https://yourstore.com/go/product-name
Even though both links lead to the same destination, the cloaked version looks cleaner and more professional. It also makes the link easier to share, especially on social media or in emails.
Cloaking is usually done using a redirect through a plugin or manually. When someone clicks on your custom URL, they are automatically taken to the original affiliate link behind the scenes.
Difference Between Link Cloaking and Link Shortening
Link cloaking and link shortening seem similar, but they serve slightly different purposes.
Link shortening is mainly about making long URLs shorter and easier to share. You can use online tools like Bitly or TinyURL to make a big, messy link and turn it into something like bit.ly/abc123. It will change your permalink to numbers and letters.
Link cloaking, on the other hand, is more about control and branding. It not only shortens the link but also hides the original affiliate URL behind a custom, branded redirect like yourstore.com/recommend/product. This makes the link more trustworthy, helps protect your commissions, and keeps everything consistent with your site branding.
So both make links shorter, but link cloaking adds an extra layer of professionalism, tracking, and security that basic link shortening doesn’t offer.
Why You Should Cloak Affiliate Links in WooCommerce
When running an online store with WooCommerce or EasyCommerce, it’s a good strategy to partner with other brands or services and promote their products via affiliate links. However, leaving these links exposed in their raw form could have several downsides.

Cloaking affiliate links is a strategy used to mask the raw URLs, making them more user-friendly, professional, and trackable.
Below are the major reasons why cloaking affiliate links in WooCommerce is beneficial:
Builds Trust with Users
Affiliate links often look suspicious to users, especially when they contain long strings of random characters or seem to redirect to domains. For example, a URL like domain.com/ref?12345 can seem spammy to visitors.
Cloaking links lets you create clean, branded URLs like domain.com/recommended-product, which users are more likely to trust. When customers trust the links, they are more inclined to click and follow through on a purchase.
Helps with Search Engine Optimization (SEO)
Cloaking links also helps with search engine optimization (SEO). Raw affiliate links often contain tracking parameters or unnecessary identifiers that can clutter your site. Using cloaked links help you present a cleaner structure for search engines to follow.
Additionally, some search engines may penalize sites that display long, unprofessional affiliate URLs, so keeping things neat with cloaking may avoid any SEO drawbacks.
Create a Better Brand Image
Cloaking affiliate links enables you to incorporate your own WooCommerce store domain name, which maintains consistent branding across your website. Instead of sending visitors to an external site with a URL that doesn’t match your store, cloaked links allow you to redirect them through your domain.
So, you can create a seamless experience for your users and ensures your brand stays front and center throughout the shopping journey.
Protection Against Link Hijacking
Raw affiliate links can be vulnerable to “link hijacking.” This occurs when someone modifies your affiliate link to steal your commission. For instance, an affiliate link might be shared by someone else and could have their own affiliate code embedded instead of yours.
Cloaked links help you reduce the chances of this happening and ensures that any sales made via your referral are credited to your account.
Easier Link Management
As your affiliate program grows, managing multiple affiliate links can become a hassle. Cloaking your links with a URL shortener or an affiliate link management plugin lets you easily edit, track, or even update links in bulk without having to go through individual posts or pages.
This level of control saves you significant time and reduces the likelihood of broken links or errors on your site.
More Control Over Redirection
When you cloak an affiliate link, you can also manage the redirects more effectively. For example, you can set up custom redirects, monitor the success of your links, and adjust strategies in real time.
Some advanced cloaking methods allow you to test different landing pages, track conversions, and implement tracking pixels or retargeting tools to maximize affiliate commissions.
How to Cloak Affiliate Links Using a WordPress Plugin
Cloaking affiliate links using an WordPress affiliate plugin is much easier the conventional methods. In this part, we will explore how you can easily cloak affiliate links with a WordPress plugin.
Step 1: Install WC Affiliate and Configure Basic Settings
First, you have to install both WC Affiliate and WC Affiliate Pro on your website. Go to your WordPress Dashboard > Plugins > Add New and then search for WC Affiliate.

In the same way, upload the pro version and activate it. After that, go to Setup Wizard.

On the setup wizard page, create your new Affiliate Dashboard page, or if you have already created it manually, then set it yourself.

After that, click the Next button to configure your commission settings. Here, you need to set the affiliate commission base, their commission rate, and the cookie expiry from the dropdown.

After all your setup is done, click the finish button to continue to the next step for cloak affiliate link settings.
Step 2: Set Cloaking Affiliate Links Settings
Now go to site Dashboard > WC Affiliate > Settings > Shortlinks. There, you need to enable shortlinks for affiliates, set the URL base, and set a personal identifier for your affiliate’s shortlink. You can also set the identifier length from those settings.

Step 3: Generate Affiliate Links
Now that your setup in complete, you can let your affiliate generate short cloak affiliate links on their own. They need to log in to their Affiliate Dashboard > URL Generator. First, enable the Create Shortlink option and then set your identifier for the link.
After that click on the Generate button.

After you click the generate button, you will be able to see your desired cloaked affiliate links for WooCommerce.

This plugin also offers many other functionalities like, you can set up multilevel commission for your affiliates, generating banners, etc.
How to Cloak Links Without a Plugin
If you are good at coding and have experience managing domains and hosting, then this part is for you. Here’s our simple guide for cloaking affiliate links without a plugin.
Step 1: Create a New Folder
At first, log in to your hosting server. You can also do this by using a free FTP/SFTP solution like FileZilla. After logging in, go to your main directory folder.

After that, create a new folder on the server. This folder’s name will be your URL slug, so try this: go, recommend, out, etc.

Step 2: Upload the index.php File
Next, create another file inside the folder you just created. Name this file as index.php and add the following code from Yoast’s GitHub.
<?php
$id = isset( $_GET['id'] ) ? rtrim( trim( $_GET['id'] ), '/' ) : 'default';
$f = fopen( 'redirects.txt', 'r' );
$urls = array();
// The file didn't open correctly.
if ( !$f ) {
echo 'Make sure you create your redirects.txt file and that it\'s readable by the redirect script.';
die;
}
// Read the input file and parse it into an array
while( $data = fgetcsv( $f ) ) {
if ( !isset( $data[0] ) || !isset( $data[1] ) )
continue;
$key = trim( $data[0] );
$val = trim( $data[1] );
$urls[ $key ] = $val;
}
// Check if the given ID is set, if it is, set the URL to that, if not, default
$url = ( isset( $urls[ $id ] ) ) ? $urls[ $id ] : ( isset( $urls[ 'default' ] ) ? $urls[ 'default' ] : false );
if ( $url ) {
header( "X-Robots-Tag: noindex, nofollow", true );
header( "Location: " . $url, 302 );
die;
} else {
echo '<p>Make sure yor redirects.txt file contains a default value, syntax:</p>
<pre>default,http://example.com</pre>
<p>Where you should replace example.com with your domain.</p>';
}
Step 3: Add the Links in the Redirects.txt File
Now you need to create a redirects.txt file for cloaking your affiliate links. In this file, you can add your destination URL and its slug. The format is:
link-slug, https://destinationurl.com/?affid=123
Add each of the affiliate link on its own line, like this:
link-slug,https://destinationurl.com/?affid=123
codexpert,https://codexpert.io?kaid=123
If you want to handle edge cases you should also make sure that the first line is:
default,http://yoursite.com
Step 4: Block Crawlers
To prevent search engines from indexing your cloaked affiliate link, add Disallow: /folder-name/ to your robots.txt file. And if you want to learn how to edit your robots.txt file, check out this Full WordPress robots.txt Guide
Final Words
Cloaking affiliate links in WooCommerce helps boost credibility, improve user experience, and enhance SEO. By turning raw, suspicious links into clean, branded URLs, you protect your commissions and build trust with your audience. If you are using a plugin like WC Affiliate or manual redirection, cloaking increases click-through rates, strengthens brand consistency, and simplifies link management.
It’s more than just shortening URLs, it’s about presenting professional, trustworthy links. Start cloaking your affiliate links today and give your WooCommerce store a polished edge that both customers and search engines will love.
Frequently Asked Questions (FAQs)
Q. How do I create an affiliate link on WooCommerce?
To create an affiliate link in WooCommerce:
- First, install the WC Affiliate plugin from your WordPress dashboard.
- Set it up using the setup wizard or manually create a new affiliate dashboard page.
- Once that’s done, go to your Affiliate Dashboard and open the URL Generator section.
- Enter the URL you want to promote, click Generate, and copy your new affiliate link to share.
Q. Do Affiliate links hurt SEO?
Not if done right! Affiliate links don’t hurt SEO as long as you use the proper tags (like rel=”nofollow” or rel=”sponsored”) and avoid overloading your site with them. Focus on providing valuable content, and Google will still see your site as helpful and trustworthy.
Q. Should I cloak Amazon affiliate links?
It’s best not to cloak Amazon affiliate links. Amazon’s Associates Program guidelines don’t allow link cloaking, and doing so could risk your account. It’s safer to use the raw affiliate link or Amazon’s native linking tools.
Q. How do I add affiliate disclosure to WordPress?
You can add an affiliate disclosure in several ways:
- Add a short statement at the top or bottom of your blog posts.
- Use a reusable block or shortcode for automatic insertion.
- Or install a plugin that adds disclosures site-wide.
- Something like: “This post contains affiliate links. If you click and make a purchase, we may earn a small commission at no extra cost to you.“
Subscribe to Our Newsletter
Get the latest WordPress tutorials, trends, and resources right in your inbox. No Spamming, Unsubscribe Anytime.

Thank you for subscribing to our newsletter!
Table of Content
- What It Means to Cloak Affiliate Links?
- Difference Between Link Cloaking and Link Shortening
- Why You Should Cloak Affiliate Links in WooCommerce
- Builds Trust with Users
- Helps with Search Engine Optimization (SEO)
- Create a Better Brand Image
- Protection Against Link Hijacking
- Easier Link Management
- More Control Over Redirection
- How to Cloak Affiliate Links Using a WordPress Plugin
- Step 1: Install WC Affiliate and Configure Basic Settings
- Step 2: Set Cloaking Affiliate Links Settings
- Step 3: Generate Affiliate Links
- How to Cloak Links Without a Plugin
- Step 1: Create a New Folder
- Step 2: Upload the index.php File
- Step 3: Add the Links in the Redirects.txt File
- Step 4: Block Crawlers
- Final Words
- Frequently Asked Questions (FAQs)
- Q. How do I create an affiliate link on WooCommerce?
- Q. Do Affiliate links hurt SEO?
- Q. Should I cloak Amazon affiliate links?
- Q. How do I add affiliate disclosure to WordPress?