Tracking User Time Zone and Language

You can record the contact's time zone and language in two ways:

  • via API.
  • using the SDK (when transferring data from the frontend of the mobile application).

Send the language in RFC 5646 format, with a primary language subtag in ISO 639-1 — for example, de-AT. Send the time zone in TZ database format — for example, Europe/Kyiv.

❗️

Important

You can track user attributes (language, time zone etc.) only for users with external user IDs.

How the Contact Language Is Filled

  • When a contact is created via the Mobile SDK, the language is written from the device language.
  • If the device later migrates to another contact (for example, a different user logs in to the app), the language is not transferred — the previously saved value remains. Update it explicitly with the user attributes update method described below.
  • A language set explicitly — with the SDK's user attributes update method or through the API — takes priority over the one captured automatically from the device.
  • When a contact is created by a Web Push subscription, the language is taken from the browser localization passed in the subscription event. A multilingual message then reaches the contact in that language, so subscribers from different language versions of a site don't need separate segments.
  • When a contact is created or updated via the API, the language is filled only if it is passed explicitly in the request.

In the contact card, the most common language codes are displayed as localized language names. Non-standard values (for example, regional codes) are displayed exactly as they were passed. The card always shows the value from the last update.

API Methods

Use Add/update a contact API method to add a new or update an existing user and Add/update contacts for bulk adding/updating your users’ data.

Add/update a contact request example

curl --request POST \
     --url https://api.yespo.io/api/v1/contact \
     --header 'accept: application/json; charset=UTF-8' \
     --header 'authorization: Basic 
your_api_key 
\
     --header 'content-type: application/json' \
     --data '
{
     "channels": [
          {
               "type": "email",
               "value": "[email protected]"
          }
     ],
     "languageCode": "en-us",
     "timeZone": "Europe/Kyiv",
     "firstName": "John",
     "lastName": "Smith",
     "externalCustomerId": "24233"
}
'

Add/update contacts request example

curl --request POST \
     --url https://api.yespo.io/api/v1/contacts \
     --header 'accept: application/json; charset=UTF-8' \
     --header 'authorization: Basic 
your_api_key
 \
     --header 'content-type: application/json' \
     --data '
{
     "contacts": [
          {
               "channels": [
                    {
                         "type": "email",
                         "value": "[email protected]"
                    }
               ],
               "firstName": "John",
               "lastName": " Smith",
               "languageCode": "en-US",
               "timeZone": "Europe/Kyiv",
               "externalCustomerId": "543323"
          }
     ],
     "dedupeOn": "externalCustomerId"
}
'

iOS SDK

Add user attributes like time zone and language by the following method:

Reteno.updateUserAttributes(externalUserId: "USER_ID", userAttributes: UserAttributes, subscriptionKeys: [String], groupNamesInclude: [String], groupNamesExclude: [String])

The UserAttributes object example:

func saveUser() {
    let attributes = UserAttributes(
        phone: user.phone,
        email: user.email,
        firstName: user.firstName,
        lastName: user.lastName,
        languageCode: "en-US",
        timeZone: "Europe/Kyiv"
    )
    Reteno.updateUserAttributes(externalUserId: user.id, userAttributes: attributes)
}

Details >

Android SDK

Methods for adding user attributes:

Reteno.setUserAttributes(String externalUserId, User user)

Reteno.setUserAttributes(externalUserId: String, user: User?)

The userAttributes object example:

fun setLanguageTimeZone() {
        val userId = "UserIdHere"
        val userAttributes = UserAttributes(
            languageCode = "en-US",
            timeZone = "Europe/Kyiv"
        )
        val user = User(
            userAttributes = userAttributes,
            subscriptionKeys = listOf("key1", "key2", "key3")
        )
        application.getRetenoInstance().setUserAttributes(userId, user)
    }

Details >

React Native SDK

Method for adding user attributes:

import { setUserAttributes } from 'reteno-react-native-sdk';

setUserAttributes({
    externalUserId: "USER_ID",
    user: {
        attributes: userAttributes,
        subscriptionKeys: string[],
        groupNamesInclude: string[],
        groupNamesExclude: string[]
    }
})

The userAttributes object example:

setUserAttributes({
  externalUserId,
  user: {
    userAttributes: {
      languageCode: "de-AT",
      timeZone: "Europe/Kyiv",
    },
  },
);

Details >

Getting the Contact Language in the Workflow Context

The $languageCode system field allows you to get the language from the contact card in the worklflow context, so as not to pass it in each event.

The $languageCode field can be used in typical blocks that work with variables and conditions, for example:

  • Webhook
  • Branch
  • Check value
`$languageCode`


Did this page help you?