Welcome Guest, Not a member yet? Register   Sign In
Affiliate system
#1

[eluser]bondjp[/eluser]
Basically is to track users coming to the site from the affiliate link and track if they buy a membership and pay the affiliate.
Can anyone tell me the best way to implement this affiliate system?
What to look for?
Has anyone done it or can point me in the right direction?
Thanks
#2

[eluser]sherwoodforest[/eluser]
what information do you have about the incoming visitor, anything on your side or is it all new

sherwood
#3

[eluser]bondjp[/eluser]
[quote author="sherwoodforest" date="1283898403"]what information do you have about the incoming visitor, anything on your side or is it all new

sherwood[/quote]

It's all new.
#4

[eluser]sherwoodforest[/eluser]
First you at least need to know what affiliate they came from

from either from
$_SERVER['HTTP_REFERER']
or
JavaScript history.back()

I would validate them (screen out the bots and google)
I would then check to see if they came from a known affiliate if so I would store in a cookie the affiliate id until they buy the membership. then I would store on the membership record the id of the affiliate.

What I would avoid is storing the data, before membership and before validation. Unless you want to track conversion rate by affiliate and not just conversions.

I hope this helps
#5

[eluser]Vheissu[/eluser]
Here is how I would do it.

Obviously when you're dealing with affiliates some kind of affiliate code is being passed through in the link so like so; http://www.example.com/users/referral/94239893 - This would send the visitor to the users controller, call the referral function and feed through the affiliate number.

I would then store this number in a session cookie and store it for a maximum of 10 minutes. If the user creates an account within that time frame, I would then check for the presence of the cookie and any value contained within it which would equate to another user.

You don't need to check for bots because you are only checking for the presence of the affiliate cookie if an action like a signup or purchase has been completed and no bots will be doing that (well you hope so).
#6

[eluser]bondjp[/eluser]
[quote author="Vheissu" date="1283961388"]Here is how I would do it.

Obviously when you're dealing with affiliates some kind of affiliate code is being passed through in the link so like so; http://www.example.com/users/referral/94239893 - This would send the visitor to the users controller, call the referral function and feed through the affiliate number.

I would then store this number in a session cookie and store it for a maximum of 10 minutes. If the user creates an account within that time frame, I would then check for the presence of the cookie and any value contained within it which would equate to another user.

You don't need to check for bots because you are only checking for the presence of the affiliate cookie if an action like a signup or purchase has been completed and no bots will be doing that (well you hope so).[/quote]

Ok. First part is easy to do. After getting the affiliate code we could redirect to the register page or home page.
Something like this:
Code:
$affiliate=$this->uri->segment(3);
................
redirect('home');

2- This i don't know how to do it. I suppose i could do set_userdata like this:
Code:
$this->session->set_userdata('affcode', '94239893');

How can i store it for 10min?
Why 10min? Isn't 10min too short? For affiliates normally i see the cookie last for 30-45-60, etc days...

How can i check for the value when the user registers?
Is this correct?:
Code:
$affiliatecode=$this->session->userdata('affcode');

So in the end we would have something like this?:

Code:
$affiliate=$this->uri->segment(3);
$this->session->set_userdata('affcode', $affiliate);
redirect('home'); // or other page we want the user to end up

Thanks.
#7

[eluser]Vheissu[/eluser]
Yep. All of the code you posted would work for what you want it to do. I'm not sure how you can explicitly set an expiration on a per variable basis, but I know in the config.php file there is a value called "sess_expiration" which lets you set the expiration in seconds, I think the default is 7200 seconds or something like that.
#8

[eluser]bondjp[/eluser]
I was digging around and found that we can set_cookie.
Wouldn't this be a better solution?

Code:
$affiliate=$this->uri->segment(3);
$cookie = array(
                   'name'   => 'affcode',
                   'value'  => '$affiliate',
                   'expire' => '2592000', // 30 days
                   'domain' => '.mydomain.com',
                   'path'   => '/',
                   'prefix' => 'aff_',
               );


set_cookie($cookie);
// Or
set_cookie('affcode', $affiliate, '2592000'); //is this better?

redirect('home'); // or other page we want the user to end up
// or
$this->load->view('home');

So when the user registers we can check if cookie is set or not like this:

Code:
if (get_cookie('affcode')) {
$affiliate=get_cookie('affcode');

// then save affiliate code into the DB for later use

// and then delete the cookie
delete_cookie('affcode');

}

Is this ok?
#9

[eluser]Vheissu[/eluser]
You just came up with a better solution on your own, awesome. I was wrong to say that you should use a session variable because storing a session variable for 30 days would not be plausible nor practical. So yes, storing the code in a cookie and checking for its presence and value is the right thing to do.
#10

[eluser]Sire[/eluser]
What percentage of visitors block cookies? Especially with browsers having built-in privacy and incognito settings? A better solution might be storing the affiliate id along with the visitors ip number, useragent, referer if known, etc... in case a cookie can't be set.




Theme © iAndrew 2016 - Forum software by © MyBB