SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Hiding Affiliate Links w/PHP

    How do you hide the long drawn out affiliate link (e.g. Commission Junction) with a php or htm?

    I have seen it on other sites, and it looks better than affiliate links showing.

    I have been thinking about this for years, and I think I even asked once before, but never received a explanation.

    What are the effects...good or bad?

    How do I make it happen?

  2. #2
    SitePoint Guru
    Join Date
    Feb 2008
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some affiliate sites give you some javascript to cut and paste. This produces the link and you have no way of modifying it.

    If you have control over the link (ie you are given some straight forward html to copy and paste) you are able to forward via a URL of your own choice.

    Here is an example called external.php

    <?php
    switch($_GET['id'])
    {
    case 1:
    $loc = "http://cj.com/345345-345345";
    break;
    case 2:
    $loc = "http://cj.com/345345-334345";
    break;
    case 3:
    $loc = "http://cj.com/345345-445345";
    break;
    case 4:
    $loc = "http://cj.com/345345-377895";
    break;
    default:
    die("Invalid ID specified);
    }

    header("Location: " . $break);
    ?>

    Code isn't tested but should be OK. Let me know if that is what you needed.
    You can then call the script external.php?id=1 or external.php?id=3 to be redirected to the appropriate link.

  3. #3
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by corbyboy View Post
    Some affiliate sites give you some javascript to cut and paste. This produces the link and you have no way of modifying it.

    If you have control over the link (ie you are given some straight forward html to copy and paste) you are able to forward via a URL of your own choice.
    Thanks for the reply.

    If I wanted to seo the file, how would I add one affiliate link per location?

    For example: keyword php keyword2 php keyword3 php

    Instead of a single file to hold all links...many files to hold single links.

    I hope I did not just confuse things.

    Thanks in advance.

  4. #4
    SitePoint Guru
    Join Date
    Feb 2008
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    example.php
    Code PHP:
    <?php
    header("Location: http://cj.com/click-3434-34343");
    ?>

    example2.php
    Code PHP:
    <?php
    header("Location: http://cj.com/click-3434-678343");
    ?>

    example3.php
    Code PHP:
    <?php
    header("Location: http://cj.com/click-3434-378783");
    ?>

    Repeat for each file and affiliate link. This would have no SEO benefits however, as you are linking away from your site, no into your site.

  5. #5
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much, for your swift answers.

    I should have just picked up a php book and figured it out. But I lost a bunch of my programming books when I moved some time ago.

    A very big thanks for the help.

    Now is this method frowned upon, or considered a redirect, or is it okay?

    I know search engines frown upon affiliate links too, so it is a catch 22 question.

    Just a question of curiosity.

  6. #6
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am also curious about another thing.

    What if I want to use the Javascript form of the affiliate link?

    I don't know if it makes any difference, but I was told that html links will not convert if the customer does not have cookies enabled.

  7. #7
    SitePoint Guru
    Join Date
    Feb 2008
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Search engines don't have a problem with affiliate links as such, they are just regular links to them. A search engine won't feature your affiliate link in the SERPS anyway, so it makes no difference. Most affiliate links forward to the homepage so that is the URL that will feature in the SERPS.

    As for having cookies diabled, I don't know of any affiliate network that doesn't work by using cookies. So if a user has cookies disabled you will probably get no comission - certainly none if they make a purchase on a return visit.

  8. #8
    SitePoint Zealot livetech's Avatar
    Join Date
    Oct 2008
    Location
    Colwyn Bay, North Wales, UK
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by oregonthunder2 View Post
    I am also curious about another thing.

    What if I want to use the Javascript form of the affiliate link?

    I don't know if it makes any difference, but I was told that html links will not convert if the customer does not have cookies enabled.
    Danger with Javascript is people have noscript running or other things which disable it, so you'd get clicks but no commission.

  9. #9
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So is there any benefits from hiding these links, or does it just make it look pretty?

  10. #10
    SitePoint Zealot livetech's Avatar
    Join Date
    Oct 2008
    Location
    Colwyn Bay, North Wales, UK
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by oregonthunder2 View Post
    So is there any benefits from hiding these links, or does it just make it look pretty?
    Main reason is to appear more authoritive. Links to many internet users such as "http://www.affiliateprogram.com/?ref=me" look ugly and less authoritive. Whereas http://www.mydomain.com/go/affiliateprogram.php looks like you're going into your site, when you're not.

    The other reason is ease of use. Suppose if the affiliate program changes it's url structure for whatever reason **cough**Textlinkads**cough**, then you'd only have to change one file, rather than sitewide changes.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •