Jump to content

Simple affiliate programs - how do they work?


V

Recommended Posts

I'm working on a web project where I need to generate something similar to affiliate links. For example, someone signs up and he/she gets a unique link (http://www.site.com/6372) and later I can display data according to the user's unique affiliate link.  I can't find any good info about this..  Does anyone know how affiliate programs work in general?

Link to comment
Share on other sites

If you want to generate a random, unique link, you can use a sufficiently complicated randomizer (You can use microtime() to get a random number, then run that through some hash algorithm, like md5().) and append the code to the end of a link with their e-mail address.

 

Send that to their e-mail address, check the code at the end of the URL with $_GET and compare the code to what's stored in your DB for that username at the time the code was generated.

 

If that's not what you're asking about, can you be more specific?

Link to comment
Share on other sites

The link provided in your example (http://www.site.com/6372) would be made using mod_rewrite. It might be mapped to something like http://www.site.com/?referral_id=6372. Then the page would have some code like this:

 

if(isset($_GET['referral_id'])) {
    // create a cookie on the user's computer to store the ID of who referred them
}

 

Then when registering you'd check to see if they have the referral cookie set. If they do and it's a valid code then add a successful referral to the user whose referral id is in the cookie.

Link to comment
Share on other sites

@sbaker thanks, your info was very helpful :) that's what I was asking for.

 

@AlexWD I haven't thought of using cookies, I'll give that a try thanks!

 

One thing I forgot to ask is, how do I know which referral link someone clicked on? Like if someone clicks on http://www.site.com/6372 from another site, how would I retrieve the referral link to use in my site?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.