Tracking API
Beware of the authentication method you choose, so that it is adapted to the context running API calls.
post
https://api.mediarithmics.com
/v1/datamarts/:datamartId/user_activities
Import a user activity
Identification of the user or of the device is achieved through the
$user_identifiers
property. We encourage you to use as many identifiers as available in your environment at the time of the capture.{
"$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" : {}
}]
}
It is still possible to use the identifiers properties at the activity root level (
$user_agent_id
, $user_account_id
+ $compartment_id
, $email_hash)
, however these are to be considered as legacy.$user_identifiers
property is to be preferred.{
"$ts" : 3489009384393,
"$type" : "APP_VISIT",
"$session_status" : "IN_SESSION",
"$user_agent_id" : "<USER_AGENT_ID>",
"$compartment_id" : "<COMPARTMENT_ID>",
"$user_account_id" : "<ACCOUNT_ID>",
"$app_id" : "1023",
"$events" : [
{
"$ts" : 3489009384393,
"$event_name" : "$app_open",
"$properties" : {}
}]
}
A user profile can be created / updated by registering a user activity containing a
$set_user_profile_properties
event. In that case you would need to use $user_account_id
and $compartment_id
inside $properties
to identify the user profile to update:{
"$ts" : 3489009384393,
"$type" : "APP_VISIT",
"$session_status" : "IN_SESSION",
"$user_identifiers" : [{
"$type": "USER_ACCOUNT",
"$compartment_id" : "<COMPARTMENT_ID>",
"$user_account_id" : "<ACCOUNT_ID>"
}],
"$app_id" : "1023",
"$events" :[{
"$ts" : 1679588413000,
"$event_name" : "$set_user_profile_properties",
"$properties" : {
"$compartment_id" : "<COMPARTMENT_ID>",
"$user_account_id" : "<ACCOUNT_ID>",
"gender" : "Male",
"zipcode" : "78000"
}
}]
}
Note that you can used any identifier available on the user point in the user activity object
A user profile can be created / updated by registering a user activity containing a
$set_user_choice
event. This method is used when you want to achieve real-time tracking but can't use the mediarithmics JavaScript Tag. In mobile applications for example.
Please note that those events will go through the processing pipeline before being stored as a user choice. You must ensure no activity analyzers is removing them during that process.
// Sample user activity to add using the tracking API
{
"$user_account_id":"<your_user_account_id>",
"$compartment_id":<your_compartement_id>,
"$type":"<your_activity_type (ex: SITE_VISIT)",
"$site_id": "<your_site_id>",
"$session_status":"NO_SESSION",
"$ts":<a_timestamp (ex:1572947762)>,
"$events": [
{
"$event_name":"$set_user_choice",
"$ts":<a_timestamp (ex:1572948120)>,
"$properties":{
"$processing_token": "<your_processing_token>", // Mandatory
"$choice_acceptance_value":<true/false>, // Mandatory
"<your_custom_field>" : "<your_custom field_value>"
}
}
]
}
The attribute
:userPointSelector
is used to select the user point on which apply the query. You can provide the following values :// Select a user point using a user_point_id
/v1/datamarts/<DATAMART_ID>/user_points/<USER_POINT_ID>/user_profiles/compartment_id=:compartmentId/user_account_id=:userAccountId
/v1/datamarts/<DATAMART_ID>/user_points/user_point_id=<USER_POINT_ID>/user_profiles/compartment_id=:compartmentId/user_account_id=:userAccountId
// Select a user point using a user_agent_id
/v1/datamarts/<DATAMART_ID>/user_points/user_agent_id=<USER_AGENT_ID>/user_profiles/compartment_id=:compartmentId/user_account_id=:userAccountId
// Select a user point using a user_account_id + compartment_id
/v1/datamarts/<DATAMART_ID>/user_points/compartment_id=<COMPARTMENT_ID>,user_account_id=<USER_ACCOUNT_ID>/user_profiles/compartment_id=:compartmentId/user_account_id=:userAccountId
// Select a user point using an email_hash
/v1/datamarts/<DATAMART_ID>/user_points/email_hash=<EMAIL_HASH>/user_profiles/compartment_id=:compartmentId/user_account_id=:userAccountId
An other way to create / update a user profile is to use the user_profiles API endpoint . Prefer this method if you are able to integrate various API endpoints and if you don't need to track the user profile update as an event for further retrieval.
put
https://api.mediarithmics.com
/v1/datamarts/:datamartId/user_points/:userPointSelector/user_profiles/compartment_id=:compartmentId/user_account_id=:userAccount
Create/Update a user profile
{
"$compartment_id" : ":compartment_id",
"$user_account_id" : ":user_account_id",
"gender" : "female",
"zipcode" : "75001"
}
$compartment_id
& $user_account_id
in the payload are not mandatory since they are already provided as query parameters.Beware of :
<COMPARTMENT_ID>
&<USER_ACCOUNT_ID>
which are used to select the user point:compartmentId
&:userAccountId
which are used to select the profile to update
An other way to create / update a user choice is to use the user_choices API endpoint . Prefer this method if you are able to integrate various API endpoints.
put
https://api.mediarithmics.com
/v1/datamarts/:datamartId/user_points/:userSelector/user_choices/processing_id=:processingId
Create/Update user choices
// Sample payload
{
"$choice_ts": "<a_timestamp (ex:1573135588140)>", // Mandatory
"$choice_acceptance_value":<true/false>, // Mandatory
"<your_custom_field>" : "<your_custom field_value> // Optional
}
get
https://api.mediarithmics.com
/v1/datamarts/:datamartId/user_points/:userSelector/user_choices/processing_id=:processingId
List user choices
get
https://api.mediarithmics.com
/v1/datamarts/:datamartId/user_points/:userSelector/user_choices/processing_id=:processingId/change_log
User choices history
Last modified 1mo ago