How to Manage Affiliate Links for Multiple Websites (Without Plugins)

Love it? Share it!

I run multiple WordPress websites and even though I started with plugins like Pretty Links or Thirsty Affiliates to manage my affiliate links, I soon realized that this is not what I wanted.

In this detailed tutorial, I will show you step by step how to set up a structure for affiliate links that you can use on multiple websites.

The best part is that you won’t need to install any plugins that only slow down your WordPress.

Disclosure: Please note that some of the links in this post are affiliate links for products I use and love. This means if you click on such a link and take action (like subscribe, or make a purchase), I may receive some coffee money at no extra cost to you. This helps me create more content free of charge for you. And, as an Amazon Associate, I earn from qualifying purchases. Thanks for your support!

Speed of Website

It’s a known fact the plugins can considerably slow down your WordPress website. It’s no wonder since you introduce with each installed plugin a new code that must be processed.

To make your website as fast as possible, you should avoid plugins and use only those that are absolutely critical.

But hey, maybe your website is quite fast and you don’t need to worry, if you’re not sure, take the speed test to find out.

My website is quite fast but I don’t want to slow it down with unnecessary plugins.

Speed of Redirection

The second aspect is the speed of redirection. If you use plugins to manage your affiliate links, you rely on the core functionality of WordPress.

This means that the plugin needs to wait for the core code to be full loaded before it’s able to execute itself.

If your WordPress is not running on a super-fast hosting, this will add precious seconds to the redirecting time.

A manual solution which I will show you here doesn’t depend on WordPress core at all, so it’s ultimately faster.

Text Replacement

Today, I have all my affiliate links in a single easily memorable format https://zavrel.net/likes/abcd

I’m using Mac so I was able to utilize a text replacement function. This means that anytime I type @likes, it gets replaced with https://zavrel.net/likes/ so I can just add the last part of the link, which is the name of affiliate partner.

Setup

I use a free Netlify service that helps me redirect all my affiliate links which I manage from a single file. Here’s how it’s done.

GitHub

First, you’ll need to create a GitHub repository.

If you don’t have a GitHub account yet, go to GitHub.com and sign up for free.

Once you have your GitHub account, create a new repository, give it a name (1), make it Private (2) and make sure to check the Add a README file option (3).

Finally click that green button at the bottom (4).

Great, now it’s time to get your repository to your computer.

GitHub Desktop

First, you need to download and install GitHub Desktop.

Next, you will sign in with your GitHub account and clone your repository so it’s available on your computer.

Once you have this, you will navigate to the directory where your repository is stored and create a new file inside called _redirects without any extension.

Use any code editor you prefer; I’m using Microsoft Visual Studio Code.

Inside _redirects file, you’ll create two columns. The first column will hold your shortcut for each affiliate link without domain name, in my case it’s /likes/ followed by the name of the product.

Each time I acquire my unique affiliate link, I will add a new line to my _redirects file, so it looks like this:

/likes/astra https://wpastra.com/?bsf=4514

Once I have all my links collected, I save the _redirects file and upload it to GitHub.

Uploading changes to GitHub

Go to GitHub Desktop, select your repository and notice how it tracks all your changes.

Click the blue button to commit (submit) the changes of the file to main (the main branch of your repository):

Next, you need to push (upload) the changes to origin (remote repository) in the cloud:

Finally, go to your GitHub account and check that your changes have been successfully uploaded:

Netlify

Now it’s time to deploy your GitHub repository to Netlify CDN.

Go ahead and create a free Netlify account if you don’t have one already.

Since you already have a GitHub account, you can use it to sign up without creating a new set of credentials:

Now it’s time to deploy your repository which means that it will be accessible from the internet via the fast content delivery network.

Locate the Add new site button and choose Import an existing project from available options:

Next, you’ll choose the Git provider to connect, in our case, it will be GitHub:

You might need to provide your GitHub credentials and confirm that Netlify can actually access your GitHub account.

Pick your repository in order to link it to your site on Netlify:

You don’t need to change anything in site settings, just click the Deploy site button:

Once your site is deployed, it will have a randomly generated name and you can already test that your redirecting is working:

In my case, typing https://pensive-joliot-2cb281.netlify.app/likes/wordpress in the browser will get me to the wordpress.com account with my affiliate ID:

Now it’s time to finally connect your own domain name to create the correct structure for your affiliate links.

Connecting you domain name

In this step, I assume that you already have a domain name registered. If you don’t, go ahead and grab some. It’s not really important what’s the name since you’ll use it exclusively for affiliate links.

You can’t use the domain name of your existing WordPress blog unless you’re willing to use a static WordPress website.

But domains are really cheap these days so it won’t hurt you to have another one just for this purpose.

Once you have your domain name ready, you need to add it to Netlify:

1. Go to Domain settings:

2. Locate and click Add custom domain button:

3. Fill out your domain name:

4. Confirm that you want to delegate your domain to Netlify:

5. Click the Check DNS configuration link:

6. Scroll all the way down and click the Set up Netlify DNS for…… link:

7. Verify your domain:

8. Don’t add any new DNS records, just click Continue button:

9. Write down all four nameservers:

10. Go to your domain registrar and locate authoritative nameservers:

11. Change nameservers so the domain points to Netlify:

12. After a while, you should see that your domain has been connected to Netlify and uses Netlify DNS:

13. Test your new affiliate link structure which should redirect you to a specific affiliate product:

Perfect! Now you can use your new affiliate link structure.

Each time you add a new affiliate product to your list, you will commit changes to your repository and push it to the cloud.

Netlify will do the rest automatically for you so you can use your new affiliate link shortcut.

In WordPress, you just add a link the usual way, but with text replacement feature on Mac, you can use the @likes shortcut:

Don’t forget to mark your affiliate links as nofollow and sponsored to make Google happy.

Yoast plugin will make it easy as it adds those two options right into the popup window as you can see at the image above.

Love it? Share it!
Default image
Jan Zavrel

Jan Zavrel is an author, teacher, online entrepreneur and Evernote Certified Consultant who runs multiple projects focused on productivity, fitness, web development and passive income.

He is also active as an instructor on Udemy and Skillshare.

His books are available via Amazon.