Our site has a homegrown affiliate program. I set a 30-day cookie when they land on the site from the clickthru. The value of the cookie identifies the affiliate they came from; for a PPC ad campaign it would identify which campaign they came from.
Later when they order something from the site, we simply check if that cookie (still) exists. If it does, I write a row to a "clickthrus" table in the DB, and then a sales reporting page later queries that table for building its statistics on demand.
Google released multi-channel funnels last month. It will track all of these various channels.