1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[How to] Mask your affiliate links from end users

Discussion in 'Black Hat SEO Tools' started by thedorf, Feb 23, 2017.

  1. thedorf

    thedorf Supreme Member

    Joined:
    Oct 1, 2008
    Messages:
    1,223
    Likes Received:
    721
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    Just a quick how to for you all. Many users will hover over a link, look at the bottom of the browser, and see if it is an affiliate link. If it is most who do this will open a new window and manually type in the website address without the affiliate code attached.

    The following will mask the affiliate link, but, it only masks the link on your website. Once the link is clicked the affiliate code is added to the link and visible in the address bar on the website the end-user is forwarded to - but most will not notice this and in any case your cookie has already been set.

    THIS IS NOT COOKIE STUFFING.

    Read: "On the World Wide Web, cookie stuffing (also cookie dropping) is an affiliate marketing technique in which, as a result of visiting a website, a user receives a third-party cookie from a website unrelated to that visited by the user, usually without the user being aware of it." Source: https://en.wikipedia.org/wiki/Cookie_stuffing

    Using my technique the cookie is being set by the website the cookie is valid for, a small but major difference.

    You can see this in action on my website but the website is only one day old and is still ugly as hell: http://www.100prowebsitetips.com

    A non-affiliate link to the company I am promoting is: http://www.a2hosting.com

    Here is the HTML:

    Code:
    <a href=''http://www.a2hosting.com" rel="nofollow" id="a2">http://www.a2hosting.com</a>
    Here is the Javascript that does the magic:

    Code:
    function loadlink(url, callback){
    var link = document.getElementById( 'a2' );
    link.addEventListener( 'click', function() {
    link.setAttribute("href",url);
    callback();
    });
    }
    
    loadlink("http://www.a2hosting.com?aid=YourAffiliateId", function(){
    setTimeout(function() { document.getElementById( 'a2' ).setAttribute("href","http://www.a2hosting.com"); }, 1000);
    });
    
    The callback function resets the link on my webpage to be the link without the affiliate code - but if clicked it will again forward with the affiliate id attached.

    Cheers,

    Phillip aka thedorf

    P.S. Always notify your affiliate manager if you do this to be on the safe side - I've yet to find an affiliate manager that had a problem with this.

    P.S.S. Mods if there is a problem with this post just delete it - whatever.
     
    • Thanks Thanks x 6
    Last edited: Feb 23, 2017
  2. Nonilol

    Nonilol Elite Member

    Joined:
    Mar 1, 2015
    Messages:
    1,632
    Likes Received:
    555
    Gender:
    Male
    Occupation:
    Media Informatics & Webdev Student
    Location:
    Hamburg, GER / Southampton, UK
    Home Page:
    Hey Phillip, would you mind explaining why the timeout is necessary there? (Unfortunately, I'm not very good with JavaScript)

    Gonna try this one out tomorrow, pretty smart approach!
     
  3. thedorf

    thedorf Supreme Member

    Joined:
    Oct 1, 2008
    Messages:
    1,223
    Likes Received:
    721
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    The timeout is necessary because the callback function will change the link back to the original href before the forward to the new website occurs and we will not get the affiliate code with the link.

    We have to let the click take effect, the forward occur, and then change the link back to it's original state without the affiliate code attached so it still shows on our website to be a non-affiliate link. If we did not do this another mouse-over on the link (on our website) would show the changed href with the affiliate code attached.
     
    • Thanks Thanks x 1
  4. hay706

    hay706 Junior Member

    Joined:
    Mar 6, 2016
    Messages:
    119
    Likes Received:
    38
  5. thedorf

    thedorf Supreme Member

    Joined:
    Oct 1, 2008
    Messages:
    1,223
    Likes Received:
    721
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    Looking at the WordPress Pretty Link website it's hard to tell if they are using 301 redirects (I don't recommend this as you are misleading the end-user where they are going) or just shortening the url. A shortened url will usually be assumed to be an affiliate link by most savvy internet users. Besides, not everyone is on WordPress.

    My method does not mislead the end-user where they are going, all I am doing is adding a variable along with the URL. The end-user goes exactly where the link states they are going. Also, I do not violate any FTC rules doing this that I am aware of. I am not paid to do this and I only promote products I have purchased and tried myself.

    Plus, my method costs nothing. I reply on the affiliate program for reporting clicks from my website so I get reporting as well.

    But hey, you do what you want to do...
     
    • Thanks Thanks x 1
  6. neOtron

    neOtron Regular Member

    Joined:
    Nov 22, 2012
    Messages:
    353
    Likes Received:
    452
    Home Page:
    This is absolutely brilliant piece of code :)

    Thanks alot :)
     
  7. jamie3000

    jamie3000 Supreme Member

    Joined:
    Jun 30, 2014
    Messages:
    1,308
    Likes Received:
    586
    Occupation:
    Finance coder looking for semi-retirement
    Location:
    uk
    Good share mate
     
  8. abhi007

    abhi007 Jr. VIP Jr. VIP

    Joined:
    Aug 31, 2010
    Messages:
    5,700
    Likes Received:
    3,883
    Location:
    Theatre of dreams :)
    I am gonna put this to use for another affiliate thing I have in mind!