Create Custom Properties

Prev Next

Whatfix Mobile enables you to add Custom Properties to create user segments that are specific to your app. These custom properties can be based on language, age, role, and more. This is helpful when you want to create segments using properties defined by you, apart from the default properties.

After creating your custom properties, add them either at runtime or at the start of the SDK.

The following GIF shows you how to create and share your Custom Property:

adding_custom_property.gif

Info:

Once you have added a custom property on Whatfix Mobile, click the Share icon to share it with your developer.

Create custom properties in runtime

In cases where the user properties are not immediately generated at the time of starting the SDK, pass the property in runtime as well. Add the following code snippet at the time of SDK integration. The custom properties of a user can be created by adding the property in key-value pair.

Android

Leap.withPropertyBuilder()
    .addProperty("<key1>","<value1>")
    .addProperty("<key2>","<value2>")
    .flush();

iOS-Swift

Leap.shared.addProperty("<key1>", stringValue: "<value1>")
           .addProperty("<key2>", intValue: <value2>).flush()

Flutter

LeapAui.flush({
    "property1": 'value1',
    "property2": 'value2'
});

Example:

LeapAui.flush({
    "userName": 'Don Joe',
    "age": 20,
    "cart_added_time": DateTime.now(),
    "user_logged_in": "FALSE"
});

MAUI Android

Leap.WithPropertyBuilder().AddProperty("age", "18").Flush();
or
Leap.Flush(new Dictionary<string, Java.Lang.Object>{ { "userId", new Java.Lang.String("12345") } })
;

Jetpack

Leap.withPropertyBuilder()
    .addProperty("<key1>","<value1>")
    .addProperty("<key2>","<value2>")
    .flush();

Xamarin (Android)

Leap.WithPropertyBuilder()
    .AddProperty("<key1>", "<value1>")
    .AddProperty("<key2>", "<value2>")
    .Flush();

Xamarin (iOS)

Leap.Shared
    .AddProperty("<key1>", "<value1>")
    .AddProperty("<key2>", "<value2>")
    .Flush();

Cordova (Android)

var userProps = {
    "<key1>","<value1>",
    "<key2>","<value2>"
}

cordova.plugins.LeapAndroid.flushProperties(JSON.stringify(userProps));

Cordova (iOS)

var userProps = {
    "<key1>","<value1>",
    "<key2>","<value2>"
}

cordova.plugins.LeapiOS.flushProperties(JSON.stringify(userProps));

Ionic

var userProps = {
        "<key1>","<value1>",
        "<key2>","<value2>"
    }

LeapPlugin.flushProperties({properties:userProps});

React Native

var userProps = {
        "<key1>":"<value1>",
        "<key2>":"<value2>"
    }

LeapReactNative.flushProperties(userProps);

iOS Objective - C

[[[[Leap shared]
       addProperty:@"<key1>" stringValue:@"<value1>"]
       addProperty:@"<key2>" intValue:<value2>]
     flush];

In a custom property key-value pair, the key is always a String, whereas the value can be a String, Integer, or Date. If a property is just a flag pass them as TRUE or FALSE.

Note:

For React Native and Cordova, if a property is a Date property, pass the date in ISO string format, 'Date:${date.toISOString()}'.

Use the following examples to create custom properties for segmentation purposes:

Info:

Use plain and meaningful words as keys for easy reference.

Android

Leap.withBuilder("<YOUR_API_KEY>") // Replace "YOUR_API_KEY" with your key
    .addProperty("userName","Don Joe")
    .addProperty("age", 20)
    .addProperty("cart_added_time",new Date())
    .addProperty("user_logged_in", "FALSE")
    .start();

or

Leap.withPropertyBuilder()
    .addProperty("user_logged_in", "TRUE")
    .flush();

iOS-Swift

Leap.shared
    .withBuilder("<YOUR_API_KEY>")? // Replace "YOUR_API_KEY" with your key
    .addProperty("userName",stringValue:"Don Joe")
    .addProperty("age", intValue:20)
    .addProperty("cart_added_time",dateValue:Date())
    .addProperty("user_logged_in", stringValue:"FALSE")
    .start();
