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.

NSDictionary *profilePushDictionary = @{@"NAME":@"Netcore Solutions",@"EMAIL":@"[email protected]", @"AGE":@"21", @"MOBILE":@"9898989898"};
[[Smartech sharedInstance] updateUserProfile:profilePushDictionary];
let profilePushDictionary = ["NAME": "Netcore Solutions","EMAIL": "[email protected]", "AGE": "21", "MOBILE":"9898989898"]
Smartech.sharedInstance().updateUserProfile(profilePushDictionary)
SmartechSDK.updateUserProfile(USER_PROFILE_DETIAL_PAYLOAD);

// Sample code for reference purpose only
const payloadata = {
      NAME: "User Name",
			EMAIL: "[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 the time of login, you can also use this method after the availability of identity. Once you set this identity, all corresponding events will be mapped to this identified user. The following method is used to set the Identity of the user. Please note that the Identity should be the primary key which is set in the panel.

[[Smartech sharedInstance] setUserIdentity:@"IDENTITY"];
Smartech.sharedInstance().setUserIdentity("IDENTITY")
SmartechSDK.setUserIdentity(USERS_IDENTITY);

3. Get User's Identity

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

[[Smartech sharedInstance] getUserIdentity];
Smartech.sharedInstance().getUserIdentity()
SmartechSDK.getUserIdentity();

4. Login event

To track the login of a user via Smartech, ensure you call the Netcore CE SDK's login method as soon as the user logs in to the application. The following method is used for login.

[[Smartech sharedInstance] login:@"IDENTITY"];
Smartech.sharedInstance().login("IDENTITY")
SmartechSDK.login(USERS_IDENTITY);

5. Clear Identity

To clear the user's identity you need to explicitly call the clearUserIdentity method. This method clears the identity and further all the events carried out after this call will be treated as Anonymous user's activity.

[[Smartech sharedInstance] clearUserIdentity];
Smartech.sharedInstance().clearUserIdentity()
SmartechSDK.clearUserIdentity();

6. Logout event

To track the logout activity of the user via Smartech, ensure you call the logout method named logoutAndClearUserIdentity on successfully logging out the user. If you want to track the user even after logout event then pass the value as no NO/false or else pass the value as YES/true.
YES/true = The identity of the user will be cleared from the SDK and all the activities done henceforth will not have any identity (Anonymous user).

[[Smartech sharedInstance] logoutAndClearUserIdentity:YES];
Smartech.sharedInstance().logoutAndClearUserIdentity(true)
//SmartechSDK.logoutAndClearUserIdentity(isLougoutClearIdentity)

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

NO/false = The identity of the user will be maintained by the SDK and all the activities done by the user will be tracked.

[[Smartech sharedInstance] logoutAndClearUserIdentity:NO];
Smartech.sharedInstance().logoutAndClearUserIdentity(false)