Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Dynamic Pricing based on user country

General • Asked by Enrique Benitez


I'm thinking of a way to handle dynamic pricing on my web app based on the user country, for example:

A user wants to subscribe for a pro account on my website and this user is based outside the US so that user don't need to pay VAT... So the price for the subscription to my site changes for those users.

How can I handle this more effectively? I was thinking that it's all about the user ip address and then use ruby geocoder.

Thanks! :)

Hey Enrique,

You could definitely geocode their IP in order to get their country. That would probably be the most accurate version of this. Alternatively you could ask the user to fill out their country as part of the sign up process or something in order to record that without doing geocoding. The geocoding approach will look a lot more seamless on the UI side of things though, so I'd probably recommend that route.

Another option I just thought of could be taking the locale from the browser and using that to determine the country: I'm not sure how well this would work as the geocoded IPs would definitely be more accurate.

Yeah I'm going to use the Geocoder gem as well as the built-in ip getter from Devise to accomplish that.

Thanks, Chris!

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,353+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.