This is a very broad question. Note that the regulation in UE (mainly GDPR) is quite different than that found in USA, itself different than that on many other countries on the American continent.
That said, when talking about privacy, we generally refer to Personally Identifying Information (PII). As such, your conversion of an IP address like 126.96.36.199 to a country, and storing only that, would generally anonymize the personal information (the IP address), what the GDPR calls pseudonymisation.
Do note that this depends on the rest of information you store and the size of the population in which that user gets mixed. Knowing that someone from the US visited your site little information, even if you additionally his first name. However, that same information for a visitor from Vatican City could identify a single individual.
Additionally, even if you weren't allowed to store X a priori, take into account that you can word your website terms for that, so your processing of the information is based on user consent. A line on the terms for posting on your site should be able to clear that up if needed.
Finally, as for the point that Hagen von Eitzen raises about the potential problems of sending the IP addresses to a geolocation service in order to know the country, while you can 'do the paperwork' to handle that properly, I would recommend to simply use an offline database to convert them locally, thus removing that part completely.