AvantLink HTTPS Link-Chain Fixer

I’m working on a script to modify all AvantLink Affiliate tracking links on your site to fix some of the known issues in switching to HTTPS. The AvantLink HTTPS Link-Chain Fixer script changes two things:

  • The URL to AvantLink, and
  • The link to the Merchant landing page.

The script has a built in 1 second delay to give AvantLink scripts like ALE time to do their thing first. You can see the script in action here.

* If any of your merchants do not support HTTPS do not use this script.
* This script requires jQuery to run.
* No Warranty. Use at your own risk.  

    function AvantLinkHTTPSLinkChainFixer(){
    /*version: 0.1e*/
    console.log("AvantLink HTTPS Link-Chain Fixer start:");
    jQuery('a[href*="avantlink"]').each(function(index) {
        /* affiliate tracking link fix */
        jQuery(this).attr("href", jQuery(this).attr("href").replace("http:", "https:"));
        /* merchant link fix */
        jQuery(this).attr("href", jQuery(this).attr("href").replace("url=http%", "url=https%"));
        /* optional: add rel nofollow ? */
        /* optional: add style to help in debugging ? */
        // jQuery(this).attr('style','background-color:yellow;');
        console.log(index + ") Fixer: " + jQuery(this).attr("href"));        
    console.log("AvantLink HTTPS Link-Chain Fixer done:");
    /* optional: script delay: 1000 = 1 second */
    setTimeout(AvantLinkHTTPSLinkChainFixer, 1000);

AvantLink HTTPS Link-Chain Fixer Options

jQuery(this).attr('rel','nofollow'); adds ref=nofollow to the affiliate links,
console.log("..."); lists the ads for you review in the javascript console. Both of these are optional. You can delete them or comment them out. If your site does not load affiliate ads via javascript you can remove setTimeout and just call AvantLinkHTTPSLinkChainFixer(); (or change 1000 to 0)

jQuery(this).attr('style','background-color:yellow;'); is in there so you see which ads are reviewed by the script. Use it to help you debug timing issues.

Here are the most common link-chain scenarios and what the script will repair.

BeforeYour SiteAvantLinkMerchant Landing PageAfter

Published by


Kimball is a website designer and developer in Goffstown, NH.

2 comments on:
“AvantLink HTTPS Link-Chain Fixer”

    1. @Shakil,
      Avantlink now supports HTTPS, so you should no longer need to fix their URLs. I recommend globally replacing non-secure AvantLink urls like href=”http://www.avantlink.com/click.php?…” to href=”https://www.avantlink.com/click.php?…”

      Do the same for banner/image ads too.

Leave a Reply

Your email address will not be published. Required fields are marked *