Metrics API
The user behavior tracking API for consumer web and mobile apps
Send a single event to power every in-app experience. Metrics power streaks, milestones, points, leaderboards, and analytics. Scales to millions of users.
Quickstart
Quickstart: send an event and read totals
Metrics are the foundation of Trophy. Send one event to power streaks, milestones, points, and leaderboards, then query the user’s aggregated totals.
import { TrophyApiClient } from "@trophyso/node";
const trophy = new TrophyApiClient({ apiKey: process.env.TROPHY_API_KEY });
// 1. Track a user action — this powers streaks, milestones, points and leaderboards
const eventResponse = await trophy.metrics.event("lessons", {
user: { id: "user-123" },
value: 1,
});
console.log("Event ID:", eventResponse.eventId);
console.log("Lifetime total:", eventResponse.total);
console.log("Unlocked achievements:", eventResponse.achievements?.length);
console.log("Current streak:", eventResponse.currentStreak?.length);
// 2. Query all metrics for a user (profile, progress, analytics)
const metrics = await trophy.users.allMetrics("user-123");
for (const metric of metrics) {
console.log(metric.key, metric.current);
}Buy vs. build
Why use Trophy for event tracking?
Building a reliable event tracking pipeline that powers in-app features is harder than it looks.
Integration Time
Reliability
Scalability
Ongoing Maintenance
Feature Development
Endpoints
Metrics endpoints
Track user interactions and query aggregated data. The metrics.event endpoint is the foundation that powers every other Trophy feature.
Send a metric event for a user. This is the core endpoint that powers all in-app features including streaks, milestones, points, and leaderboards.
Path Parameters
keystringrequiredUnique reference of the metric as set when created.
Request Body
userUserrequiredThe user that triggered the event (must include id).
valuenumberrequiredThe value to add to the user's current total for the given metric.
attributesobjectEvent attributes as key-value pairs matching attributes set up in the dashboard.
Response
eventIdstringUnique identifier for the created event.
totalnumberThe user's new total for this metric.
achievementsAchievement[]Milestones completed by this event.
currentStreakStreakThe user's current streak status.
pointsobjectPoints awarded by this event, keyed by points system.
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
// Track a user event
await trophy.metrics.event(
"lessons",
{
user: { id: "user-123" },
value: 1
}
);
// This single event powers:
// - Streak tracking
// - Achievement progress
// - Points accumulation
// - Leaderboard rankingsGet a single user's progress against all active metrics.
Path Parameters
idstringrequiredID of the user.
Response
keystringUnique key of the metric.
namestringDisplay name of the metric.
currentnumberThe user's current total for this metric.
achievementsAchievement[]Related milestones and their progress.
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
// Query user metrics
const metrics = await trophy.users.allMetrics("user-123");
// Response:
// [
// { key: "words-written", name: "Words written",
// status: "active", current: 4500, achievements: [...] }
// ]Built for production workloads
Reliable infrastructure designed for performance at scale.
- Uptime SLA
- 99.9%
- p95 API Latency
- 200ms
- Monthly API Requests
- 180M
- Users Tracked
- 1M+
What is a metric event?
A metric event is any user action you want to track — completing a lesson, writing words, making a purchase. You send a single API call with the metric key, user ID, and a value, and Trophy automatically updates streaks, milestones, points, and leaderboards.
How does event tracking power other Trophy features?
Metrics are the foundation of Trophy. When you send a metric event, Trophy checks it against all configured features: it extends streaks, evaluates milestone thresholds, awards points, and updates leaderboard rankings — all from that one API call.
Can I track custom user behavior and activity?
Yes. You define your own metric keys (e.g., "lessons", "purchases", "workouts") in the dashboard, then send events with any numeric value. You can also attach custom attributes for filtering and segmentation.
What SDKs are available for event tracking?
Trophy offers type-safe server-side SDKs for Node.js, Python, Go, Java, PHP, Ruby, and .NET. All SDKs provide the same simple interface for sending metric events and querying user data.
Can I use Trophy with React, React Native, or mobile apps?
Yes. Trophy's server-side SDKs handle event tracking and feature logic from your backend, and you fetch the data to display in any frontend — React, React Native, Next.js, Swift, Kotlin, Flutter, or any other framework. This keeps your API key secure and works with any client.
Can I query a user's aggregated metrics?
Yes. The get all metrics endpoint returns a user's progress against all active metrics, including current totals and related milestones. This is useful for rendering dashboards and progress views in your app.