Collecting data selectively is how discrimination starts.
But you are probably right, it's not illegal.