Track custom query param?

I attach a custom query param like ?custom=123 to links which point to my site so I can track where visitors came from. The query param only appears for that initial page request of the session, and then my shopping cart records it internally and does not generate URLs which include it. Can Piwik use the same query param that only appears once per session for reporting the source of visitors or orders?

Yes it sounds like Campaign tracking: Tracking Campaigns – Analytics Piwik - Analytics Platform - Matomo