Language/Locale
The locale
object provides access to the visitor's language and geographic region as configured in the browser. For instance, if languageCode is set to 'en' and countryCode is 'GB', the visitor speaks British English.
Technically, the values are retrieved from the "Accept-Language" request header that the browser sends to the server. The browser uses this header to indicate to the server which language/locale the visitor most likely understands. An "Accept-Language" header value for a German speaking visitor from Switzerland might look like this:
"de-ch,de;q=0.8,en;q=0.5"
This translates to "I prefer Swiss German, but will accept other types of German and also English," and causes the visitor.js script to return 'de' (for German) as the default language code and 'CH' (for Switzerland) as the country code.
visitor.locale.languageCode
- Gets the two-letter ISO-639-1 code of the default language set on the visitor's browser.
- Data Type: String
- Default Value: '' (if the browser's language can not be determined)
- Example Values: 'en' for English, 'es' for Spanish
visitor.locale.countryCode
- Gets the two-letter ISO-3166 country code for the default language locale set on the visitor's browser.
- Data Type: String
- Default Value: '' (if no language localization could be determined)
- Example Values: 'GB' for United Kingdom, 'FR' for France