---
title: Custom Event Context
url: https://docs.kaltura.com/docs/rich-media-cms-apis/analytics/analytics-events-custom-context
---

## Custom Event Context

### Per-Application Segmentation via appId

Use the `appId` KS privilege to segment analytics by application:

```bash
# Generate KS with appId privilege
KS=$(curl -s -X POST "$KALTURA_SERVICE_URL/service/session/action/start" \
  -d "secret=$KALTURA_ADMIN_SECRET" \
  -d "format=1" \
  -d "type=0" \
  -d "partnerId=$KALTURA_PARTNER_ID" \
  -d "userId=viewer@example.com" \
  -d "privileges=appId:corporate-portal" | tr -d '"')

# All events sent with this KS are tagged under "corporate-portal"
curl -s -X POST "$KALTURA_SERVICE_URL/service/stats/action/collect" \
  -d "ks=$KALTURA_KS" \
  -d "format=1" \
  -d "event[objectType]=KalturaStatsEvent" \
  -d "event[partnerId]=$KALTURA_PARTNER_ID" \
  -d "event[entryId]=$KALTURA_ENTRY_ID" \
  -d "event[eventType]=3" \
  -d "event[sessionId]=$SESSION_ID" \
  -d "event[eventTimestamp]=$(date +%s)"
```

Pull per-application analytics via `report.getTable` with the same `appId`-scoped KS.

### Event Context Fields

| Field | Source | Description |
|-------|--------|-------------|
| `userId` | KS privilege | Ties events to a specific user |
| `appId` | KS privilege | Tags events to a named application |
| `referrer` | Event field | Page URL or device identifier |
| `clientVer` | Event field | Client application version |
| `uiconfId` | Event field | Player configuration ID |
