Custom Events
Learn how to implement custom event tracking in Ucoder Insight. Understand the data structure, usage examples, and best practices for tracking specific user interactions like 'Add to Cart', 'Form Submission', and more.
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-insight";Data Structure
Every custom event follows a strict structure to ensure data consistency in your dashboard.
trackCustomEvent({dataKey: dataValue})
| 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-insight";
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
}Auto Tracking
Understand the core metrics Ucoder Insight captures automatically. Learn how to leverage page views, click tracking, scroll depth, error monitoring, and performance metrics to optimize your website's user experience and conversions.
Dashboard Overview
Understanding your project performance metrics and calculations.