How to track multiple campaigns in a single visit

I am using campaign for simple affiliate link tracking. The problem is that affiliate id is attached to a product e.g. Affiliate_id = 1, product_id = 100 is one visit, Affiliate_id = 2, product_id = 200 is another visit. I do not want affiliate_id 2 to overwrite affiliate_id 1. I want to capture both of them for these products.

What is the right way to do this kind of affiliate tracking.

Here is the scenario. I have multiple products on the website, and many affiliates who send traffic to the website. E.g.

Currently if users comes to the website using campaign_id = affiliate1, all the subsequent visits are attributed to affiliate1, even if another product page is visited through some other affiliate. It seems that there should be an easy way to have this data. Any help is appreciated.

So, if you visit after 30 min using another referer link, the campaign should be set to the most recent referrer by default.

however in the SAME visit if you visit another referral link, then the campaign would still stay to the original campaign used. This is by design.

See also: Piwik attributes conversions to the last seen referrer by default. How do I credit conversions to the first referrer instead?