- 24 Jun 2024
- 3 Minutes To Read
-
Print
-
DarkLight
-
PDF
Create Custom Properties
- Updated On 24 Jun 2024
- 3 Minutes To Read
-
Print
-
DarkLight
-
PDF
Whatfix Mobile enables you to add Custom Properties to create user segments that are specific to your app. 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 in the runtime or at the start of the SDK.
The following GIF shows you how to create and share your Custom Property:
You need to add the following code snippet at the time of SDK integration. The custom properties of a user can be created by adding the property as a key-value pair.
Android
Leap.withBuilder("<YOUR_API_KEY>") // Replace "YOUR_API_KEY" with your key
.addProperty("<key1>","<value1>")
.addProperty("<key2>","<value2>")
.start();
Swift
Leap.shared.withBuilder("<YOUR_API_KEY>")?
.addProperty("<key1>", stringValue: "<value1>")
.addProperty("<key2>", intValue: <value2>).start()
Objective-C
[[[[[Leap shared] withBuilder:@"<YOUR_API_KEY>"]
addProperty:@"<key1>" stringValue:@"<value1>"]
addProperty:@"<key2>" intValue:<value2>]
start];
React Native
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
LeapReactNative.startWithProperties("<YOUR_API_KEY>", userProps);
Ionic
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
LeapPlugin.startWithProperties({apiKey:"<YOUR_API_KEY>", properties:userProps});
Cordova (Android)
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
cordova.plugins.LeapAndroid.startWithProperties("<YOUR_API_KEY>", JSON.stringify(userProps);)
Cordova (iOS)
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
cordova.plugins.LeapiOS.startWithProperties("<YOUR_API_KEY>", JSON.stringify(userProps);)
Xamarin Android
Leap.WithBuilder("<YOUR_API_KEY>")
.AddProperty("<key1>","<value1>")
.AddProperty("<key2>","<value2>")
.Start();
Xamarin iOS
Leap.Shared.WithBuilder("<YOUR_API_KEY>")
.AddProperty("<key1>","<value1>")
.AddProperty("<key2>","<value2>")
.Start()
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()
iOS Objective C
[[[[Leap shared]
addProperty:@"<key1>" stringValue:@"<value1>"]
addProperty:@"<key2>" intValue:<value2>]
flush];
React Native
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
LeapReactNative.flushProperties(userProps);
Ionic
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
LeapPlugin.flushProperties({properties:userProps});
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));
Xamarin Android
Leap.WithPropertyBuilder()
.AddProperty("<key1>", "<value1>")
.AddProperty("<key2>", "<value2>")
.Flush();
Xamarin iOS
Leap.Shared
.AddProperty("<key1>", "<value1>")
.AddProperty("<key2>", "<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.
Use the following examples to create custom properties for segmentation purposes:
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();
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];
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);
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});
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);
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();