Link Cloaking with Javascript

5 replies
Hello everyone,

This is the script I'm currently using to 'cloak' my affiliate links.

Code:
<script type="text/javascript">
function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[[]/,"\[").replace(/[]]/,"\]");
  var regex = new RegExp("[\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

var redirect_value = getQuerystring('a');

var websites = [
                "MyAffiliateLink1", 
                "MyAffiliateLink2",
                "MyAffiliateLink3"
                ]

if (redirect_value!="null")
{
window.location=websites[redirect_value];
}
</script>
I just have a question regarding how my affiliate ID would be recognized. I'm with one company that <b>appears</b> to use a similar system to Clickbank, however it's impossible to be sure, and they register hits through my link (No sales to test yet).

I'm wondering if this will be safe to use when it comes to using Clickbank/Neverblue/etc affiliate links. Safe as in the hit will still register and I would still get a commission for the sale if one were made.

Edit: The reason I ask is because Clickbank in particular does not have great tracking, so unless I'm misinformed, I can't see how many hits have been sent to my link
#cloaking #javascript #link
  • Profile picture of the author alucard001
    I think clickbank has a google-analytic-like tracking system which you can see how many hits you get from particular link.

    It is in "Reporting" > "Analytics"

    Is it what you want?
    {{ DiscussionBoard.errors[1656720].message }}
  • Profile picture of the author Boomachucka
    The plan for this is to forward people from a pdf file to the redirect, so it should be fine since it's not going to be running on any of my sites.

    If that's the case and I were to use it on a site, is there no way around what google does and does not like about this sort of practice? You know, other than being 'honest' and letting people delete your clickbank id
    {{ DiscussionBoard.errors[1657655].message }}
  • Profile picture of the author customertools
    IF you run wordpress, I'd scrape this and use the wordpress plugin GoCodes. It will cloak your links a google friendly way, and you know the affiliate code is working with it. I use it on a lot of websites.

    -Brad
    {{ DiscussionBoard.errors[1664738].message }}
  • Profile picture of the author Srikanth D
    Gocodes is really simple and useful. But I am looking for a plugin that has tracking integrated. As of now, I am not able to track the clicks on a particular affiliate link through blog stats or analytics on a daily basis. Although Gocodes does track clicks, I want to be able to track on a daily basis to compare with the affilaite tracking system.
    Signature
    >> Getting back into IM game <<
    {{ DiscussionBoard.errors[1664825].message }}

Trending Topics