Menu

Custom Events

       In addition to Predefined Events by SolarEngine, developers can report custom events according to their own analysis needs.

       The _event_name should be customized by the developer.

Event Name Requirements

  • String type
  • Start with letters only.
  • No more than 40 characters.
  • Contain numbers, lowercase letters and underscores only.

Property

Event property is an Object, where each key-value pair represents a property.

Key: Property Name

  • String type
  • Start with letters only.
  • No more than 40 characters.
  • Contain numbers, lowercase letters and underscores only.

Value: Property Value

  • Support basic data types like String, number, boolean, and date
  • For elements of an array, only string type is supported.
  • For other types, they will be forcibly converted to strings and stored.

Custom Property Types

       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 TypeDescriptionExample
numberRange from -9E15 to 9E15, without quotation marks.such as: 1234, 12.34

stringLimit 2KB. Numbers with quotation marks will also be identified as strings."dashen", "北京"

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"
booleanTrue or false without quotation marks.true, false
arrayAll 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.

Function

export function trackCustomEvent(eventName:string, customProperties?:Object, preProperties?:Object)
ParameterDescriptionTypeRequired
eventNameCustom event nameStringYES
customPropertiesCustom event propertiesObjectNo
prePropertiesPreset propertiesObjectNo

The preProperties currently support _currency_type and _pay_amount. Other preset properties will be discarded directly.

Sample Code

let eventName = "fake_key_name";
let customProperties = {"key1":"value1", "key2":"value2"};
let preProperties = {"_currency_type":" USD", "_pay_amount":11}
SolarEngine.trackCustomEvent(eventName, customProperties, preProperties); 


Previous
Predefined Events
Next
Duration Events
Last modified: 2024-12-05Powered by