How to Send a Custom Event
Supported Data Types for Event Properties
Supported Data Types for Event Properties
| Data Type | Example Key | Example Value |
|---|---|---|
String | ”productName" | "Headphones” |
Int / Long | ”quantity” | 2 |
Boolean | ”isNewUser” | true |
Double / Float | ”price” | 199.99 |
JSONArray | ”tags” | [“electronics”, “audio”] |
JSONObject | ”userInfo” | { “id”: “u123”, “age”: 28 } |
null | ”discount” | null (Not allowed. Avoid using null in eventProperties. Use "0", "unknown", or remove the key.) |
📝 Note
Only primitive types,JSONArray, andJSONObjectare allowed insideeventProperties.
Avoid passing complex objects or custom class instances directly. Convert them to JSON first.
💡 All properties must be JSON-serializable. Also, avoid passingnullvalues.
Example of Custom Event Payload: Supported Data Types
Understand the types of data you can pass insideeventProperties and how to structure complex objects.
Best Practices for Custom Event Tracking
Best Practices for Custom Event Tracking
Follow these guidelines to help users name, structure, and send custom events effectively.
-
Naming Guidelines
- Use
camelCaseorsnake_casefor event names (e.g.,purchaseCompleted,user_logged_in) - Keep names short and descriptive
- Avoid spaces or special characters
- Use
-
Event Structure
- Use consistent keys (e.g., always use
"productId") - Include only relevant attributes
- Skip redundant or unused properties
- Use consistent keys (e.g., always use
-
Avoid These Mistakes
- Don’t send raw classes — always serialize to JSON
- Avoid high-cardinality keys (e.g., UUIDs, timestamps)
- Never pass
null— use"unknown"or remove the key