Affiliate Link Encoder

One of our most powerful tools, the Affiliate Link Encoder (also known as the Automatic Link Encoder, or ALE for short) will automatically convert all existing links for your merchants into affiliate links for you! It can even target keywords to automatically encode them in a Merchant Link! This is an extremely useful tool for affiliates who have existing content on their pages, or for forum sites where other posters may be posting links or keywords.

Please see the full walkthrough (including screenshots) below, or check out our video tutorial for this tool on YouTube!

Purpose: The ALE allows you to identify keywords within your current content – both live and archived – and turn them automatically into affiliate links. The ALE also allows you to turn any outbound link to a merchant’s site into an affiliate link without any additional steps needed!

Example: Let’s say you have a beauty blog / website that has been live for quite some time and you post regularly. Now you have a ton of content – both current and historical posts - and you want to go back and ensure that affiliate links are added so you’re able to monetize your content. The good news is that you don’t have to go through every single one of your posts.

Getting Started

Step 1: Create ALE Subscription

From your AvantLink dashboard, hover over the AdTools, scroll down to the ‘Affiliate Link Encoder’ and select ‘Create ALE Subscription’.



You'll be taken to the configuration screen. Details on each option below:


Subscription Name: Choose a unique name that will help you keep track of each of your subscriptions!

Website: Select your affiliate website which you will use this subscription on.

Encode Links: Select ‘Yes’ if you want to turn any reference of a merchant website, like, into an affiliate link. This will ensure that any mention of in your posts will automatically turn into a commissionable affiliate link!

Select 'No' if you do not want to activate this feature (if you want to encode keywords only).

Encode Keywords: Select 'Yes' if you would like to select keywords that will automatically be converted to an affiliate link. For example, if ‘moisturizers’ is selected as a key word, it will be linked in the sentence “The most important part of facial care is to begin with a good moisturizer.”

Selecting ‘Yes’ will require a number of additional parameters. If you select ‘No’ and do not want to encode keywords (if you want to encode links only), you can skip down to Formatting for Encoded Elements.

Please note: You can only set five (5) keywords per subscription! (If you have more keywords than this, you may need to use a separate, second ALE subscription.)

  • Keyword Occurrence Limit: This allows you to select how many times in each post you would like the automatic linking to occur. The range can vary from every occurrence of the term, to just the first occurrence or in intervals up to the first 5 occurrences.
  • Exclude Keywords in Header Tags: Setting this option will prevent the ALE from encoding merchant and custom keywords that occur in header tags. For example if the ALE is set to encode the keyword "Cleanser" and this option is set, the following occurrence of "Cleanser" in the page HTML will not be encoded: <h2>Herbal Cleanser</h2>
  • Exclude Keywords in Class: Setting this option will prevent the ALE from encoding merchant and custom keywords that occur in a specific class. For example if the ALE is set to encode the keyword Moisturizer and this field is set to a text value of NoAle, then in the page HTML the following occurrences of Moisturizer will not be encoded.
  • Encode All Merchant Names/URLs: Setting this option will allow you to automatically use all of your active merchant’s names and URL-related information as keywords to encode. For example, if you mention the brand Pharmaca, this will automatically turn into an affiliate link even though it is not written as a URL. If you select ‘No’ for this option, then you can select individual merchants that you DO want to encode (or you can skip all default merchant information altogether).
  • Custom Keywords to Encode: This setting allows you to enter one or more custom keywords to encode as links. For each keyword you specify (e.g. "Affiliate marketing"), you can also select a merchant to associate with that text, and the destination URL (on the merchant's website) to direct your readers. If there are certain keywords that you DO NOT want encoded (perhaps one particular merchant that you want to exclude, or partial matches to other text that you have entered) you can choose "-Do not encode this text-" in place of a merchant to associate with the text. This will take precedence over any other encoding that is configured.
  • Boundaries: In the example above, you will see that you can select 'Before' and 'After' as a boundary. Think of these like quotation marks where in order to create the link from the keyword, the beginning or end of the word on site must exactly match the keyword you’ve encoded. Example: If you set the word “sleep” as a keyword without boundaries, then when you write “sleeping” in a post, the “sleep” at the beginning of sleeping will be encoded. We recommend selecting before and after boundaries for all keywords unless you are certain that you’d like to do otherwise.


Formatting for Encoded Elements: Setting this allows you to choose how the linked keywords will appear on your blog. The default will create the hyperlink and use the default formatting of your site; or, you can choose one of the options such as 'double underline' or setting a CSS class (to allow further customization on your side. Here is a preview of the options available to you:


Exclude Certain Links from Encoding: Selecting ‘Yes’ will allow you to customize 5 unique URLs that you would like to exclude from encoding. For example, entering the value ‘’ would skip over ‘’.

Open Links in New Window: Selecting ‘Yes’ will allow your site’s window to remain open when a reader clicks on another link and is redirected to another site. We recommend always selecting ‘Yes’.

Add rel=’nofollow’ attribute: Selecting this option will instruct some search engines / robots to not count this link for SEO purposes. We recommend always selecting 'Yes', since this is best practice for affiliate links.

Once all of the options are set, click 'Save'. Now you're ready to put the code on your site!

Step 2: Add your ALE code to your site

Click 'Get Source' and the HTML code will be created.

Copy this code into your site-wide html template, for example the 'template.php' or 'footer.php' pages. This will then be present on ALL of your pages on your website. Alternatively, if you only want to deploy it on some pages or specific pages, you can insert that code into the html of the web page(s) where you would like all your links encoded.


And you are done! The Affiliate Link Encoder is a powerful tool to automatically change keywords or existing links in your blog into affiliate links. This is a must for any blog or website that has a large amount of content, including archived posts, or forum posts!


How does it work?

If you're curious as to the technical underpinnings, this section is for you!

Let's take a look at the code. The HTML is just a link, pointing to a customized JavaScript library which has your merchants. If you follow the link in your browser, you'll see the code.

Here's a very stripped-down, pseudo example. It consists of 3 sections.

var aMD=new Array('','','');
var aMI=new Array('11935','13978','11917');

function avEncodeLinks(){
  var links=document.getElementsByTagName('a');
  foreach (links in document) as i {

function avInitiateAle(){avEncodeLinks();return;}
function OnDOMLoad() {addEventListener("DOMContentLoaded");}

(Note: Do not use this script on your live website! This is a simplified demo only. Please follow the walkthrough above to create your own ALE Subscription for your website!)

The first section simply correlates the target merchant URLs, with their merchant IDs.

The second section does the heavy lifting; it identifies the URL, swaps it out for your base AvantLink affiliate link, and inserts the corresponding merchant ID and redirect URL, and then replaces the existing link with the new URL.

The third section is just the logic to get the JavaScript to wait until your site is loaded, and then go through and target all of the links, dynamically replacing them.


Questions? Comments? Donations? Email us at!


Have more questions? Submit a request