1. User Association Introduction

When simple user association identifies users, there are two types of user ID values: one is device ID (anonymous ID), and the other is login ID. It cannot meet the requirements of complex multi-touchpoint user association. For details, please refer to the detailed introduction of user identification in the SDK product functions section User Identification Introduction.

2. API Introduction

This section only introduces the API functions of universal user association. For other tracking interface, please refer to the Basic API Introduction.

2.1. User Login

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

var sensorsApiCloudSdk = api.require('sensorsAnalyticsAPICloudSDK'); sensorsApiCloudSdk.login({ loginId: '123456', properties:{ age:18, name:'sensors' } });
CODE

In order to accurately record the user's behavior information after logging in, it is recommended to call the user login method at the following moments:

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

2.2. Get User ID

In Sensors Analytics, each event is associated with an ID to identify the user or device information corresponding to the event. We call it distinct_id. Before the login() method is called 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 get the distinct_id() by using the method:

var sensorsApiCloudSdk = api.require('sensorsAnalyticsAPICloudSDK'); var distinctId = sensorsApiCloudSdk.getDistinctId();
CODE
You can also get the anonymous ID assigned by the Sensors Analytics SDK by using the getAnonymousId() method:
var sensorsApiCloudSdk = api.require('sensorsAnalyticsAPICloudSDK'); var anonymousId = sensorsApiCloudSdk.getAnonymousId();
CODE

2.3. Customize Anonymous ID

By default, the SDK generates an anonymous ID and can guarantee the uniqueness of the ID. If you need to replace the anonymous ID assigned by the default, you can call it immediately after initializing the SDKidentify(“User-defined anonymous ID ”) method to replace.

var sensorsApiCloudSdk = api.require('sensorsAnalyticsAPICloudSDK'); var distinctId = sensorsApiCloudSdk.identify({anonymousId:"anonymousId"});
CODE