How to Cloak Links on Blogger - Simple

How to Cloak Links on Blogger - Simple

If you're using Blogger (BlogSpot) and want to hide or "cloak" your any link or affiliate links, you're in the right place. 

While Blogger doesn’t have as many features as WordPress (like plugins for link cloaking), you can still achieve this with a bit of JavaScript magic. Let me guide you through it step by step!  

What is Link Cloaking? 

Link cloaking means hiding the actual URL of your affiliate links to make them look cleaner and more professional. For example:  

Normal Affiliate Link: https://affiliate.com/productpage?tracking-affiliatenumber-camapaign-blah-blah

Cloaked Link: https://sdavidrince.space/go/productpage  


Why Cloak Links on Blogger?

1. Professional Look: Cloaked links look cleaner and trustworthy.  

2. Easier to Share: Short and branded URLs are easier to remember and share.  

3. Customization: You can brand your links with your domain name.  

Step-by-Step Guide to Cloak Links on Blogger

Adding the JavaScript to Your Blog  

Follow these steps to insert the code into your Blogger template:  

1. Go to Blogger Dashboard > Theme > Edit HTML.  

2. Use CTRL + F (or CMD + F) to find the </head> tag in the code.  

3. Copy and paste the following JavaScript code just before the </head> tag: 

<script>

// Blogger Affiliate Link Cloaker by sdavidprince.space

//<![CDATA[

var key = window.location.href.split("go/")[1]?.replace("/", "");

var urls = {

  'product1': 'https://www.example.com/product1', // Replace with your affiliate link

  'product2': 'https://www.example.com/product2', // Replace with your affiliate link

};

if (key) {

  if (urls[key]) {

    window.location.href = urls[key];

  } else {

    document.write("'" + key + "' not found :(");

  }

}

//]]>

</script>


2. Formating Your Cloaked Links**  

Here’s how to create cloaked links using the code above:  

-Format: http://yourblog.com/go/keyword  

- Replace `keyword` with the name you assigned in the script (e.g., `product1`).  

Example:  

If your affiliate link is:  

https://www.example.com/product1

Then your cloaked link will be:  

http://yourblog.com/go/product1


Adding More Links

To add more links, just include additional rows under var urls = { in the script.  

Example:  

var urls = {

  'product1': 'https://www.example.com/product1',

  'product2': 'https://www.example.com/product2',

  'product3': 'https://www.example.com/product3', // Add more as needed

};


How This Script Works  

1. The script checks for a /go/keyword pattern in your URL.  

2. Based on the keyword, it redirects users to the actual affiliate link you’ve defined in the script.  


Note:

- If you’re using a custom domain, the link will look like this:   http://www.exampleblog.com/go/keyword  

- If you’re using a default Blogger address, it will look like this:  

 http://yourblog.blogspot.com/go/keyword  


And that’s it! With just a small code snippet, you can now cloak affiliate links in Blogger and make your URLs look clean and professional.

Happy ...mxm 

Please write your comments or send a webmention
Webmention Notice

This site accepts Webmentions via webmention.io/www.sdavidprince.space/webmention. You can also reply to syndicated posts, and your responses may be backfed (posted back here) via brid.gy.

What does all these mean? Read more about it. Respect this and keep mentions relevant.

Dark/Light
Font Size
A-
A+
Best Personal Blogs About Life - OnToplist.com
Translate

Explore: Navigation