Tracking User Time Zone and Language

You can record the user’s time zone and language in eSputnik through SDK or through API, if you transfer data from the backend.

📘

Note

Send data about language in RFC 5646 format. A primary language subtag in ISO 639-1 format is required. Example: de-AT

Send data about time zone in TZ database format. Example: Europe/Kyiv

🚧

Important

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

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 >

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.reteno.com/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.reteno.com/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"
}
'