1. User Association Introduction

When using a simple user association to identify users, there are two types of user ID values: one is the device ID (anonymous ID), and the other is the login ID. It cannot meet the complex multi-touch user association. For more detailed information, please refer to the User Identification Introduction in the SDK product functions section.

2. API Introduction

This section only introduces the API functions of all-domain user association, for other tracking interfaces, please refer to the Basic API Function Introduction.

2.1. User Login

When a user registers successfully or logs in, you need to call the user login interface of the SDK:

SDK version >= 4.3.0, call this method when the user logs in. The first parameter is obtained from the detailed preset ID key list, and the second parameter is the specific user ID.

After calling the interface, the key and value will be cached locally, and the ID information will be included in subsequent collected events.

iOS SDK

 [[SensorsAnalyticsSDK sharedInstance] loginWithKey:@"key" loginId:@"value"];
CPP

Call this method in the case of multiple user ID associations. The first parameter is obtained from the detailed preset ID key list, and the second parameter is the associated user ID.

After calling the interface, the key and value will be cached locally, and the ID information will be included in subsequent collected events.

iOS SDK

[[SensorsAnalyticsSDK sharedInstance] bind:@"$identity_mobile" value:@"187****8991"];
CPP

Call this method to cancel the association of multiple user IDs. The first parameter is the key to cancel the association, and the second parameter is the user ID to cancel the association.

After calling the interface, the corresponding unbinding events will be sent, and the key-value in the local cache of the ID information will be cleared (if it exists).

iOS SDK

[[SensorsAnalyticsSDK sharedInstance] unbind:@"$identity_mobile" value:@"187****8991"];
CPP

SDK version >= 4.3.0, call this method when the user logs in. The first parameter is obtained from the detailed preset ID key list, and the second parameter is the specific user ID.

After calling the interface, the key and value will be cached locally, and the ID information will be included in subsequent collected events.

iOS SDK

SensorsAnalyticsSDK.sharedInstance()?.login(withKey:"key",loginId:"value");
CPP

When calling in multiple user ID associations, the first parameter is obtained from the detailed preset ID key list, and the second parameter is the corresponding associated user ID.

After calling the interface, the corresponding key and value will be cached locally, and the collected events thereafter will include the cached ID information.

iOS SDK

SensorsAnalyticsSDK.sharedInstance()?.bind("$identity_mobile",value:"187****8991");
CPP

When calling in multiple user ID disassociations, the first parameter is the disassociated key, and the second parameter is the corresponding disassociated user ID.

After calling the interface, relevant unbinding events will be sent, and the corresponding key-value will be cleared from the local cached ID information if it exists.

iOS SDK

SensorsAnalyticsSDK.sharedInstance()?.unbind("$identity_mobile",value:"187****8991");
CPP

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

· When the user registers successfully · When the user logs in successfully · Every time the logged in user starts the app

2.2. Multiple User ID Association

Used when associating multiple user IDs, the first parameter is obtained from the detailed preset ID key list, and the second parameter is the corresponding associated user ID.

After calling the interface, the corresponding key and value will be cached locally, and the collected events thereafter will include the cached ID information.

[[SensorsAnalyticsSDK sharedInstance] bind:@"$identity_mobile" value:@"187****8991"];
JAVA

2.3. Multiple User ID Disassociation

Used when disassociating multiple user IDs, the first parameter is the disassociated key, and the second parameter is the corresponding disassociated user ID.

After calling the interface, relevant unbinding events will be sent, and the corresponding key-value will be cleared from the local cached ID information if it exists.

[[SensorsAnalyticsSDK sharedInstance] unbind:@"$identity_mobile" value:@"187****8991"];
JAVA

2.4. Reset Anonymous ID

Used to reset the anonymous ID, it can generate a new anonymous ID or pass in a specified anonymous ID.

Note: It can only be used in an anonymous state (i.e. after logout or before login), otherwise the call is invalid.

The difference between this method and identify is that in addition to modifying the distinct_id in IDM 2.0, it also modifies the values of $identity_idfv or $identity_ios_uuid in IDM 3.0 identities.

// 重置匿名 ID [[SensorsAnalyticsSDK sharedInstance] resetAnonymousIdentity:nil]; // 修改为指定的匿名 ID [[SensorsAnalyticsSDK sharedInstance] resetAnonymousIdentity:@"id-xxxxxxx-xxxxx"];
CODE

2.5. Get User ID

SDK version needs to be >=4.3.0

Get the ID of the globally linked user

// 获取事件的 ID NSDictionary *SDKProperties = [[SensorsAnalyticsSDK sharedInstance] identities]; // 可以获取数据体中的 identities 对象:SDKProperties.identities
CODE

SDK version needs to be >=4.3.0

Get the ID of the globally linked user

// 获取事件的 ID NSDictionary *SDKProperties = SensorsAnalyticsSDK.sharedInstance?.identities; // 可以获取数据体中的 identities 对象:SDKProperties.identities
CODE