views:

33

answers:

1

Hello,

In my future website, i'll have parteners and i want them to receive a certain percentage of money according to how much the visitors they sent me bought items.

So this is a simple question :

How to know where the visitor comes from when he decide to purchase a thing on my website so i give the correct amount to the partener who reffered the member ?

(i use the php Symfony framework, i guess it has nothing to do with, but anyhow... ;D )

Thanks

+2  A: 

Typically, this involves giving each partner some kind of unique ID, and then having them include that ID as a variable in the initial page they link to on your site. You then keep track of this ID in a session (either PHP's built-in sessions, or a cookie), and associate it with any purchases made. You can then go aggregate purchases by the associated partner ID to know who to give a cut.

For instance, a partner might link to your site like this:

http://www.your-example-site.com/some-product-page?referrer=QK117A4

where QK117A4 is their unique ID.

Amber
and after in my header :if ($_GET['referrer']) {setcookie.......}and in the page where the user are about to pay if isset cookie(referrer)$sql = update sells set parteners = parteners+1 where idParteners=...That code is just awefull it's just for you to validate the logical part. Is that right ?
Tristan
That's one way to do it - but I'd highly suggest instead of just incrementing a value in a table, mark each *order* record with the partner id, and then when you need the counts, run a query like `SELECT COUNT(partnerid) FROM orders GROUP BY partnerid`. That way, you keep a record of the actual sales that each partnerid generated - it's a lot easier to go back and verify that the numbers are correct later if something seems fishy.
Amber