Custom Events
While Ucoder Insight automatically tracks page views and standard clicks, Custom Events allow you to track specific business actions like “Add to Cart”, “Form Submission”, or “Video Play”.
Config Custom event
import { trackCustomEvent } from "ucoder/core";Data Structure
Every custom event follows a strict structure to ensure data consistency in your dashboard.
track(eventName, config)
| Property | Type | Required | Description |
|---|---|---|---|
| event_name | string | Yes | The primary name of the event (e.g., user_signup). |
| action_category | string | Yes | Group similar events (e.g., ecommerce, auth, video). |
| object_id | string | No | ID of the object being interacted with (e.g., product_id). |
| status | 'success' | 'failure' | No | Outcome of the action. |
| message | string | No | Readable description or error message. |
| additionalData | object | No | Key-value pairs for extra context. |
Usage Examples
Blog
import { trackCustomEvent } from "ucoder/core";
export default function AddToCartButton() {
trackCustomEvent({
event_name: "email_input_clicked",
action_category: "interaction",
object_id: "email_input_field",
status: "success",
});
return <button onClick={handleAddToCart}>Buy Now</button>;
}Data Constraints
To maintain performance, additionalData only accepts flat objects. Nested objects or arrays are not allowed.
Allowed types:
stringnumberbooleannull/undefined
Invalid Example:
additionalData: {
user_info: { name: "John" } // Nested objects are NOT allowed
}Last updated on