User Tracking
Enabling Encryption for Events
To enable encryption for event payloads stored locally on the device, include the following code in the Android manifest under the <application> tag.
<application>
.......
<meta-data
android:name="SMT_USE_ENCRYPTION"
android:value="true" />
.......
</application>
After setting up encryption, build the user profile by passing user attributes and managing 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("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)
SmartechSDK.updateUserProfile(USER_PROFILE_DETIAL_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. Refer to the given table to know the Supported Data Types.
- 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. 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.
4. 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();
5. 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);
Supported Data Type
Here are the supported data types available for attributes.
| Data Type | Applicable | Maximum Length Allowed | Allowed Special Characters | Sample Value |
|---|---|---|---|---|
| Text line |
| 255 | All special characters are allowed. | Netcore Cloud |
| Date |
| No limit. Ensure to follow the format: DD-MM-YYYY or YYYY-MM-DD | Except for dash(-), no other special format is allowed. | 23-01-2013, 2012-01-23 |
| Decimal |
| It can support 18 digit before the decimal point and eight digit after decimal point. | Only dot(.) is allowed. | 1111111111111111111.99999999 |
| Integer |
| 11 | Not allowed | 123 |
| No limit | At-the-rate(@) and dash(-) are only allowed. | [email protected] | ||
| Mobile | 16 | Not allowed | 919999999999 You can also pass your country code | |
| URL | 255 | All are allowed | https://cedocs.netcorecloud.com | |
| Long Text | 5000 characters | All are allowed | Note: Similar to Text line, but can not be used for paragraphs or other text forms. 5k character limit. This is not allowed in Segments and Journeys. |
Updated 14 days ago
