Custom Events
Beyond automatic pageviews, you can record any action in your app with tribe.track(). Custom events appear in the Tribe dashboard alongside your pageview data, giving you a unified picture of how people use your product.
Basic usage
Section titled “Basic usage”import { Tribe } from "@tribecloud/sdk";
tribe.track("event_name", { key: "value" });The first argument is the event name, and the second is an optional data object for attaching whatever properties make sense. Worth noting: track() is fire-and-forget. It returns immediately while the event gets sent in the background via sendBeacon, so it won’t slow down your UI.
Examples
Section titled “Examples”E-commerce
Section titled “E-commerce”tribe.track("purchase", { productId: "abc", amount: 29.99, currency: "USD" });tribe.track("add_to_cart", { productId: "abc", quantity: 1 });tribe.track("checkout_started", { itemCount: 3, total: 89.97 });tribe.track("feature_used", { feature: "export", format: "csv" });tribe.track("plan_upgraded", { from: "free", to: "pro" });tribe.track("invite_sent", { role: "editor" });Content
Section titled “Content”tribe.track("video_played", { videoId: "xyz", duration: 120 });tribe.track("article_read", { slug: "/blog/intro", readTime: 45 });tribe.track("search", { query: "pricing", results: 12 });Script tag usage
Section titled “Script tag usage”If you’re using the script tag integration, the global Tribe object exposes the same method:
<button onclick="Tribe.track('cta_clicked', { location: 'hero' })"> Get Started</button>- Event names work best as lowercase with underscores:
purchase,feature_used,page_scroll - Data values can be strings, numbers, or booleans. Nested objects are serialized as JSON
- No PII should end up in event properties. Keep emails, names, and other personal data out
track()works for both logged-in and anonymous users. Anonymous users are identified by theirlocalStorageanonymous ID- Events are batched and delivered via
sendBeacon, so they arrive reliably even if the page is unloading