Custom Properties for Segments

Leap allows you to add custom properties for creating segments of your choice and use case.
Custom properties will allow you to create more segments that are specific to your app. This is helpful when you are not able to create segments using the default properties. You can do it either in runtime or at the start of the SDK.
Once you have added a custom property on Leap, use the share button to share it with your developer.

To create custom properties at the start of the Leap SDK

You just need to add the below code snippet at the time of SDK integration. The custom properties of a user can be created by adding property in key-value pair.
Android
iOS Swift
iOS Objective-C
React Native
Cordova (Android)
Cordova (iOS)
Xamarin Android
Xamarin iOS
Ionic
Leap.withBuilder("<YOUR_API_KEY>") // Replace "YOUR_API_KEY" with your key
.addProperty("<key1>","<value1>")
.addProperty("<key2>","<value2>")
.start();
Leap.shared.withBuilder("<YOUR_API_KEY>")?
.addProperty("<key1>", stringValue: "<value1>")
.addProperty("<key2>", intValue: <value2>).start()
[[[[[Leap shared] withBuilder:@"<YOUR_API_KEY>"]
addProperty:@"<key1>" stringValue:@"<value1>"]
addProperty:@"<key2>" intValue:<value2>]
start];
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
LeapReactNative.startWithProperties("<YOUR_API_KEY>", userProps);
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
cordova.plugins.LeapAndroid.startWithProperties("<YOUR_API_KEY>", JSON.stringify(userProps);)
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
cordova.plugins.LeapiOS.startWithProperties("<YOUR_API_KEY>", JSON.stringify(userProps);)
Leap.WithBuilder("<YOUR_API_KEY>")
.AddProperty("<key1>","<value1>")
.AddProperty("<key2>","<value2>")
.Start();
Leap.Shared.WithBuilder("<YOUR_API_KEY>")
.AddProperty("<key1>","<value1>")
.AddProperty("<key2>","<value2>")
.Start()
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
LeapPlugin.startWithProperties({apiKey:"<YOUR_API_KEY>", properties:userProps});

To create custom properties in runtime

In cases where the user properties are not immediately generated at the time of starting you can pass the property in runtime as well. Just add the below code snippet at the time of SDK integration. The custom properties of a user can be created by adding property in key-value pair.
Android
iOS Swift
iOS Objective-C
React Native
Cordova(Android)
Cordova (iOS)
Xamarin Android
Xamarin iOS
Ionic
Leap.withPropertyBuilder()
.addProperty("<key1>","<value1>")
.addProperty("<key2>","<value2>")
.flush();
Leap.shared.addProperty("<key1>", stringValue: "<value1>")
.addProperty("<key2>", intValue: <value2>).flush()
[[[[Leap shared]
addProperty:@"<key1>" stringValue:@"<value1>"]
addProperty:@"<key2>" intValue:<value2>]
flush];
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
LeapReactNative.flushProperties(userProps);
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
cordova.plugins.LeapAndroid.flushProperties(JSON.stringify(userProps));
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
cordova.plugins.LeapiOS.flushProperties(JSON.stringify(userProps));
Leap.WithPropertyBuilder()
.AddProperty("<key1>", "<value1>")
.AddProperty("<key2>", "<value2>")
.Flush();
Leap.Shared
.AddProperty("<key1>", "<value1>")
.AddProperty("<key2>", "<value2>")
.Flush();
var userProps = {
"<key1>","<value1>",
"<key2>","<value2>"
}
LeapPlugin.flushProperties({properties:userProps});
In a custom property key-value pair, the key is always a String where value can be String, Integer or Date. If a property is just a flag, you can pass "TRUE" or "FASLE"
For React Native and Cordova, If a property is Date property pass the date in ISO string format by prefixing "Date:" i,e - `Date:${date.toISOString()}`
You can refer to the below examples to create custom properties for segmentation purposes:
Tip: Use plain and meaningful words as key for easy reference.
Android
iOS Swift
iOS Objective-C
React Native
Cordova (Android)
Cordova (iOS)
Xamarin Android
Xamarin iOS
Ionic
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();
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();
[[[[[[[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];
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);
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);
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);
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();
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();
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});