For the complete documentation index, see llms.txt. This page is also available as Markdown.

App tracking

Track mobile and CTV applications through the tracking API, with signature authentication.

Your goal

Send activities from your mobile or CTV application to the platform, authenticated in a way that is safe for code running on a user's device.

Expected outcome

App activities arriving with the right activity type, the right channel ID, and correctly formatted device identifiers - and no long-term token embedded in the application.

What app tracking requires

None of these requirements are optional:

Requirement
Detail

The tracking API

All user activities are sent using the tracking API - there is no app SDK to install.

Signature authentication

Requests between your application and mediarithmics are authenticated with signature authentication. See Manage API access.

Correct payload

The activity and events must follow the specifics below.

Correctly formatted $user_agent_id

Device identifiers use the formats described in UserDevice & UserDeviceTechnicalId.

Ways to integrate

Call the API from the app

Integrate a small piece of code - around 100 lines - into the application to make the calls to the tracking API. Complete samples for iOS, Android, Tizen and webOS, Android TV and Roku are below.

Forward from an existing analytics tool

Reuse an analytics tool you already have in the app, and transfer events from that solution's server to the mediarithmics API.

The second option keeps the credential on your servers rather than in the app, at the cost of depending on the other tool's export.

Activity formatting

Field
Type
Description

$type

String enum

Must be APP_VISIT.

$session_status

String enum

See the session status guidance below.

$user_agent_id

String, optional

The user agent identifier of the device, in the unified representation.

$app_id

String

The mobile app ID - the channel, created beforehand in Navigator or through the API.

Field
Type
Description

$type

String enum

Must be CTV_VISIT.

$session_status

String enum

See the session status guidance below.

$user_agent_id

String, optional

The user agent identifier of the device, in the unified representation.

$ctv_id

String

The CTV app ID - the channel, created beforehand in Navigator or through the API.

For CTV application tracking, automatic capture of IP addresses is available. See Network IDs.

Choosing a session status

This is the decision that shapes your integration:

Value
When to use it
Consequence

IN_SESSION

Recommended. One API call per tracked event.

The platform automatically aggregates all the events of a session sent across many calls.

CLOSED_SESSION

Only if you make a single API call per session, at its end.

You must provide all the events of the session in the $events array. Each call with this value generates a new user activity.

Predefined app events

Predefined event names are available out of the box to simplify and automate event processing:

Event
Meaning
Who sends it

$app_open

The app was opened, or resumed and became active again.

You.

$app_install

The app was installed.

The platform. Triggered the first time an app open event is received for a user, whether the user is new or existing.

$app_update

The app was updated.

The platform. Triggered when the SDK version, app version, or OS version changes from one open to the next.

You do not send $app_install or $app_update - they are calculated server-side from $app_open. Sending them yourself would double-count.

The full catalogue is in UserActivity & UserEvent.

Sample integration

Each sample below is a complete integration for one platform: it signs the payload with HMAC-SHA256, builds an activity of the shape described above, and posts it to the tracking API. The signPayload function every sample opens with is the digest specification documented on Manage API access.

Replace the placeholder constants with your own values - the datamart ID, the channel ID that goes in $app_id or $ctv_id, the compartment and registry IDs, and the secret key with its key_id.

The samples hold SECRET_KEY_VALUE as a constant so that they stay readable. It is the value returned once, when the key is created - see Generate a secret key.

iOS - Swift
Android - Kotlin
Tizen and webOS - JavaScript
Android TV and Google TV - Kotlin
Roku - BrightScript

Verify

  • The API step shows events in ingestion monitoring. See Monitor data ingestion.

  • Activities appear with type APP_VISIT or CTV_VISIT and the expected channel ID.

  • Device identifiers resolve to a device point rather than being dropped, which means the registry exists.

  • $app_install appears once for a new user, without you sending it.

Troubleshooting

Symptom
Likely cause

Calls are rejected

The signature is computed over the wrong message. Check the order uri, key_id, timestamp, body, separated by \n.

One activity per event instead of a session

$session_status is CLOSED_SESSION - each such call creates a new activity.

Device identifiers do not appear

The $user_agent_id format is wrong for the registry type, or the registry does not exist.

Events land on the wrong property

$app_id or $ctv_id points at the wrong channel.

Last updated

Was this helpful?