Setting Global Properties
The Singular SDK lets you define additional custom properties to send to the Singular servers with every session and event sent from the app. These properties can represent any information you want about the user, the app mode or status, or anything else. Once you set these properties, they are available as dimensions in your reports and you can use them to break down your data.
For example, if you have a gaming app, you can define a property called "Level" and set it initially to "0". Any session and event sent from the app will be sent with "Level": "0". Once the user levels up you reset the property to "1" and so on. You can then get your reports, including sessions, event counts, and revenue data, broken down by user level.
- You can define up to 5 global properties.
- They persist between app runs (with the latest value you gave them) until you unset them or the user uninstalls the app.
- Each property name and value can be up to 200 characters long. If you pass a longer property name or value, it will be truncated to 200 characters.
- Global properties are accessible and available in user-level exports and postbacks. In the future, aggregate reporting support will be added. Let your Singular customer success manager know if you have any questions, or are interested in updates to global properties support!
Setting Global Properties through SingularConfig
You can use the withGlobalProperty method to set global properties through SingularConfig before initializing the SDK.
Note that since global properties and their values persist between app runs, the property that you are setting may already be set to a different value. Use the overrideExisting parameter to tell the SDK whether to override an existing property with the new value or not.
withGlobalProperty Method | |
---|---|
Description | Set a global property. |
Signature | .withGlobalProperty(String key, String value, boolean overrideExisting) |
Usage Example |
|
Setting Global Properties After Initialization
Use the following methods to set, unset, and retrieve global properties at any time in the app's run.
Singular.setGlobalProperty Method | |
---|---|
Description |
Set a global property to a given value. Notes:
|
Signature | public static bool setGlobalProperty(String key, String value, boolean overrideExisting) |
Usage Example |
|
Singular.getGlobalProperties Method | |
Description | Retrieve all the global properties and their current values as a Map. |
Signature | public static Map<String, String> getGlobalProperties() |
Usage Example |
|
Singular.unsetGlobalProperty Method | |
Description | Remove a global property. |
Signature | public static void unsetGlobalProperty(String key) |
Usage Example |
|
Singular.clearGlobalProperties Method | |
Description | Remove all global properties. |
Signature | public static void clearGlobalProperties() |
Usage Example |
|