I did this a while ago and realized that my notes could help someone find this:
Create referral URLs
Whenever you send a referral address to your user, store it in a table. In my case, I had URLs for different purposes (“invite your friends”, “share this item”, etc.). Therefore, I also kept the type of referral. Add an entry point to your site, such as http://example.com/ref/jklejis , to handle the incoming URL. If you don’t like having an obvious “referral” URL, you can use middleware to simply grab the special url parameter on any URL to your website and handle it that way, i.e. http://example.com/items/123?r=jklejis
Tracked visitor
As soon as a visitor visits me from a referral, I set a cookie and any further requests from this user are tracked by a piece of middleware that tracks the actions in the table. Then I run a task to analyze the “action” table to issue loans to users. I didn’t have any requirements in real time here, but if you do, use a signal for specific actions to start your code.
I recently ran into this project, which seems to be still alpha, but it does something similar and can get started: http://pinax-referrals.readthedocs.org/en/latest/
avv
source share