Logbook.
Simple Referral Tracking Nov. 9 at 7:52 am
I recently had need for a simple referral tracking mechanism in a Rails application, what we used to refer to as promo codes at AOL. Here’s the method I chose for implementation.
In my application controller I’m capturing any ‘referral’ variable in the url as a session variable of the same name.
before_filter :capture_referal
private
def capture_referal
session[:referral] = params[:referral] if params[:referral]
end
This just writes a session variable called referral with the value passed in the url. Later, during checkout/registration I’m capturing the session variable as part of the order.
@order.referral_code = session[:referral]
@order.save
Lots of ways to make this fancier, but I love the simplicity of it. Referral codes can be generated for any affiliate by any of the sales and marketing staff, and there’s no need to set them up in advance. Regular order reports will show the code and allow searching for a specific code.
Recent Entries
- Tide data for Canada Apr. 26 at 10:41 am
- Ruby HTML Indentation Jun. 27 at 9:47 am
- SSH Keys May. 28 at 5:01 am
- More logbook entries