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);
payload.put("DOB", "1990-01-01");
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 method below to set a user’s identity. In case the user’s identity is not available at login, you can also use this method after identity, and after setting identity, all corresponding events 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);Identifying Users for Hashed ID
Use this method if you want the SDK to hash the identity (SHA-256) before it is stored or sent to Smartech. Pass the identity in plain text — the SDK performs the hashing internally, so the plain-text value is never persisted or transmitted.
An optional salt parameter can be supplied for additional security. When a salt is provided, it is prepended to the identity before hashing (hash(salt + identity)). If you pass null, the identity is hashed without a salt.
If you use a salt, the same salt must be used every time for a given identity — a different salt produces a different hash and will be treated as a different user.
Smartech.getInstance(new WeakReference<>(getApplicationContext())).setHashedUserIdentity(identity, salt);Smartech.getInstance(WeakReference(applicationContext)).setHashedUserIdentity(identity, salt)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);
NoteIn 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.
Login Event for Hashed ID
Call this method as soon as the user successfully logs in, passing the plain-text identity and the same salt used with setHashedUserIdentity. The SDK hashes the identity internally before recording the login event.
Smartech.getInstance(new WeakReference<>(getApplicationContext())).loginWithHashedIdentity(identity, salt);Smartech.getInstance(WeakReference(applicationContext)).loginWithHashedIdentity(identity, salt)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 8 days ago
