1. User Association Introduction

When associating users with simple user association, there are two types of user IDs: device ID (anonymous ID) and login ID. It cannot meet the needs of complex multi-touch user association. For more details, please refer to the User Identification Introduction in the SDK product features section.

2. API Introduction

This section only introduces the API functionality of global user association. For other tracking interfaces, please refer to the Basic API Introduction.

2.1. User Login

When a user successfully registers or logs in, you need to call the SDK's login() method.

sensors.login("登录 ID");
CODE

In order to accurately record the behavior information of logged-in users, it is recommended to call the user login method at the following times:

· When a user registers successfully · When a user logs in successfully · Every time a logged-in user launches the app

2.2. Get User ID

Each event in Sensors Analytics is associated with an ID, which is used to identify the user or device information associated with the event. We call it the distinct_id. Before calling the login() method in the SDK, the value obtained is the default anonymous ID (AndroidId). After calling the login() method, the value obtained is the one passed in the login() method.

You can obtain the distinct_id() by invoking the getDistinctIdPromise method:

//获取当前用户的distinctId sensors.getDistinctIdPromise().then((result) => { var distinctId = result })
CODE
You can also obtain the anonymous ID assigned by the Sensors Analytics SDK by invoking the getAnonymousIdPromise() method:
//获取当前用户的匿名id sensors.getAnonymousIdPromise().then((result) => { var anonymousId = result })
CODE

2.3. Custom Anonymous ID

By default, the SDK generates an anonymous ID and can guarantee the uniqueness of this ID. If you need to replace the default anonymous ID assigned by Sensors Analytics, you can immediately call the identify("custom anonymous ID") method after initializing the SDK to replace it.

//设置自定义匿名 ID,在初始化 SDK 之后立即调用 sensors.identify(“用户自定义匿名 ID ”);
CODE