{"id":899,"date":"2021-07-20T01:31:04","date_gmt":"2021-07-20T01:31:04","guid":{"rendered":"https:\/\/salarydistribution.com\/affiliate-marketing\/2021\/07\/20\/affiliate-link-cloaking-two-efficient-ways-to-cloak-links-on-your-wordpress-site\/"},"modified":"2021-07-20T01:31:04","modified_gmt":"2021-07-20T01:31:04","slug":"affiliate-link-cloaking-two-efficient-ways-to-cloak-links-on-your-wordpress-site","status":"publish","type":"post","link":"https:\/\/salarydistribution.com\/affiliate-marketing\/2021\/07\/20\/affiliate-link-cloaking-two-efficient-ways-to-cloak-links-on-your-wordpress-site\/","title":{"rendered":"Affiliate Link Cloaking \u2013 Two Efficient Ways to Cloak Links on Your WordPress Site"},"content":{"rendered":"<div id=\"post_content\">\n<div class=\"ftrd-img\">\n                                                    <img src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/A-Complete-Guide-to-Affiliate-Link-Cloaking-Banner.jpg\" alt=\"A-Complete-Guide-to-Affiliate-Link-Cloaking-Banner\">\n                                            <\/div>\n<p>Overly lengthy affiliate links are a common problem faced by affiliates, especially those who are new to the game. After all, how do you get users to click on these long links?<\/p>\n<p>Thankfully, the solution is quite simple: affiliate link cloaking. By \u201ccloaking\u201d a link, you will make it cleaner, and what\u2019s more, personalize it according to your branding. It\u2019s imperative if you sell <a href=\"https:\/\/www.cloudways.com\/blog\/affiliate-products-to-sell\/\" target=\"_blank\" rel=\"noopener\">affiliate products<\/a> on your website.<\/p>\n<p>Affiliate link cloaking offers a plethora of benefits, the most significant of which are clean, identifiable links. Here\u2019s everything you need to know about using them.<\/p>\n<h2 id=\"What\">What is Affiliate Link Cloaking?<\/h2>\n<p>As you can probably guess from the name, link cloaking refers, literally, to \u201ccloaking\u201d the original link and disguising it so it looks simpler. Think of it as a way of cleaning up the links.<\/p>\n<p>People generally avoid clicking on overly long links in the first place. They can seem shady, and your audience can find it hard to deem them \u201ctrustworthy.\u201d<\/p>\n<p>Thus, affiliate link cloaking improves how links are presented on your website. And remember, if you are using affiliate links, you also need to write and add appropriate <a href=\"https:\/\/www.cloudways.com\/blog\/affiliate-disclosures\/\" target=\"_blank\" rel=\"noopener\">affiliate disclosures<\/a>.<\/p>\n<h2 id=\"Benefits\">The Major Benefits of Using Affiliate Link Cloaking<\/h2>\n<p>Affiliate link cloaking offers a number of advantages to marketers promoting their services for a more reliable image.<\/p>\n<h3>User-Friendly Affiliate Link Management<\/h3>\n<p>If you are working with multiple affiliate programs, managing those lengthy links can seem difficult. But cloaking them and personalizing these offers a simple solution to easily managing multiple links together.<\/p>\n<p>Say you want to generate more traffic for your Cloudways affiliate program. If you don\u2019t use link cloaking at all, you\u2019d have to access the Affiliate Panel, find your unique ID, and then add it to any post.<\/p>\n<p><img loading=\"lazy\" class=\"lazy cw_postFancy_img aligncenter wp-image-89238 size-full\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/themes\/cloudways\/template\/img\/grey.gif\" data-original=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Link-Cloaking.png\" alt=\"Cloudways Unique Affiliate Link\" width=\"645\" height=\"47\"><\/p>\n<p><img loading=\"lazy\" class=\"cw_postFancy_img aligncenter wp-image-89238 size-full\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Link-Cloaking.png\" alt=\"Cloudways Unique Affiliate Link\" width=\"645\" height=\"47\"><i>Cloudways Unique Affiliate Link<\/i><\/p>\n<p>But by using a plugin, you can just add the link directly while you are editing the post in WordPress. It\u2019s so much better than using those long ugly links provided by different <a href=\"https:\/\/www.cloudways.com\/blog\/best-affiliate-programs-for-bloggers\/\" target=\"_blank\" rel=\"noopener\">affiliate programs<\/a>. Here\u2019s a good example from ThirstyAffiliates:<\/p>\n<p><img loading=\"lazy\" class=\"lazy cw_postFancy_img aligncenter wp-image-89401 size-full\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/themes\/cloudways\/template\/img\/grey.gif\" data-original=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Cloudways-affiliate-link.jpg\" alt=\"Cloudways affiliate link\" width=\"450\" height=\"181\"><\/p>\n<p><img loading=\"lazy\" class=\"cw_postFancy_img aligncenter wp-image-89401 size-full\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Cloudways-affiliate-link.jpg\" alt=\"Cloudways affiliate link\" width=\"450\" height=\"181\"><\/p>\n<h3>Easy to Share<\/h3>\n<p>Another major advantage of using link cloaking is that it makes your links very easy to share \u2013 an invaluable property for affiliate marketers.<\/p>\n<p>When they are small and easy to manage, they automatically become more shareable.<\/p>\n<h3>Convenient Link Tracking<\/h3>\n<p>Tracking the traffic from different links becomes much easier with affiliate link cloaking.<\/p>\n<p>You will be able to figure out which links are generating more traffic. By analyzing the content and the context where these links have been added, you can optimize others accordingly to maximize the effectiveness of your affiliate programs.<\/p>\n<h2 id=\"WordPress-steps\">How to Cloak Affiliate Links in WordPress by Using Thirstyaffiliates<\/h2>\n<p>Cloaking affiliate links in WordPress is actually quite simple, and you can easily do it through a third-party plugin like <a href=\"https:\/\/thirstyaffiliates.com\/\" target=\"_blank\" rel=\"noopener nofollow\">ThirstyAffiliates<\/a>. It\u2019s one of the best <a href=\"https:\/\/www.cloudways.com\/blog\/affiliate-marketing-tips\/\" target=\"_blank\" rel=\"noopener\">affiliate marketing tips<\/a> because it saves a great deal of time. Here\u2019s our step-by-step tutorial on cloaking links in WordPress.<\/p>\n<h3>1. Select a Prefix<\/h3>\n<p>The first step is to select a prefix for your affiliate links. The link prefix is essentially the part that is sandwiched between the link slug and the domain name. For instance, it could be something like yourwebsite.com\/<b>promotes\/<\/b>cloudways-hosting<\/p>\n<h3>2. Add Links<\/h3>\n<p>Once you have installed Thirsty Affiliates, you can add individual links to the plugin in order to cloak them. At the top, you need to add a title. Then, add the URLs and the destination. For instance, if you are using the <a href=\"https:\/\/www.cloudways.com\/en\/web-hosting-affiliate-program.php\" target=\"_blank\" rel=\"noopener\">Cloudways Affiliate Program<\/a>, setting the destination is easy by just copying your unique affiliate ID.<\/p>\n<p><img loading=\"lazy\" class=\"lazy cw_postFancy_img aligncenter wp-image-89243\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/themes\/cloudways\/template\/img\/grey.gif\" data-original=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Link-Cloaking2-1024x456.png\" alt=\"Add Links\" width=\"450\" height=\"200\"><\/p>\n<p><img loading=\"lazy\" class=\"cw_postFancy_img aligncenter wp-image-89243\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Link-Cloaking2-1024x456.png\" alt=\"Add Links\" width=\"450\" height=\"200\"><\/p>\n<h3>3. Insert the Cloaked Links<\/h3>\n<p>You can insert your cloaked links successfully into your content through the WordPress dashboard through a straightforward prompt that shows up in the dashboard, as shown below:<\/p>\n<p><img loading=\"lazy\" class=\"lazy cw_postFancy_img aligncenter wp-image-89244\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/themes\/cloudways\/template\/img\/grey.gif\" data-original=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Link-Cloaking3-300x134.png\" alt=\"Cloaked Links\" width=\"450\" height=\"200\"><\/p>\n<p><img loading=\"lazy\" class=\"cw_postFancy_img aligncenter wp-image-89244\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Link-Cloaking3-300x134.png\" alt=\"Cloaked Links\" width=\"450\" height=\"200\"><\/p>\n<h2 id=\"Without-Plugin\">Can You Cloak Affiliate Links Without a Plugin?<\/h2>\n<p>Yes, you can also do that. Here\u2019s our simple guide for cloaking affiliate links without using a plugin.<\/p>\n<h3>Step 1: Create a New Folder<\/h3>\n<p>First gain access to your server. You can do this using any FTP client like FileZilla. It will look something like this when you access the main directory on the server:<\/p>\n<p><img loading=\"lazy\" class=\"lazy cw_postFancy_img aligncenter wp-image-89245\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/themes\/cloudways\/template\/img\/grey.gif\" data-original=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Link-Cloaking4-300x159.png\" alt=\"FileZilla\" width=\"450\" height=\"239\"><\/p>\n<p><img loading=\"lazy\" class=\"cw_postFancy_img aligncenter wp-image-89245\" src=\"https:\/\/www.cloudways.com\/blog\/wp-content\/uploads\/Link-Cloaking4-300x159.png\" alt=\"FileZilla\" width=\"450\" height=\"239\"><\/p>\n<p>You can then create a new folder on the server. Name it something like \u201caffiliate links.\u201d<\/p>\n<h3>Step 2: Upload the index.php File<\/h3>\n<p>Then, create another file entitled index.php and add the code as given on Yoast\u2019s <a href=\"https:\/\/gist.github.com\/jdevalk\/5622742#file-index-php\" target=\"_blank\" rel=\"noopener nofollow\">GitHub repository<\/a>.<br \/><!--?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 '&lt;\/p&gt; &lt;p&gt;Make sure yor redirects.txt file contains a default value, syntax:&lt;\/p&gt; &lt;p&gt; &lt;\/p&gt; &lt;pre&gt;default,http:\/\/example.com&lt;\/pre&gt; &lt;p&gt;Where you should replace example.com with your domain.&lt;\/p&gt; &lt;p&gt;';&lt;br ?--><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;?php\r\n \r\n$id  \t= isset( $_GET['id'] ) ? rtrim( trim( $_GET['id'] ), '\/' ) : 'default';\r\n$f\t= fopen( 'redirects.txt', 'r' );\r\n$urls\t= array();\r\n \r\n\/\/ The file didn't open correctly.\r\nif ( !$f ) {\r\n  echo 'Make sure you create your redirects.txt file and that it's readable by the redirect script.';\r\n  die;\r\n}\r\n \r\n\/\/ Read the input file and parse it into an array\r\nwhile( $data = fgetcsv( $f ) ) {\r\n  if ( !isset( $data[0] ) || !isset( $data[1] ) )\r\n    continue;\r\n  \r\n  $key = trim( $data[0] );\r\n  $val = trim( $data[1] );\r\n  $urls[ $key ] = $val;\r\n}\r\n \r\n\/\/ Check if the given ID is set, if it is, set the URL to that, if not, default\r\n$url = ( isset( $urls[ $id ] ) ) ? $urls[ $id ] : ( isset( $urls[ 'default' ] ) ? $urls[ 'default' ] : false );\r\n\r\nif ( $url ) {\r\n  header( \"X-Robots-Tag: noindex, nofollow\", true );\r\n  header( \"Location: \" .  $url, 302 );\r\n  die;\t\r\n} else {\r\n  echo '&lt;p&gt;Make sure yor redirects.txt file contains a default value, syntax:&lt;\/p&gt;\r\n  &lt;pre&gt;default,http:\/\/example.com&lt;\/pre&gt;\r\n  &lt;p&gt;Where you should replace example.com with your domain.&lt;\/p&gt;';\r\n}<\/pre>\n<h3>Step 3: Add the Links in the Redirects.txt File<\/h3>\n<p>Once you have added the code, the next step for affiliate link cloaking is to create a new file. Name it <b>redirects.txt<\/b>. Essentially, you can add the destination URL as well as the link slug here.<\/p>\n<p>The format is as follows:<\/p>\n<p>Website-slug, https:\/\/destinationlink.com\/affiliateid=987<\/p>\n<p>Then give a line break, and add each affiliate link in a separate line:<\/p>\n<p>Website-slug, https:\/\/destionationlink.com\/affiliateid=987<\/p>\n<p>Cloudways, https:\/\/cloudways.com?cloudid=389<\/p>\n<h3>Step 4: Block Crawlers<\/h3>\n<p>You don\u2019t want Google or other search engines going through your redirects. To prevent that from happening, it\u2019s best to add a rule to your robots.txt file. Just open the robots.txt file and add a rule:<\/p>\n<p>Disallow: \/affiliate-links\/<\/p>\n<p>This is the name of the folder you create in the root directory.<\/p>\n<section class=\"blogInlineCtaNewSec\">\n<div class=\"mainWrap\">\n<div class=\"txt\">\n<h2>Are you a developer?<\/h2>\n<p>Earn Upto 15% recurring commission + CPA per Referral With Cloudways Affiliate Program.<\/p>\n<\/div>\n<\/div>\n<\/section>\n<h2 id=\"Plugins\">Top 3 Affiliate Link Cloaking Plugins<\/h2>\n<p>Now, if you want to use plugins, here are the top three that you can choose for your website.<\/p>\n<h3>1. ThirstyAffiliates<\/h3>\n<p>Thirsty Affiliates is one of the oldest players in the game and allows you to cloak links (tutorial given above) directly from your WP Dashboard.<\/p>\n<h3>2. Pretty Links<\/h3>\n<p>Pretty Link is another plugin used for link shortening, especially for custom links. It\u2019s a great way to clean up your affiliate links and cloak them according to your preferences.<\/p>\n<h3>3. Simple URL<\/h3>\n<p>Simple URL is another link shortener that works seamlessly with WordPress websites. It\u2019s a clean affiliate link cloaking plugin that you can use on your WordPress website to shorten the links.<\/p>\n<h2><b>Bottom Line\u00a0<\/b><\/h2>\n<p>This is a simple yet effective guide to cloaking affiliate links on your website. Using a plugin is obviously the easier option because it reduces time considerably. It also makes it easy for affiliates to streamline the different links that they use to promote certain programs.<\/p>\n<div class=\"blg-inr-sbsc-box\">\n<h4>Grow Your Income with Our Affiliate Program<\/h4>\n<p>Join, Promote, and Earn. It\u2019s That Simple!<\/p>\n<\/p><\/div>\n<div id=\"cw_blg_athr_sec\">\n<div class=\"blg-abt-athr-box\">\n<div class=\"cw-inr-blg-athr-img-box img-circle\">\n                                <img loading=\"lazy\" alt=\"\" src=\"https:\/\/secure.gravatar.com\/avatar\/ca207262cb8388dee6142bd36555d4a3?s=128&amp;d=mm&amp;r=g\" class=\"avatar avatar-128 photo class-custom class-custom-2\" height=\"128\" width=\"128\">                            <\/div>\n<div class=\"athr-desc-box\">\n<h4> <a href=\"https:\/\/www.cloudways.com\/blog\/author\/usman\/\">Usman Dar <\/a><\/h4>\n<p> Usman is a Digital Marketer at Cloudways- A Managed Cloud Hosting Platform, where he looks after affiliate partnerships and helps digital nomads in generating passive income.<br \/>\nHe is a foodie by heart, who loves to explore new eateries around his vicinity. <\/p>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div id=\"inrblog_btm_scrbBar\">\n                    <span id=\"close_inrblog_btm_scrbBar\" class=\"close_inrblog_btm_scrbBar\">\u00d7<\/span><\/p>\n<div class=\"blg-inr-rgt-side-wrpr text-capitalize text-center blg-subs-nws-affiliate-marketing\">\n<h3>\n                     Get Our Newsletter<br \/><span>Be the first to get the latest updates and tutorials.<\/span><br \/>\n    <\/h3>\n<\/div>\n<h2>Thankyou for Subscribing Us!<\/h2>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.cloudways.com\/blog\/affiliate-link-cloaking\/<\/p>\n","protected":false},"author":0,"featured_media":900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/posts\/899"}],"collection":[{"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/comments?post=899"}],"version-history":[{"count":0,"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/posts\/899\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/media\/900"}],"wp:attachment":[{"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/media?parent=899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/categories?post=899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salarydistribution.com\/affiliate-marketing\/wp-json\/wp\/v2\/tags?post=899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}