When I created Botletter, I also wanted to proudly display “Made with love in France”. The problem is, as a digital nomad constantly moving from one country to another, it didn’t really make sense to use France as the company’s location.

What if every user sees his home country displayed in the footer? 🤔

Then came up the idea to write a script to display the user’s location for the “Made with love in {{user_country}}” formula.

This could attract the visitors’ attention and increase the conversion rate. The goal is to encourage people to contact me and start a discussion about Botletter. This way, I will know better who are my visitors, how they discovered Botletter and what are their expectations about the product.

The downside is the risk to hurt people and make them feel like I’m fooling them… I discuss the results of the experiment later.

How to implement it with Ruby on Rails

Create such a “hack” in your app is really easy. I will use Rails as an example but I’m sure you can do it with other technologies.

First, we want to use the visitors’ IP address in order to locate them. Geocoder is a complete geocoding solution for Ruby. It will allow us to find the location using the IP address.

Install Geocoder like any other Ruby gem:

gem install geocoder

And run at the command prompt:

bundle install

Geocoder adds location and safe_location methods to the standard Rack::Request object so you can easily look up the location of any HTTP request by IP address.

We want to check the user’s location before rendering the view. Thus, we add a before action in the application controller, creating a variable with the user’s location based on his IP address. This way, the user’s location will be available in all our views.

before_action :loc_function

# We check if geocoder finds the location

if request.location

result = request.location



# If geocoder does not find it, we display 'France'

else



end

end def loc_function# We check if geocoder finds the locationif request.locationresult = request.location @loc = result.country# If geocoder does not find it, we display 'France'else @loc = "France"endend

In the footer, we can now display the location formula with the user’s location:

Made with ❤ in @loc %>

Voilà!