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.

SDKs for
NodeJSGoJava.NETPHPPythonRuby

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

1 API call to start tracking events. Full integration in hours.
Build
Build event ingestion pipeline, storage layer, aggregation logic, and API endpoints. Expect 4-8 weeks.
Why does it matter?
Event pipelines seem simple until you need to handle deduplication, ordering, and fan-out to downstream features like streaks and milestones.

Reliability

99.9% uptime with built-in idempotency and exactly-once processing guarantees.
Build
You must solve idempotency, retry logic, and exactly-once semantics yourself — especially tricky when events fan out to multiple systems.
Why does it matter?
A missed or duplicated event can break a user's streak, double-award a milestone, or corrupt a leaderboard. Getting this right is critical.

Scalability

Trophy processes hundreds of millions of events daily with automatic scaling.
Build
Each growth milestone requires re-evaluating your pipeline: batching strategies, queue sizing, database partitioning, and more.
Why does it matter?
Event volume grows with your user base. A pipeline that works at 10K events/day can fail at 10M without significant re-architecture.

Ongoing Maintenance

Zero maintenance. Trophy handles infrastructure, monitoring, and updates.
Build
Ongoing monitoring, schema migrations, pipeline health checks, and on-call rotations for event processing failures.
Why does it matter?
Event pipelines are operationally expensive. Alert fatigue from transient failures and data drift can consume engineering time.

Feature Development

New metric types, aggregation modes, and attribute filters ship regularly.
Build
Each new metric type or aggregation requires schema changes, migration scripts, and downstream updates across all consuming features.
Why does it matter?
Your metrics requirements will evolve as your product grows. Building flexibility in from day one is expensive; retrofitting it later is worse.

Endpoints

Metrics endpoints

Track user interactions and query aggregated data. The metrics.event endpoint is the foundation that powers every other Trophy feature.

POST/metrics/{key}/eventView docs

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

keystringrequired

Unique reference of the metric as set when created.

Request Body

userUserrequired

The user that triggered the event (must include id).

valuenumberrequired

The value to add to the user's current total for the given metric.

attributesobject

Event attributes as key-value pairs matching attributes set up in the dashboard.

Response

eventIdstring

Unique identifier for the created event.

totalnumber

The user's new total for this metric.

achievementsAchievement[]

Milestones completed by this event.

currentStreakStreak

The user's current streak status.

pointsobject

Points awarded by this event, keyed by points system.

Example
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 rankings
GET/users/{id}/metricsView docs

Get a single user's progress against all active metrics.

Path Parameters

idstringrequired

ID of the user.

Response

keystring

Unique key of the metric.

namestring

Display name of the metric.

currentnumber

The user's current total for this metric.

achievementsAchievement[]

Related milestones and their progress.

Example
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+

Questions

What developers ask about metrics

Not answered here?Ask the team
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.