or

Leap.shared
    .addProperty("user_logged_in", stringValue:"TRUE")
    .flush();

Flutter

LeapAui.flush({
    "property1": 'value1',
    "property2": 'value2'
});

Example:

LeapAui.flush({
    "userName": 'Don Joe',
    "age": 20,
    "cart_added_time": DateTime.now(),
    "user_logged_in": "FALSE"
});

MAUI Android

Leap.Flush(new Dictionary<string, Java.Lang.Object>{
    { "userId", new Java.Lang.String("12345") },
    { "isPremiumUser", new Java.Lang.Boolean(true) },
    { "score", new Java.Lang.Integer(100) }
});

MAUI iOS

Leap.Shared.AddProperty("age",18).AddProperty("gender","female").Flush();

Jetpack

Leap.withBuilder("<YOUR_API_KEY>") // Replace "YOUR_API_KEY" with your key
    .addProperty("userName","Don Joe")
    .addProperty("age", 20)
    .addProperty("cart_added_time",new Date())
    .addProperty("user_logged_in", "FALSE")
    .start();

or

Leap.withPropertyBuilder()
    .addProperty("user_logged_in", "TRUE")
    .flush();

Xamarin (Android)

Leap.WithBuilder("<YOUR_API_KEY>")
                .AddProperty("userName", "Don Joe")
                .AddProperty("age", 20)
                .AddProperty("cart_added_time", new Java.Util.Date())
                .AddProperty("user_logged_in", "FALSE")
                .Start();

or

Leap.WithPropertyBuilder()
                .AddProperty("user_logged_in", "TRUE")
                .Flush();

Xamarin (iOS)

Leap.Shared.WithBuilder("<YOUR_API_KEY>")
                .AddProperty("userName", "Don Joe")
                .AddProperty("age", 20)
                .AddProperty("cart_added_time", new NSDate())
                .AddProperty("user_logged_in", "FALSE")
                .Start();

or

Leap.Shared.AddProperty("user_logged_in", "TRUE")
                .Flush();

Cordova (Android)

var date = new Date()

var userProps = {
        "userName": "Don Joe",
        "age": 20,
        "cart_added_time": `Date:${date.toISOString()}`,
        "user_logged_in": "FALSE"
    }

cordova.plugins.LeapAndroid.startWithProperties("<YOUR_API_KEY>", userProps);

or

cordova.plugins.LeapAndroid.flushProperties(userProps);

Cordova (iOS)

var date = new Date()

var userProps = {
        "userName": "Don Joe",
        "age": 20,
        "cart_added_time": `Date:${date.toISOString()}`,
        "user_logged_in": "FALSE"
    }

cordova.plugins.LeapiOS.startWithProperties("<YOUR_API_KEY>", userProps);

or

cordova.plugins.LeapiOS.flushProperties(userProps);

Ionic

var date = new Date()

var userProps = {
        "userName": "Don Joe",
        "age": 20,
        "cart_added_time": `Date:${date.toISOString()}`,
        "user_logged_in": "FALSE"
}

LeapPlugin.startWithProperties({apiKey:"<YOUR_API_KEY>",properties:userProps});

or

LeapPlugin.flushProperties({properties:userProps});

React Native

var date = new Date()

var userProps = {
        "userName": "Don Joe",
        "age": 20,
        "cart_added_time": `Date:${date.toISOString()}`,
        "user_logged_in": "FALSE"
    }

LeapReactNative.startWithProperties("<YOUR_API_KEY>", userProps);

or

LeapReactNative.flushProperties(userProps);

iOS Objective - C

[[[[[[[Leap shared] withBuilder:@"<YOUR_API_KEY>"]
                    addProperty:@"username" stringValue:@"Don Joe"]
                    addProperty:@"age" intValue:20]
                    addProperty:@"cart_added_time" dateValue:[NSDate date]]
                    addProperty:@"user_logged_in" stringValue:@"FALSE"] start];

or
[[[Leap shared]
            addProperty:@"user_logged_in" stringValue:@"TRUE"]
            flush];