One of the common needs of a contribution or event registration system is to track what campaign that transaction is destined from and what link originated the transaction. This allows organizations to calculate what links / web sites / advertising / mailings are most effective and use that information to influence their current or future campaigns. Some organizations (e.g. wikimedia foundation) use a three level tracking scheme: Campaign, Appeal and Fund, while other organizations might choose to use only one tracking field.
This issue came up at the San Francisco developer camp. There is no built-in support for this in CiviContribute or CiviEvent. However we can accomplish something very similar using a combination of custom fields, populating fields via a GET url and a civicrm buildForm hook. We've made some changes to v2.2.4 to make it easier. Here is the recipe for tracking either a contribution or event registration page.