/affiliation

A Ruby on Rails affiliate tracking system

Primary LanguageRubyMIT LicenseMIT

Required Gems
=============
Rspec
	gem install rspec

Packet
	gem install packet

Friendly
	gem install friendly

Setup
=====

1. Copy the config/database.example and config/friendly.example and modify
 to suit your needs

2. Generate the authentication key
	rake auth:gen:site_key

3. Create databases, Friendly tables, and seed database
	rake db:create:all
	rake db:migrate RAILS_ENV=production
	rake db:seed RAILS_ENV=production

Usage
=====

After affiliates sign up or are created in the admin, they can be assigned codes to link to your site's pages. This will require some modification of your storefront's code, but only enought to track the current affiliate code through the session.

An example usage for affiliate 'marty123' with a trackback code 'mar' would be as follows:
 
1. marty123 links to your store with his affiliate code
	http://widgetsrus.co.uk/index.html?affiliate=mar

2. Your site drops in a tag on the linked page (or use curl, or any method to perform an HTTP GET) passing the trackback data to the affiliate application
	(on http://widgetsrus.co.uk/index.html) <img src="http://affiliates.widgetsrus.co.uk/track/mar" height="1" width="1" alt=""/>

3. Place a similar tag or otherwise GET the affiliate application through the user's visit on any pages you want trackbacks recorded on. Any additional metrics you want recorded can be included in JSON format as such:
	http://affiliates.widgetsrus.co.uk/track/mar/{'search_terms':'purple widget', 'other_key':'other_value'}

4. In the event the user purchases something in your store, the tag on the order completion page is a bit different:
	http://affiliates.widgetsrus.co.uk/track/mar/{order_number}/{order_amount}
	-- e.g. --
	http://affiliates.widgetsrus.co.uk/track/mar/234494/23.45

Available tracking routes:
track/{trackback_code}/{order_number}/{order_amount} //-> +Trackback, +PageView, +PayableAction
track/{trackback_code}/{extra_data} //-> +Trackback, +PageView
track/{trackback_code} //-> +Trackback, +PageView