Collect and track user data

Here's how you can collect and track your iOS users' data in HelpCrunch.
Written by Andrew
Updated 3 months ago

By default, the HelpCrunch SDK doesn’t require users to enter any of their information before starting a chat conversation with you. You can send user data by yourself or enable our Welcome screen with the attributes that you want users to enter.

Sending User attributes

Saving app user data to HelpCrunch is done by creating the HCSUser object and passing it to [HelpCrunch updateUser:completion:] or [HelpCrunch initWithConfiguration:user:completion:].

Be sure to add unique User ID strings to the userId property for all your users. Constructing empty users with no data will not work (after all, you will have no use of an empty user you cannot identify).

Don't use a static field value for the userId field! 
Each userId must be unique for unique users or null for anonymous users.

ObjC:

HCSUser *user = [HCSUser new];
user.userId = @"UserId";
user.name = @"Name";
user.email = @"Email";
user.phone = @"Phone";
user.company = @"Company";
user.customData = @{
    @"CustomKey1": @"CustomObject1",
    @"CustomKey2": @"CustomObject2",
    @"CustomKey3": @"CustomObject3"
  };

[HelpCrunch updateUser:user completion:^(NSError * _Nullable error) {}];

Swift:

let user = HCSUser()
user.userId = "UserId"
user.name = "Name"
user.email = "Email"
user.phone = "Phone"
user.company = "Company"
user.customData = ["CustomKey1": "CustomObject1",
                   "CustomKey2": "CustomObject2",
                   "CustomKey3": "CustomObject3"]

HelpCrunch.update(user)

You can also pass user data when initializing HelpCrunch in your application:

ObjC:

[HelpCrunch initWithConfiguration:configuration
                             user:user
                       completion:^(NSError * _Nullable error) {}];

Swift:

HelpCrunch.initWith(configuration, user: user)

After you have added user’s data, it will appear in your HelpCrunch admin panel right in a chat window:

In addition to user’s name / email / company / phone and ID, HelpCrunch lets you send additional customer attributes as custom data.

With the customData attributes, you can send any user information you wish to track. Custom data is key/value pairs and can contain numbers, strings or boolean data. You can associate a specific user of your application with a specific HelpCrunch chat using the withUserId option.

To create the new customData attribute, go to Settings → Contacts → Custom attributes and click 'Add new attribute'.

 ObjC:

HCSUser *user = [HCSUser new];
user.userId = @"UserId";
user.customData = @{
    @"CustomKey1": @"CustomObject1",
    @"CustomKey2": @"CustomObject2",
    @"CustomKey3": @"CustomObject3"
  };

[HelpCrunch updateUser:user completion:^(NSError * _Nullable error) {}];

 Swift:

let user = HCSUser()
user.userId = "UserId"
user.customData = ["CustomKey1": "CustomObject1",
                   "CustomKey2": "CustomObject2",
                   "CustomKey3": "CustomObject3"]

HelpCrunch.update(user)

Custom data parameters will appear in a chat window in your HelpCrunch admin panel just like main user attributes (name, email, user id) do:

Also, you will be able to use custom data for searching through your Contacts' list. There are 5 types of custom data you can search by: integer, float, string, date, and boolean:

Did this answer your question?