User profiling for Cocoa apps

User profiling allows you to understand your app users' preferences and behaviors. By integrating Apptics, you can easily track user sign-ups, log-ins, and more while respecting their privacy preferences. This guide will walk you through the steps to set up user tracking and handle privacy consent.

User properties

User properties enable you to attach custom metadata attributes to individual users, such as subscription status, preferences, or demographics. These properties help segment users for targeted analysis and personalized experiences, providing valuable context for understanding how different user cohorts interact with your app.

Property categories

  • Custom properties - These are the properties that are app specific and defined by you.
  • Predefined properties - These are the properties provided by Apptics to capture basic user details.

List of predefined propeties

APUserPropertyFirstName
APUserPropertyLastName
APUserPropertyEmailAddress
APUserPropertyContactNumber
APUserPropertyDOB
APUserPropertyGender
APUserPropertyCountry
APUserPropertyRegion
APUserPropertyCity
APUserPropertyGeoLocation
APUserPropertyTimezone
APUserPropertyCompanyName
APUserPropertyPlanType
APUserPropertyEngagementScore
APUserPropertyLanguage

Data types

User properties support the below mentioned data types:

  • String - Text values (e.g, "premium", "mobile")
  • Number - Numeric values (e.g, 25, 10, 15)
  • Boolean - True/false values (e.g, true, false)

Limits

  • Custom properties: Upto 30 unique custom properties per project.
  • Predefined properties: 15 standard properties provided by default per project.
  • Key length: Maximum 50 characters per property key.
  • Value length: Maximum 250 characters per property value.

Class definition

@interface APUser : NSOject

Properties

PropertyTypeDescription
userIdNSString*Required. This is the unique identifier for the user
customerGroupIdNSString*(nullable)Optional identifier for grouping users.

Examples

Create a new user object

CopiedAPUser *user = [[APUser alloc] initWithUserId:@"user123" 
                               customerGroupId:@"20a78bc6"];
Copiedlet user = APUser(userId: "user123", customerGroupId: "20a78bc6")

Adding defined properties

Copied// String properties
[user addStringProperty:APUserPropertyFirstName value:@"John"];
[user addStringProperty:APUserPropertyLastName value:@"Zylker"];
[user addStringProperty:APUserPropertyEmailAddress value:@"john@zylker.com"];
[user addStringProperty:APUserPropertyCompanyName value:@"Zylker Corp"];

// Numeric properties
[user addIntegerProperty:APUserPropertyEngagementScore value:85];
Copied// String properties
user.addStringProperty(APUserPropertyFirstName, value: "John")
user.addStringProperty(APUserPropertyLastName, value: "Zylker")
user.addStringProperty(APUserPropertyEmailAddress, value: "john@zylker.com")

// Numeric properties
user.addIntegerProperty(APUserPropertyEngagementScore, value: 85)

Adding custom properties

Copied[user addStringProperty:@"department" value:@"Engineering"];
[user addBooleanProperty:@"beta_tester" value:YES];
[user addDoubleProperty:@"account_balance" value:1250.75];
[user addFloatProperty:@"subscription_price" value:29.99f];
[user addLongProperty:@"user_id_numeric" value:123456789L];
Copied// String properties
user.addStringProperty("department", value: "Engineering")
user.addBooleanProperty("beta_tester", value: true)
user.addDoubleProperty("account_balance", value: 1250.75)
user.addFloatProperty("subscription_price", value: 29.99)
user.addLongProperty("user_id_numeric", value: 123456789)

Set user object (mandatory)

Copied[Apptics setUser: user];
CopiedApptics.setUser(user)

Tracking user activity

Track sign-up

  • Call the below method to track a user activity. You should use the below method after the user is registered and you have the user id. 
Copied+ (void) trackSignUp:(NSString* _Nullable)userID;

or

+ (void) trackSignUp:(NSString* _Nullable)userID groupId:(NSString * _Nullable)groupID;

Track user sign-in

  • Call the below method to track a user when they login to your app.
Copied+ (void) trackLogIn:(NSString* _Nullable)userID;

or

+ (void) trackLogIn:(NSString* _Nullable)userID groupId:(NSString * _Nullable)groupID;

Track existing users

  • Call the below method to track any existing users of your app.
Note: This method can be called on every app launch.
Copied+ (void) setCurrentUser:(NSString * _Nullable)userID;

or

+ (void) setCurrentUser:(NSString * _Nullable)userID groupId:(NSString * _Nullable)groupID;

Track user on sign-out

  • Call the below method during user sign-out to let the framework know. This ensures the user's session is properly closed.
Copied+ (void) trackLogOut:(NSString* _Nullable)userID;

or

+ (void) trackLogOut:(NSString* _Nullable)userID groupId:(NSString * _Nullable)groupID;

Note: Use the method with the `userID` parameter to associate the user with a group or organization ID. All data tracked by the Apptics SDK will then be linked to the specified user ID and group or organization ID.