user2028856 user2028856 - 5 months ago 24
PHP Question

How to track users cross domain for a purchase

I'm creating a kind of affiliate marketing website with products I've scraped from partner websites. The user clicks on the Buy link and is re-directed to the partner site to complete the purchase. If the user buys the product, I should get a percentage of the sales. So far this model is a pretty common approach.

However the element that I don't yet understand is, what technology or script do other affiliate sites use to track to see if the user, once they've let the main site, does purchase the product or not? How do I track my user's purchase or actions once they've left my site?

I know that cookies can store brief user information but I don't think that's enough. I need to then store this information in a database. Should I use php sessions for this?

Any tips or suggestions is really appreciated.
Cheers

Answer

What technology or script do other affiliate sites use to track to see if the user, once they've let the main site, does purchase the product or not?

Javascript. Affiliate Softwares usually have click tracking code which is placed on the landing pages. Once a vsitor comes to landing page through an affiliate website, a random visitor id along with affiliate id mapping is created which gets stored in the database. At this same time, a cookie gets created with the visitor id, affiliate id info etc. When the user finishes a purchase, there is a sales tracking code javascript code which is placed on the purchase page that gets trigerred. You can use create this code and insert the visitor's id along with affiliate id in the database.

How do I track my user's purchase or actions once they've left my site?

I have answered this partly in the above question. But once the user comes back again, it is going to recognise this user based on cookie and preferably you can store the session value in the cookie itself rather than the database, because the sale entry will get created in the database once the user has completed his purchase, if you have placed your sale tracking code at the end of purchase page.