Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Cloak Affiliate Links on Your WordPress Site

Do you want to cloak affiliate links on your WordPress site?

Cloaking your affiliate links in WordPress provides clean and easy-to-read links, which can increase the likelihood of clicks and conversions. It can also increase user trust.

In this article, we will show you how to easily cloak affiliate links in WordPress.

Cloaking affiliate links in WordPress

Link cloaking is a technique used to make long affiliate links into shorter and branded links on your WordPress website.

Often, affiliate links are lengthy, hard to remember, and show your affiliate username or ID like this:

http://www.affiliatesite.com/products/?product_id=123&affiliate=123

With link cloaking, you can shorten your ugly affiliate links into branded URLs like this:

http://www.yoursite.com/refer/productname

This can make your links look more trustworthy and professional to your audience, encouraging more clicks.

If you use affiliate links to make money from your WordPress blog, then you should cloak links to increase your click-through rate and conversions.

Many link-cloaking plugins will also help you measure the performance of your affiliate marketing strategies and optimize them for better results.

Cloaking affiliate links also adds an additional layer of security by masking the actual affiliate URL. This can protect your affiliate accounts and earnings from fraud or theft.

This can also help prevent your links from being blocked by social media sites or search engines, increasing the search visibility of your affiliate content.

Having said that, let’s see how you can easily cloak affiliate links on your WordPress website, step by step.

There are many link-cloaking and URL shortener plugins that you can use in WordPress, including Pretty Links and Thirsty Affiliates. Both plugins are great, but we will use Pretty Links for this tutorial since it’s a little more user-friendly.

You can easily cloak affiliate links in WordPress using Pretty Links. It is one of the best affiliate marketing tools for WordPress that lets you add, manage, and cloak affiliate links.

Install and Activate Pretty Links

First, you need to install and activate the Pretty Links plugin. For detailed instructions, please see our beginner’s guide on how to install a WordPress plugin.

Note: Pretty Links also has a free version that can cloak links. However, we will be using the Pro plan in the tutorial to unlock more features.

Create Your Cloaked Link

Upon activation, head over to the Pretty Links » Add New page from the WordPress admin sidebar.

Once you are there, you can start by typing a name for your link into the ‘Add Title’ option.

After that, you must select a link type from the ‘Redirection’ dropdown menu to create short and branded links for your affiliate program.

If you choose ‘Cloaked’, then the target URL will be hidden in your user’s browser, and they will only see your cloaked link. Some affiliate programs don’t allow this, so you will need to check first.

Another option is ‘307 Temporary’. It will replace the original URL with your new affiliate link and tell search engines that this link may change in the future.

Add a title for your affiliate link and choose the Cloaked option as the redirection type

Next, simply copy and paste your affiliate link into the ‘Target URL’ field.

Once you have done that, type the slug you want to use for your cloaked URL into the ‘Pretty Link’ field.

For example, if you want your cloaked link to be like the example below, then you will need to type the ‘/refer/bluetooth-speakers’ text into the ‘Pretty Link’ field. You will then get a link like this:

www.example.com/refer/bluetooth-speakers

Add cloaked affiliate link

Choose Attributes for Your Cloaked Link

After that, simply switch to the ‘Advanced’ tab from the sidebar on the left.

From here, you can add different attributes to your affiliate link by checking the box next to these options.

For instance, if you want to add a nofollow attribute to the external link, then simply check the box next to ‘No Follow’. This means that search engines won’t pass on any link authority to the site you are linking to.

Add attributes to the cloaked affiliate link

You can also check the ‘Sponsored’ box to tell search engines that your link is a paid advertisement.

Plus, checking the ‘Parameter Forwarding’ box can be handy if you want to pass a coupon code or customer ID to your cloaked link.

It’s also a good idea to check the box next to ‘Tracking’ so that you can view your affiliate link performance in the Pretty Links reports.

Configure Pro Settings for Your Cloaked Link

Once you have done that, switch to the ‘Pro’ tab from the sidebar on the left. Now, you can set an expiry date for the affiliate link by checking the ‘Expire’ option.

This will expand a tab on your screen where you can set the link’s expiry date after a specific date or number of clicks.

For example, if you choose the ‘Clicks’ option from the ‘Expire After’ dropdown menu and type 5 into the ‘Clicks’ field, then your affiliate link will immediately expire once 5 visitors have clicked on the link.

You can also type a URL for the expired redirect into the ‘URL’ field. If users click on the expired affiliate link, they will be redirected to this URL.

Set an expiry date for the cloaked affiliate link

After that, you can type the keywords that you would like to be replaced with your affiliate link into the ‘Keywords’ field.

This means that whenever the keyword you choose is written in your WordPress post or page, the plugin will automatically add its affiliate link to the keyword.

You can also easily replace another URL with your affiliate link by typing it into the ‘URL Replacements’ field.

Now, whenever Pretty Links finds this URL on your website, it will replace it with the cloaked link.

Choose a keyword and replacement URL

Once you are done, simply click the ‘Update’ button in the Publish section to store your changes.

After that, click the ‘Publish’ button in the same section to publish your cloaked affiliate link.

Save affiliate link

Add Your Cloaked Link to a WordPress Post or Page

Now, you can visit a WordPress post or page where you want to add the cloaked affiliate link.

Once you are there, select the text that you want to add the link to and then click the ‘Pretty Links’ icon in the block toolbar at the top.

This will open up a link prompt on your screen, where you can search for the cloaked affiliate link using its title or the link itself.

Add affiliate link in the block editor

