In affiliate mode, you can enable the option to add a different button URL to each product. You can achieve it in Catalog Settings > Affiliate Button:
Once you check the Unique URL for each Product checkbox, you will see a new box on each product edit screen:
The default value for the Button URL can be defined in the settings.