I am creating a basic and small program in php like cj and linkshare. its not that big and complicated. But I need to know about the logic how it actually gets to know if the sale is completed or not on advertiser's website once the affiliate's url is clicked? Appreciate the suggestions and advices. thanks
Each lead would need a unique identifier which is then tracked throughout the process, if the sale is made, flag the lead as having generated a sale.
I think if your programming skills were on par to do such a thing the logic should come natural. Utilizing cookies and tracking id's in the query string should of been the first and only thing that popped in to your head. Somehow, I just don't think you will ever finish this project if you have to ask such an elementary question.
in here not anyone explain all code because its not small code its many function involve in this code.
first you create a code of geolocation (this use of database or maxmind)because of geolocation tell you where country ip buy affiliate. you create advertiser code . its help you which advertiser buy affiliate .also use with database it get advert id , urlid , click , earn , date and use JavaScript or php code like siteurl.php?advertid-25&urlid=65
You don't need to use Geolocation for affiliate tracking. That has nothing to do with it. - Generate a random id for the affiliate. This is there tracking id. Obviously store this id in your database associated with your affiliate. (For Example: 12345) - The tracking id will be in the query string of the URL your affiliate will be using. Let's assign it a variable name of "a" for sake of transparency. (Example URL: blah.etc/product?id=5&a=12345) - When a visitor accesses the web site through blah.etc/product?id=5&a=12345 you will have your script either append the tracking id (12345) to each internal link OR you can easily store the id as a cookie. - When the visitor makes a purchase fetch the tracking id from the cookie or query string and give credit to the affiliate. A GOOD affiliate program WILL store tracking id's in a cookie that expires no less than 14 days. If the visitor lands on the site and doesn't purchase that day your affiliate can still get credit for a purchase made within the allotted time. An AWESOME affiliate program WILL save the tracking id fetched from the cookie to a server side database once an account has been created. The affiliate will get credit for the sale at any point since they were the original referral. This is actually extremely simple to implement with basic code.
First create a new database table 'tbl_conversions' containing the following columns: ID (int, unique, auto increment) Sale (varchar, unique) Code (varchar, unique) On your affiliate script (script that affiliates get that redirects to a product) Set a cookie 'sale' with a random unique string Insert row in your tbl_conversions table where 'sale' = $_COOKIE['var'] Redirect to affiliate site with Sale value in a GET var What you want to do next is have the merchant site include a javascript that makes a call to your callback script that verifies a successful sale. You can do this by generating a value for 'code' (like 'merchant id + sale id'). On a successful sale the merchant's code has a javascript that calls yourwebsite.com/sale.php?sale=123&code=10123 Then on sale.php: If sale & code from your database match with the GET variables from the javascript call, remove the row from database and add it to the successful conversions database! This is the basic logic behind having 2 websites talk to each other and verify stuff like conversions.