In UI, provide a form with "Male, Female, Other". If they click other, reveal an optional text field where they can enter what they wish. Store.
Normalize the synonyms of male and female to lower case "male" and "female" when doing analysis. You don't have to get 100% normalisation. But you'll probably get 80-90%.
Contemplate what you are actually using the data for, listen to users.
To be honest, if you manage to not put transgender as a sexual orientation, you'll be doing better than most people.