OxinionDeveloper
Data

Analytics

Query event counts, funnel data, and engagement metrics from your Oxinion deployment.

Overview

The Analytics module exposes aggregated metrics for location events, reward activity, and engagement across all modules. All queries are scoped to your API key.

Event counts

typescript
1import { createOxinion } from 'oxinion';
2
3const oxinion = createOxinion({ apiKey: 'sk_...' });
4
5const { data, error } = await oxinion.analytics.events.counts({
6 from: '2025-01-01',
7 to: '2025-01-31',
8 events: ['geofence.entered', 'rewards.issued'],
9 groupBy: 'day',
10});
11
12if (data) {
13 data.forEach((row) => {
14 console.log(row.date, row['geofence.entered'], row['rewards.issued']);
15 });
16}

Funnel analysis

typescript
1const { data } = await oxinion.analytics.events.funnel({
2 from: '2025-01-01',
3 to: '2025-01-31',
4 steps: ['geofence.entered', 'rewards.issued', 'rewards.redeemed'],
5 windowHours: 24,
6});
7
8data?.steps.forEach((step) => {
9 console.log(step.event, '->', step.users, 'users');
10});

Top geofences

typescript
1const { data } = await oxinion.analytics.events.topGeofences({
2 from: '2025-01-01',
3 to: '2025-01-31',
4 metric: 'entries',
5 limit: 10,
6});
7
8data?.forEach((g) => {
9 console.log(g.tag, g.externalId, '->', g.entries, 'entries');
10});

User segmentation

typescript
1const { data } = await oxinion.analytics.users.segment({
2 filter: {
3 hasVisited: { geofenceTag: 'flagship-store' },
4 rewardBalance: { gte: 100 },
5 },
6});
7
8console.log('Matching users:', data?.count, data?.userIds);

Methods

analytics.events.counts(params)
Aggregate counts by event type over a date range. Params: { from, to, events?, groupBy? }.
analytics.events.funnel(params)
Compute drop-off across an ordered event sequence. Params: { from, to, steps, windowHours? }.
analytics.events.topGeofences(params)
Rank geofences by entry/exit/dwell count. Params: { from, to, metric, limit? }.
analytics.users.segment(params)
Filter user IDs by activity and property conditions.