Affiliate tracking is an important aspect of e-commerce. Here's a small JS snippet which will read affiliate codes from the URL and set the corresponding cookie value.