Need help creating referral code

Discussion in 'PHP' started by fried2009, Jan 28, 2006.

  1. #1
    Hello,
    Can someone help me create a script so that people can put my link on their site and when others click on it and signup for my services it records who it was from?

    It is for a site like tcmhosting.net
     
    fried2009, Jan 28, 2006 IP
  2. Nathan Malone

    Nathan Malone Well-Known Member

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Well, here is a (very) simple way for people who have cookies enabled. Just put the following code at the top of every page of your site (assuming your site is written in php), and when someone purchases a product from you, just pull the data from $_COOKIE['ref'].

    
    <php
    $ref = $_GET['ref'];
    $domain = $_SERVER['SERVER_NAME'];
    if ($ref) {
    setcookie('ref', $ref, time()+5184000, '/', $domain, 0);
    }
    ?>
    
    Code (markup):
    Then have everyone who links to your site simply link to it like this: digitalpoint.com?ref=myrefid and their affiliate id will be placed in a cookie and will be credited to them (assuming that the visitor has cookies enabled) if the person they refered buys a product within 60 days.

    A few things on this script:

    1. It only works for people who have cookies enabled.

    2. It would be best to do a 301 redirect from the link with the affiliate id to the page without the id on the url for search engine purposes.

    3. There is a slight possibility that your server doesn't have $_SERVER['SERVER_NAME'] enabled, which would mess up this script.

    4. You will obviously need to figure out a way to associate affiliate id's with people so you get the right paychecks to the right people.

    5. You might consider changing "?ref=asdf" to something else which would not identify it as an affiliate link.

    Hope this helps...
     
    Nathan Malone, Jan 28, 2006 IP
  3. fried2009

    fried2009 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Where would I put this code? Also if I gave someone named test a referral link would I just give him a link like tcmhosting.net?ref=test ? I'm wondering how to actually set this up.
     
    fried2009, Jan 29, 2006 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sounds like you could do with gettng a freelancer to do this for you. It's too complicated to knock it out as a script suggestion here in a forum post considering it will involve a database etc. I'd recommend get-a-freelancer.com .
     
    T0PS3O, Jan 29, 2006 IP
  5. discoverclips

    discoverclips Peon

    Messages:
    491
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    create a unique url for each referrer like:

    referrer.php?name=UNIQUE

    let the visitor fill out the form you want, add a hidden input field with the referrer's name
    <input type="hidden" name="referrer" value="<? echo $_REQUEST['name']; ?>">
     
    discoverclips, Jan 31, 2006 IP
  6. asr_guy

    asr_guy Peon

    Messages:
    178
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Just buy a low cost affiliate tracking script and save yourself some headaches. Some are around $99 and I have seen cheaper.

    -Peter
     
    asr_guy, Feb 8, 2006 IP
  7. YIAM

    YIAM Notable Member

    Messages:
    2,480
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    #7
    I can do it for you as a free lancer. for rate PM me
     
    YIAM, Feb 10, 2006 IP