User Tracking

Follow these steps to build user profile via passing the user attributes & set and manage user identity,

1. Building User Profile

You can pass additional information associated with a user to Smartech as user attributes as shown below.

HashMap<String, Object> payload = new HashMap<>();
payload.put("FIRSTNAME", "Ram");
payload.put("LASTNAME", "Sharma");
payload.put("AGE", 25);

Smartech.getInstance(new WeakReference<>(context)).updateUserProfile(payload);
val payload : HashMap<String, Any> = HashMap()
        payload["FIRST NAME"] = "Ram"
        payload["LAST NAME"] = "Sharma"
        payload["AGE"] = 25
  
Smartech.getInstance(WeakReference(context)).updateUserProfile(payload)
SmartechSDK.updateUserProfile(USER_PROFILE_DETAIL_PAYLOAD);

// Sample code for reference purpose only
const payloadata = {
      NAME: "User Name",
			EMAILID: "[email protected]",
			AGE: "30",
			MOBILE: "4545748"
    };
SmartechSDK.updateUserProfile(payloadata);

📘

Note:

  • Smartech supports following data types - String, Integer, Float, Date, Array, Objects.
  • Date should be sent as yyyy-mm-dd format

2. Identifying users

Use the below method to set a user’s identity. In case the user’s identity is not available at login, you can also use this method after availability of identity and after setting identity all corresponding event will be mapped to this identity.

Smartech.getInstance(new WeakReference<>(context)).setUserIdentity("<USER'S_IDENTITY>");
Smartech.getInstance(WeakReference(context)).setUserIdentity("<USER'S_IDENTITY>")
SmartechSDK.setUserIdentity(USERS_IDENTITY);

3. Get User's Identity

You can use the following method to get the identity of a user.

String identity = smartech.getUserIdentity();
val identity = smartech.getUserIdentity()

4. Login Event

Call Smartech login method as soon as user successfully login into the app and also set user’s identity before calling the login method of SDK.

Smartech.getInstance(new WeakReference<>(context)).login("<USER'S_IDENTITY>");
Smartech.getInstance(WeakReference(context)).login("<USER'S_IDENTITY>")
SmartechSDK.login(USERS_IDENTITY);

📘

Note

In addition to calling this method after a successful login and sign-up, it is recommended to call login() method where the app finds the user is already logged in and navigates the user to the homepage.

5. Clear Identity

This will clear the user’s identity and after this, all activity will be tracked as anonymous.

Smartech.getInstance(new WeakReference<>(context)).clearUserIdentity();
Smartech.getInstance(WeakReference(context)).clearUserIdentity()
SmartechSDK.clearUserIdentity();

6. Logout Event

Call the Smartech logout method after the user log-out from the application. If you want to clear the user identity pass true in the parameter. When you logout the user with identity clear, you won't be receiving any personalised push notifications.

Smartech.getInstance(new WeakReference<>(context)).logoutAndClearUserIdentity(booleanClearIdentity);
Smartech.getInstance(WeakReference(context)).logoutAndClearUserIdentity(booleanClearIdentity)
//SmartechSDK.logoutAndClearUserIdentity(isLougoutClearIdentity)

// Sample code for reference purpose only
SmartechSDK.logoutAndClearUserIdentity(1);

Next

You can go back to setup other features or choose one of them from the left panel!