How does Zendesk capture the location of the end-user?
The user's location is based on the IP address of the user, captured the moment of the ticket creation. There will be some cases where there's a firewall or a proxy used by the end-user, which could prevent this information from being accurate.
It is not possible to capture the end-user's location or set up the location manually in tickets created via the API. The location displayed in these tickets is the one of the server of the script making a call to the API.