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:

  1. On user sign-in/login success.
  2. On user sign-up/register success.
  3. On the screen or page where user identity becomes known.
  4. 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 send more personalized campaign messages to each user. You can use this method while Sign Up or wherever the user updates the details for its profile.

📘

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

You can use the following code to push the user's profile data.

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

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.

📘

Note:

The Identity should be the primary key which is set in the panel.

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

Get Users Identity

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

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

Login event

To track the login of the user via Smartech, ensure you call the Smartech 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")

Clear Identity

To clear the user's identity you need to explicitly call 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()

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)

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)