Tracking Links With IDs

I’m trying to figure out if it’s possible to automatically generate unique links with id for affiliate links. Basically, we have ‘Site-A’ which is an affiliate network and ‘Site-B’ a private network which gets links from affiliate networks and offers it to members to promote on their sites. Is it possible to setup an automatic system which generates unique link with an ID to track which of the members made a sale? Below I have included a diagram of the process.