Upon adding the link, just click the ‘Publish’ or ‘Update’ button at the top to store your settings.

Now, you can visit your website and click on the affiliate link. You will now see the cloaked URL redirecting you to the affiliate product page.

Preview for cloaked links

Bonus: Add Affiliate Disclosure for Each Blog Post

If your main source of income is affiliate links for different products/services on your WordPress blog, then it is a good idea to add an affiliate disclosure for each blog post.

This is a statement on your website that informs users that these links are paid advertisements. It promotes transparency, builds trust among your audience, and can also boost SEO.

An example affiliate disclaimer on a blog

Plus, adding an affiliate disclosure also helps you comply with laws and regulations, as many countries, including the USA, have laws about failing to disclose paid endorsements.

You can easily add an affiliate disclosure on your WordPress site by adding the following code to your theme’s functions.php file.

function disclosure() {
    return "<p class='disclosure'>This site may contain links to affiliate websites, and we receive an affiliate commission for any purchases made by you on the affiliate website using such links.</p>";
}
 
add_shortcode( 'disclosure', 'disclosure' );

However, keep in mind that the smallest error while typing the code can break your site and make it inaccessible.

That is why we recommend always using WPCode. It is the best WordPress code snippets plugin on the market that makes it safe and easy to add custom code to your website.

WPCode - Best WordPress Code Snippets Plugin

Upon plugin activation, you can simply head to the Code Snippets » + Add Snippet page from the WordPress dashboard. Here, click the ‘Use Snippet’ button under the ‘Add Your Custom Code’ option.

After that, select ‘PHP Snippet’ as the Code Type from the dropdown menu and add the code into the ‘Code Preview’ box.

Next, click the ‘Save Snippet’ button at the top and toggle the ‘Inactive’ switch to ‘Active’.

Saving your WPCode snippet

Once you do that, add the [disclosure] shortcode at the top of the blog posts to display an affiliate disclosure.

For more detailed instructions, see our tutorial on how to add affiliate disclosure for each blog post automatically.

We hope this article helped you learn how to easily cloak affiliate links in WordPress. You may also want to see our beginner’s guide on how to create an affiliate product box in WordPress and our expert picks for the best WordPress themes for affiliate marketing.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

19 CommentsLeave a Reply

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Jiří Vaněk

    I was waiting to start affiliate collaborations on my blog until I had more users and it made sense to do so. Initially, I planned to create the links manually, which would have meant a lot of effort and wasted time. Your solution is great and will save me a lot of time and work. I personally tried Pretty Links, and it suits me perfectly. The plugin is simple and very easy to understand. For me, it’s perfect.

  3. Ralph

    On my current blog I cloak affiliate links by 301 redirecting in hosting but I have 10 or less links so it is easy. I plan to open new blog that will be affiliate oriented and this method will waste me a lot of time. Your option looks way better, faster and easier. Thanks again for great and easy to understand guide for new bloggers.

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Admin

  4. Esi

    Please i am really looking for a way to cloak my links. I will prefer just a keyword to display that can redirect my visitors to the affiliate page. Please which free version can help me with this?

    • WPBeginner Support

      It would need to be attached to a url, just a keyword would require editing the hosts file on a computer.

      Admin

  5. Janus Rokkjær

    Looks like a lot of work for most of these plugins although the csv import is quite handy.

  6. Fares

    nice article but i believe the best practice is to do it without pluging because it will affect speed. any tips on how to do it manualy?

  7. Jeanine

    Great article with helpful tips. I have now set up the cloaking, but I was wondering about the following. Since all the links are redirects, it takes some seconds to load the links. Therefore I would like to show an “exit page” that says something like: Just waiting to redirect you to.. (shop name).. just a few seconds..

    Do you have a tip on how to show an exit page like that?

  8. Queen

    I use the thirsty affiliate and when it cloak’s my affiliate link and is clicked on it changes back to the default affiliate link. I don’t think that is normal is there a way to fix this? Thanks

    • WPBeginner Support

      Hi Queen,

      This is actually normal expected behavior. You can’t fix this unless you own the site where you are sending your users.

      Admin

  9. Naomi

    Can I ask why you put /refer or /recommend or anything else in the slug when cloaking?

    Why not just have example.com/product-name?

    • WPBeginner Support

      You can have the slug right after domain. However, using something as base has its own advantages. It tells users what kind of link it is. If you have a permalink structure where you use post or page title right after domain, then it will be hard for users to guess whether its a post/page or an affiliate link. You may also be using category/tag urls with no category/tag base like example.com/mycategory. Now if you create a category/tag for that particular product then this would cause conflict.

      Admin

    • Sinisa Vuksanovic

      Hi, and you can with refer/ or something simmilar modify your robots.txt file with Disallow: /refer/ if you think this is a good idea. I think it is.

  10. Harry

    Well I am giving Pretty links a go because I was using a pure redirection plugin before; but that seems to have really messed with my permalink structure in the Google index!

  11. Ajay

    Great but which one of these plugin is best for my website

  12. rahul

    I heard Matt Cutts saying cloaking any type of links is against quality guidelines. It is because user lands on page other than he see actually. Then how cloaking affiliate links is good?

    • Roland

      If you are into affiliate marketing, it is highly recommended to cloak your affiliate URLs to make them a neat & clean. Also SEO friendly approved by Google guidelines are Geo – Location, First Click free, URL Rewriting and Replacement of Java Scripts. Yust make sure that you do not lie. If you try to trick search engines or wurse people then it is considerd Black Hat SEO.

  13. Martin

    Whatever you do once the user switches browser, you won’t get your commission.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.