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

Server-side events

Send activities, profiles, and consent from your own servers with the tracking API.

Your goal

Send activities from your backend rather than from a browser - because the data lives there, because you want to avoid client-side loss, or because there is no browser involved at all.

Expected outcome

Activities, profile updates, and user choices arriving from your servers, identified as reliably as your systems allow.

Send an activity

POST https://api.mediarithmics.com/v1/datamarts/:datamartId/user_activities

With Content-Type: application/json, and a valid UserActivity object as the body.

Identification is done through the $user_identifiers property. Use as many identifiers as are available in your environment at the time of capture - this is what determines how well the platform can consolidate the user.

{
  "$ts": 3489009384393,
  "$type": "APP_VISIT",
  "$session_status": "IN_SESSION",
  "$user_identifiers": [
    {
      "$type": "USER_ACCOUNT",
      "$compartment_id": "<COMPARTMENT_ID-1>",
      "$user_account_id": "<ACCOUNT_ID-1>"
    },
    {
      "$type": "USER_ACCOUNT",
      "$compartment_id": "<COMPARTMENT_ID-1>",
      "$user_account_id": "<ACCOUNT_ID-2>"
    },
    {
      "$type": "USER_AGENT",
      "$user_agent_id": "<USER_AGENT_ID>"
    },
    {
      "$type": "USER_EMAIL",
      "$hash": "<USER_EMAIL_HASH>",
      "$email": "<USER_EMAIL>"
    }
  ],
  "$app_id": "1023",
  "$events": [
    {
      "$ts": 3489009384393,
      "$event_name": "$app_open",
      "$properties": {}
    }
  ]
}

Identifier properties at the activity root - $user_agent_id, $user_account_id with $compartment_id, and $email_hash - still work but are legacy. Prefer $user_identifiers.

Create or update a profile

Which way you pick depends on whether you want the update recorded as an event.

Register an activity containing a $set_user_profile_properties event. Use $user_account_id and $compartment_id inside $properties to identify the profile to update.

Any identifier available on the UserPoint can be used in the activity object.

Use this when you want the profile update to exist as an event you can retrieve later.

The body is a UserProfile object:

$compartment_id and $user_account_id in the payload are not mandatory here, because they are already given as parameters.

Prefer this method if you can integrate several API endpoints and you do not need the profile update tracked as an event.

The update_strategy query parameter controls how the update is applied - PARTIAL_UPDATE, PARTIAL_DELETE, or FORCE_REPLACE. See Import profiles for what each one does. The older force_replace and merge_objects parameters are legacy; use update_strategy instead.

The UserPoint selector

Endpoints that act on a specific user take a selector, and any identifier can be used:

Create or update a user choice

Here too, there are several ways.

Register an activity containing a $set_user_choice event. This is the method to use when you want real-time tracking but cannot use the JavaScript tag - in a mobile application, for instance.

$processing_id and $choice_acceptance_value are both mandatory.

$choice_ts and $choice_acceptance_value are mandatory.

Reading choices back:

  • GET .../user_points/:userSelector/user_choices/processing_id=:processingId lists the choices. The processing ID is optional - omit it to list all of them.

  • GET .../user_points/:userSelector/user_choices/processing_id=:processingId/change_log returns the history of a choice.

Prefer this method if you can integrate several API endpoints.

See Manage consent & Processing activities for what a processing activity is and how choices are enforced.

Verify

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

  • A test call produces an activity on the expected UserPoint, with the identifiers you sent.

  • A profile update is visible on the profile you targeted, in the compartment you targeted.

  • A user choice is readable back through the choices endpoint.

Troubleshooting

Symptom
Likely cause

A new UserPoint per call

The identifiers you send are not stable, or the registry or compartment referenced does not exist.

The profile update lands on the wrong profile

The selector and the profile parameters were confused - see the warning above.

A user choice never appears

An activity analyzer removed the $set_user_choice event before storage.

The activity is rejected

The body is not a valid UserActivity, or it exceeds the 8,000-character limit.

Last updated

Was this helpful?