In addition to the clearly predefined events listed in the last chapter, developers can report custom events according to their own analysis needs.
The custom event names should be customized by the developer.
Here are the naming rules:
A custom property is an NSDictionary object where each element represents a property. "Key" is the property name.
The data type of custom event properties is determined by their data types reported for the first time and cannot be changed once confirmed. For subsequent reporting of the same properties, only properties with the same data types as the first occurrence will be stored in the database.
Data Type | Description | Example |
---|---|---|
number | Range from -9E15 to 9E15, without quotation marks. | 1234, 12.34 |
string | Limit 2KB. Numbers with quotation marks will also be identified as strings. | "dashen", "北京", "1234", "true" |
date | "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd HH:mm:ss", or "yyyy-MM-dd 00:00:00" | "2023-03-01 12:34:56","2023-03-01 12:34:56.789","2023-03-01 00:00:00" |
boolean | True or false without quotation marks. | true, false |
array | All elements in an array will be converted into strings. | ["a","1","true"] |
Note:
The data type of the property determines their analysis logic available in analysis models. For example, the numerical type can perform calculations such as maximum value, minimum value, and summation, while the Boolean type can perform calculations of true and false values. Therefore, when determining the format of data reporting, you need to consider the analysis scenarios and business needs and formulate a complete event tracking plan as directions.
Here is an example code of a user purchasing a product:
[[SolarEngineSDK sharedInstance] track:@"isFirstBuy" withProperties:properties];
Parameter | Description | Type | Required |
---|---|---|---|
eventName | Developer custom event name | NSString | Yes |
customProperties | Developer custom event property | NSDictionary | No |
preProperties | Preset properties: only two keys, _pay_amount and _currency_type, are supported. | NSDictionary | No |
Function
- (void)track:(NSString *)eventName withCustomProperties:( NSDictionary * _Nullable )customProperties withPresetProperties:( NSDictionary * _Nullable )preProperties;
Sample Code
NSDictionary *customProperties = @{
@"orderId":@"1234567",
@"payType":@"success"
};
NSDictionary *presetProperties = @{
@"_pay_amount":@4.9,
@"_currency_type":@"USD"
};
[[SolarEngineSDK sharedInstance] track:@"order" withCustomProperties:customProperties withPresetProperties:presetProperties];