These docs are for v1.0. Click to read the latest docs for v2.0.

Tracking User

Smartech SDK enables developers to identify a user and create a profile for the user with all its attributes. Assigning a unique user identity helps collect the user's activity and information across systems in a single unified view.
Unique user identity must be your primary key to identify users in your database.

We recommend not to use any user identity that can change over time.

Normally you can set the user identity in the following flow of your app:

  • On user sign-in/login success.
  • On user sign-up/register success.
  • On screen or page where user identity becomes known.
  • When the user context changes (apps with multiple accounts).

User Profile

You can pass additional information associated with a user to Smartech as user attributes. These attributes can be used to segment users and target campaigns to a specific group. Attributes can also be used to personalize the campaigns for each user.

HashMap<String, Object> payload = new HashMap<>();
payload.put("FIRST NAME", "Ram");
payload.put("LAST NAME", "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)

📘

NOTE:

  • Smartech supports following data types - String, Integer, Float, Date, Array, Objects.
  • Bool/Boolean data type in the payload is NOT supported by Smartech.
  • Date should be sent as yyyy-mm-dd format

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>")

Login Event

Call Smartech login method as soon as user succusfully 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>")

📘

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.

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()

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)