ASA,
Best to explain with an example.
I have an affiliate link to a product on Amazon.
I get paid a commission if someone uses my link and buys the product.
I also get paid a commission if they use my link and buy something else - which could be Haraam.
I think this would not happen very often.
I’m not sure, but I believe I can find out which products the user bought and maybe able to work out what was Halal or Haraam.
Please let me know if this is permissible.
Jazakallah.