How to mask affiliate links in WordPress with the Pretty Links plugin

If you’re running an affiliate blog, then it makes sense to mask or shorten your affiliate links. People are sometimes hesitant to click on them when they see the affiliate string in the URL, and another reason is that affiliate links are hideous! Also, to comply with Google, it’s always good to ensure affiliate links are automatically marked as nofollow.

In this tutorial, I will show you how to install the free Pretty Links WordPress plugin and configure it for Google and performance. This is an awesome little plugin that allows you to create custom masked links with your own domain and track clicks on those links. I use the Pretty Links plugin on all of my websites.

You can grab the free Pretty Links plugin from the WordPress repository, or follow the steps below to install it from your WordPress dashboard.

Step 1

In WordPress under Plugins click on “Add New.”

WordPress add new plugin
WordPress add new plugin

Step 2

Search for Pretty Links and click on “Install Now” under “Shortlinks by Pretty Links” and then click “OK.”

Install the Pretty Links WordPress plugin
Install the Pretty Links WordPress plugin

Step 3

Then click on “Activate Plugin.”

Activate Pretty Links WordPress plugin
Activate Pretty Links WordPress plugin

After you’ve installed the plugin, it’s now time to configure the settings.

Default affiliate links to 301 and nofollow

The first thing you should do is click into the Pretty Links plugin settings and set the following:

  • Change the redirection type to “301 (Permanent).” Most likely you’ll be using the same shortened links for years, so a permanent status is what they should be set to.
  • Confirm that the links are set to “nofollow.” Google’s guidelines say that affiliate links should be set to nofollow. If this is set in the plugin settings, you don’t ever have to worry about forgetting to manually place this in the HTML code.
Pretty Links default to 301 and nofollow
Pretty Links default to 301 and nofollow

Settings to speed up Pretty Links

Shortening plugins like this can harm your WordPress site’s performance. This is why I always configure the following two options under the “Reporting” section:

  • Change the tracking style to “Simple Click Count Tracking.” You will get fewer stats, but it will be faster.
  • Enable the option to “Auto-Trim Clicks.” This will automatically delete all hits older than 90 days. This will help keep your database smaller.
Speed up Pretty Links plugin
Speed up Pretty Links plugin

I can’t stress how important the auto-trim feature is. If you don’t enable this, over time the _prli_clicks table in your database will get out of hand with thousands of rows.

To add a new masked (shortened) affiliate link click on “Add New” under the Pretty Links menu.

In the “Target URL,” input the affiliate URL destination. Make sure you are using HTTPS links. Google Chrome 80 now enforces using secure (HTTPS) links due to SameSite cookies.

Then choose your “Pretty Link” URL. I always use the following format so that I can track things separately in Google Analytics easier. You could change /go/ to whatever you want. Or not even have a separator.

domain.com/go/name

Add shortened link in Pretty Links plugin
Add shortened link in Pretty Links plugin

Then hit “Publish.”

You can now use your new URL anywhere on your website and it will redirect to the actual affiliate URL. You can view hits on the link within the Pretty Link dashboard. You can also edit your shortlinks at any time.

Pretty Links affiliate links dashboard
Pretty Links affiliate links dashboard

Summary

For any website running affiliate links, this plugin is a must-have. It will save you a lot of time, help you comply with Google, and give you the data you need to see which links are getting clicked on.

Did I miss anything important? Feel free to leave your comments below!

author bio
Brian Jackson

I craft actionable content and develop performance-driven WordPress plugins. Connect on X, subscribe to my newsletter (once a month), or buy me coffee.

26 thoughts on “How to mask affiliate links in WordPress with the Pretty Links plugin”

  1. I was using some mad redirect plugin which messed up my permalink structure (still trying to fix), but I am now using Pretty Links and it seems to be doing the job. I also like analytics it gives.

    Reply
    • Hey Harry! Ya I have been using Pretty Links for probably almost 5 years now. Probably one of the only plugins I have never had any problems with. Works great.

      Reply
  2. Hi Brian, thank you for the step-by-step instructions. I have a question I hope you can help with. I read somewhere on line that if ones wp site goes down for any reason the pretty links won’t work where you have placed them. Is this correct? Oh, I plan on using the free version. Will this do? Thank you for your time. Tracy

    Reply
    • I use the free version on all of my sites Tracy. And yes, if your site goes down the Pretty Links won’t work. But if your site is down, well, they shouldn’t be clicking on your links anyways :) I don’t use Pretty Links offsite.

      Reply
    • I have been using the free version of Pretty Links for probably 5+ years now. I’ve never had a single problem.

      Reply
  3. Hi. So I downloaded this plug in per your recommendation. I want to use it for when I link to external links (affiliate or not). I am at the point where you added infolinks as the pretty link, but I dont understand what target url to use. Every link I attach to will be a different url… I was thinking that it would put an attachment icon where I write my post. Then a box would pop up and I’d put the target url in there. That is not what happens, so I am pretty confused. Thanks!!

    Reply
    • The target URL is your external and or affiliate link (where you want it to go). You have to create additional links within the Pretty Link settings dashboard. You then use the “prettylink” that it generates within your post.

      However, for SEO reasons I wouldn’t use the plugin to normally link to external sites. You don’t want a redirect happening to normal sites. I only use the plugin for affiliate links.

      Reply
  4. Hi Brian,

    I recently installed Pretty links and am getting ready to do my affiliate links, but I think I have gotten myself confused a bit.

    Are you saying that you change ALL of your affiliate links to use the pretty link of “infolinks” and you don’t give each affiliate link a pretty link name of its own?

    Reply
    • Hey Verna,
      I give each affiliate link their own short name. So for example, domain.com/go/product1 and domain.com/go/product2. Hopefully that clears things up!

      Reply
  5. This plug sounds as the right one to install. Before we install it, can you specify if the “masked” link can be edited? We are looking for our body building site, to send traffic to affiliated vendor. Thanks.

    Reply
    • Hey Rey,
      Everything above is using the free version of Pretty Links. :) Nothing appears to be out of date to me. I use the free version on many of my sites. Never actually tried the paid version.

      Reply
    • Hey Pouya,
      You can just copy the link from the Pretty Links dashboard (click the copy to clipboard on the right) and use it as a normal link in the WordPress editor. This will work with every theme and plugin.

      Reply
  6. Hi! I have a question regarding the rel=”nofollow” attribute. I am using pretty links and I had set it up to add the attribute automatically to every new pretty link I create. Besides that, I add also the attribute to the code of the blog post where I insert the affiliate link, just in case one day I stop using the plugin, so I don’t need to add them manually later on. So the question is, is it OK to do that? Meaning having rel=”nofollow” on both the original link and the pretty link.
    Thanks!

    Reply
    • Hey Estela,
      But if you disable the plugin later, the links you created with Pretty Links would stop working. So I probably wouldn’t bother adding nofollow manually.

      Reply
      • That’s exactly why I do it, so the links are in the code in case I disable the plugin. But the question is not that, the question is if there is any issue/possible penalty for indicating nofollow to the same link in two different places.

        Reply
        • Hey Estela,
          I’m not aware of any penalties due to nofollow links. Google ignores nofollow links, so having that twice on a link shouldn’t be a problem.

          Reply
    • Hey Ajay,
      The target link is automatically hidden when you create a shortened URL in Pretty Links. For example, you could use something like domain.com/go/yourlinkname. If you’re referring to the target attribute, I’m not sure you can.

      Reply

Leave a Comment