Serve different site version based on user country

Hey all,

Hoping someone has encountered this circumstance until now. I am using translations to serve different versions of a site based on a user’s country. Some translations are being served on different domains. I am wondering if there is a way to get a user’s location (specifically country code) and then target them to a specific domain (could be either www.domain.ca or www.domain.com/uk for example) on the same Kirby installation.

Thanks :slight_smile:

Basically there are (at least) two ways to determine location:

  • by IP
  • by client information (from browser)

None of this is 100% accurate, what users select in their browsers can basically be anything, and use of VPNs makes IPs unreliable. You probably know this from accessing Netflix etc. on a VPN to spoof your location.

Resources:

If you google this, you will find a lot more resources.

As @texnixe says, this not an exact science and really dififcult to do with 100% accuracy. If you look look at the sites of big international companies, they usually get around this by asking the user. For example, if i look at the US version of the Adobe site, at somepoint a pop up appears that says that something like “We think your in the UK, would you like to see the UK version?”. Thats another approach to consider. You could present the text of that popup in both English and the language of the country you think the user is from.

Atleast put country flag near the appropriate buttons. If they dont understand English, they will understand their own country flags as an image, and click that button.

For example, if I use this service http://geolocation-db.com/documentation, would I route the user to their version of the site based on the country code returned?

For the second option, would there be a way to have a top-level page containing all countries + translations available and the user clicks the one they are in? But can go to a specific countries’ homepage if the user inputs the country-specific URL.

Yes, that would be the same as for your other question with the languages.

Here is a similar approach: https://www.ikea.com/

They recognize the recommended website, but with an option to select something else in the dropdown. The language specific versions can either live on a subdomain or like in the example under domain.com/language-code. Apple does the same.

So say I created http://domain.com/language-code. How would I enable that as the landing page? Would it be possible to set it as the landing page for the global site (domain.com) but not if a user goes through a country-specific domain (domain.ca)?

A language page with a language code in the URL doesn’t really make sense, at least in my opinion. This landing page should be rather “neutral” and make a more or less educated guess regarding the user language (by leveraging IP, browser information etc.), then offer the user to go either to the recommended or the chosen destination (the country specific domain).

When the user lands on the landing page and the language destination cookie is not set yet, they see the selector. As soon as they choose the destination, you set the language destination cookie to the selected language value.

If the user lands on the landing page again and the cookie is set, you automatically redirect them to the destination stored in the cookie, i.e. they won’t see the language selector by go directly to jail, äh, the destination.

Thanks for your help :slight_smile: is there an option in Kirby to set a page to not be translated or set it as a landing page as you described in your example?

Hm, good question.I’m not really sure what would be the best approach.