目录

Overview

Your app server can call this API to synchronize custom user attributes to the Analytics Kit for analysis and audience management.

Scenario

If your app server calculates some user attributes instead of obtaining them from the app, and if you want to apply these user attributes to the analysis reports provided by the Analytics Kit (for example, use the user attribute as a filtering condition for viewing reports), you can call this API to synchronize the user attributes from the app server to the Analytics Kit.

Restrictions

Interface Prototype

Protocol

HTTPS POST

Direction

HUAWEI Analytics Kit server -> Developer callback API server

URL

POST https://<URI>/analytics/datacollection/import/user

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

Request

Table1 Request body
ParameterMandatory/OptionalTypeDescription

data_type

Mandatory

Integer

Data type.

1: customized user attribute

userdata_set

Mandatory

UserData[1...100]

List of users and attributes to be imported.

Table2 UserDataSet parameters
ParameterMandatory/OptionalTypeDescription

id

Mandatory

String

User ID, a string of up to 256 characters.

properties

Mandatory

UserProperty[1...25]

List of user attributes.

Table3 UserProperty parameters
ParameterMandatory/OptionalTypeDescription

id

Mandatory

String

User attribute ID, a string of up to 256 characters. The value can consist of digits, letters, and underscores (_) but cannot start with a digit.

[example]

favorite_sport

value

Mandatory

String

User attribute ID, a string of up to 256 characters.

[example]

football

Note:

  1. In each request, UserDataSet can carry information about a maximum of 100 users.

  2. You can report custom user attributes through the mobile SDK or synchronize the attributes from the app server. A maximum of 25 custom user attributes are supported in total. When attributes are synchronized from the app server, the number of attributes that have been reported through the mobile SDK must be considered. The total number of attributes must not exceed the upper limit.

  3. If an attribute is both reported through the mobile SDK and synchronized from the app server, the attribute from the app server is used.

  4. Ensure that user personal data is not treated as custom user attributes for synchronization.

  5. The number of requests per second does not exceed 100.

Response

Table4 Response body
ParameterTypeDescription

result_code

String

Response code. For details, please refer to Result Codes.

result_msg

String

Response description.

Response Example

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Connection:  Close
  4. Content-Length: xxxx
  5. {          
  6.  "result_code":"0",
  7.  "result_msg":"success"
  8. }

Result Codes

Status CodeResult CodeResponse CodeDescriptionSuggestion

200

0

Success

Request succeeded.

-

400

10020

invalidParameter. Parameter : %1, Reason: %2

Invalid parameter.

%1 indicates the parameter name, and %2 indicates the exception cause.

Check and correct the parameter value.

Call Example

  1. POST /analytics/datacollection/import/user HTTP/1.1
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: xxxx
  4. Accept: application/json
  5. Authorization: Bearer 78C2395236BBF4262CAE4F1172E327C2929AD63EAA0395961A49DEBC3B6F8339
  6. x-product-id: sample-productid
  7. x-app-id: sample-appid
  8. {
  9.    "data_type": 1,
  10.    "userdata_set": [
  11.        {
  12.            "id": "123",
  13.            "properties": [
  14.                {
  15.                    "id": "favorite_sport",
  16.                    "value": "football"
  17.                },
  18.                {
  19.                    "id": "vip_users",
  20.                    "value": "true"
  21.                }
  22.            ]
  23.        },
  24.        {
  25.            "id": "456",
  26.            "properties": [
  27.                {
  28.                    "id": "favorite_sport",
  29.                    "value": "basketball"
  30.                },
  31.                {
  32.                    "id": "vip_users",
  33.                    "value": "false"
  34.                }
  35.            ]
  36.        }
  37.    ]
  38. }