Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
# Create the document import
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"document_type": "USER_DEVICE_POINT_DELETION",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'# Create the execution
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '
{ "type": "USER_AGENT", "user_agent_id": "vec:89998434" }
{ "type": "USER_AGENT", "user_agent_id": "udp:987654" }
'{
// Response
}# As explained above, user activities query is always for a particular datamart (1649) & userpoint (dff34408-6cc1-4531-86c5-bac8da9ebac9)
# Retrieve all activities
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities"
# Retrieve all activities for a given channel (4307)
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=$channel_id==4307"
# Retrieve all activities for a given activity type (SITE_VISIT)
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=$type==SITE_VISIT"
# Retrieve all activities for several activity types (SITE_VISIT & APP_VISIT)
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=$type==SITE_VISIT|APP_VISIT"
# Retrieve a given activity (17928440-e72f-11ec-aad0-d12e54ffd215)
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=$unique_key==17928440-e72f-11ec-aad0-d12e54ffd215"
# Retrieve all activities ingested after a particular date (14/06/2022 10:38:47)
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=start_ts==1655195927000"
# Retrieve all activities ingested before a particular date (13/07/2022 13:15:00)
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=end_ts==1657717207000"
# Retrieve all activities ingested between 2 dates (between 14/06/2022 10:38:47 & 13/07/2022 13:15:00)
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=start_ts==1655195927000,end_ts==1657717207000"
# Retrieve all activities ingested between 2 dates for a given channel (between 14/06/2022 10:38:47 & 13/07/2022 13:15:00 for channel 4307)
curl -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=start_ts==1655195927000,end_ts==1657717207000,$channel_id==4307"
# Delete a given activity (17928440-e72f-11ec-aad0-d12e54ffd215)
curl -X DELETE -k -H "Authorization: <MICS_API_KEY>" -H "content-Type: application/json" "https://api.mediarithmics.com/v1/datamarts/1649/user_timelines/dff34408-6cc1-4531-86c5-bac8da9ebac9/user_activities?filters=$unique_key==17928440-e72f-11ec-aad0-d12e54ffd215"
{
"type": "USER_ACCOUNT",
"user_account_id": "mt1-k4LwxGWEn-...........",
"creation_ts": 1770466916312,
"compartment_id": 20,
"expiration_ts": 1778241090397
} {
"$compartment_id": "21",
"$last_modified_ts": 1774049259779,
"$expiration_ts": 1779898252683,
"$creation_ts": 1774049244368,
"$utiq_martechpass_fixed": "mt2-k4LwxGWEn-..........."
}UserPoint
|
|---------UserDevicePoint--------------------------DeviceInfo: PC - CHROME BROWSER
| |---------UserDeviceTechnicalId: 1P cookie
| |---------UserDeviceTechnicalId: Network ID
| |---------UserDeviceTechnicalId: 3P cookie
|
|---------UserDevicePoint--------------------------DeviceInfo: ANDROID TABLET
| |---------UserDeviceTechnicalId: Mobile advertising id
| |---------UserDeviceTechnicalId: Mobile vendor iddevice property of user device pointuser_agent_idmob:ios:raw:12345654-ABCD-1234-A1B2-123456789876
mob:and:raw:12345678-abcd-1234-a1b2-123456789876UserPoint
|
|---------UserAgent: vec:1111--------------------------DeviceInfo: PC - CHROME BROWSER
|
|---------UserAgent: vec:2222--------------------------DeviceInfo: ANDROID TABLET// Browser based agent
{
"vector_id": "vec:12345654321",
"device": {
"form_factor": "SMARTPHONE",
"os_family": "IOS",
"browser_family": "SAFARI",
"browser_version": null,
"brand": null,
"model": null,
"os_version": null,
"carrier": null,
"raw_value": null,
"agent_type": "WEB_BROWSER"
},
"creation_ts": 1591712194234,
"mappings": [
{
"user_agent_id": "tech:goo:Cazrazrkazeeza-azeree9-azezrze",
"realm_name": "GOOGLE_OPERATOR"
},
{
"user_agent_id": "tech:apx:12345654321654321",
"realm_name": "APP_NEXUS_OPERATOR"
}
]
}// Mobile application agent
{
"vector_id": "vec:12345654321",
"device": {
"form_factor": "OTHER",
"os_family": "OTHER",
"browser_family": null,
"browser_version": null,
"brand": null,
"model": null,
"os_version": null,
"carrier": null,
"raw_value": null,
"agent_type": null
},
"creation_ts": 1573405364473,
"mappings": [
{
// IDFA user agent id with raw encoding: mob:ios:raw:6d92078a-8246-4ba4-ae5b-76104861e7dc
// IDFA user agent id with SHA1 encoding: mob:ios:sha1:d520a80c026be39edeb9c6e3f37c01f2da5f5e97
// AAID user agent id with raw encoding: mob:and:raw:97987bca-ae59-4c7d-94ba-ee4f19ab8c21
// AAID user agent id with MD5 encoding: mob:and:md5:ba06c008973b8a1bff6e087c6149227f
"user_agent_id": "mob:ios:raw:12345654-8246-1234-ae5b-123456454654",
}
]
},xtor=A-B-C-D-E-F-G-H{
"$ts": 3489009384393,
"$event_name": "$transaction_confirmed", // Conversion detected
"$properties": {
"$items": [
{
"$id": "product_ID", // Used to filter in funnel analytics
"$qty": 20, // Used for conversion amounts
"$price": 102.8, // Used or conversion amounts
"$brand": "Apple" // Used to filter in funnel analytics
"$category1": "Category 1", // Used to filter in funnel analytics
"$category2": "Category 2", // Used to filter in funnel analytics
"$category3": "Category 3", // Used to filter in funnel analytics
"$category4": "Category 4" // Used to filter in funnel analytics
},
{
"$id": "product_ID2",
"$qty": 12,
"$price": 3.4,
"$brand": "Microsoft"
}
],
"$currency": "EUR"
}
}{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/UserActivity",
"definitions": {
"UserActivity": {
"oneOf": [
{
"$ref": "#/definitions/GenericUserActivity"
},
{
"$ref": "#/definitions/SiteVisitUserActivity"
},
{
"$ref": "#/definitions/AppVisitUserActivity"
},
{
"$ref": "#/definitions/CTVVisitUserActivity"
}
]
},
"GenericUserActivity": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$session_status": {
"$ref": "#/definitions/UserActivitySessionStatus"
},
"$ttl": {
"type": "number"
},
"$user_agent_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$user_account_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$compartment_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$email_hash": {
"$ref": "#/definitions/Nullable%3Calias-1071211137-70767-70920-1071211137-0-212510%3Cdef-interface-792792747-896-1013-792792747-0-7494%2C%22%24type%22%3E%3E"
},
"$user_identifiers": {
"$ref": "#/definitions/Nullable%3Cdef-alias-792792747-1226-1323-792792747-0-7494%5B%5D%3E"
},
"$origin": {
"$ref": "#/definitions/Nullable%3CUserActivityOrigin%3E"
},
"$location": {
"$ref": "#/definitions/Nullable%3CUserActivityLocation%3E"
},
"$unique_key": {
"$ref": "#/definitions/UUID"
},
"$type": {
"type": "string",
"enum": [
"DISPLAY_AD",
"EMAIL",
"TOUCH",
"USER_SCENARIO_START",
"USER_SCENARIO_STOP",
"USER_SCENARIO_NODE_ENTER",
"USER_SCENARIO_NODE_EXIT"
]
},
"$events": {
"type": "array",
"items": {
"$ref": "#/definitions/UserActivityEvent"
}
}
},
"required": [
"$email_hash",
"$events",
"$location",
"$origin",
"$session_status",
"$ts",
"$ttl",
"$type"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"Timestamp": {
"type": "number"
},
"UserActivitySessionStatus": {
"type": "string",
"enum": [
"NO_SESSION",
"IN_SESSION",
"CLOSED_SESSION"
]
},
"Nullable<ID>": {
"anyOf": [
{
"$ref": "#/definitions/ID"
},
{
"type": "null"
}
]
},
"ID": {
"type": "string"
},
"Nullable<alias-1071211137-70767-70920-1071211137-0-212510<def-interface-792792747-896-1013-792792747-0-7494,\"$type\">>": {
"anyOf": [
{
"type": "object",
"properties": {
"$hash": {
"type": "string"
},
"$email": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
}
},
"required": [
"$hash"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"Nullable<string>": {
"type": [
"string",
"null"
]
},
"Nullable<def-alias-792792747-1226-1323-792792747-0-7494[]>": {
"anyOf": [
{
"type": "array",
"items": {
"$ref": "#/definitions/UserIdentifier"
}
},
{
"type": "null"
}
]
},
"UserIdentifier": {
"anyOf": [
{
"$ref": "#/definitions/UserEmailIdentifier"
},
{
"$ref": "#/definitions/UserAccountIdentifier"
},
{
"$ref": "#/definitions/UserAgentIdentifier"
}
]
},
"UserEmailIdentifier": {
"type": "object",
"properties": {
"$type": {
"type": "string",
"const": "USER_EMAIL"
},
"$hash": {
"type": "string"
},
"$email": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
}
},
"required": [
"$type",
"$hash"
],
"additionalProperties": false
},
"UserAccountIdentifier": {
"type": "object",
"properties": {
"$type": {
"type": "string",
"const": "USER_ACCOUNT"
},
"$user_account_id": {
"$ref": "#/definitions/ID"
},
"$compartment_id": {
"$ref": "#/definitions/ID"
}
},
"required": [
"$type",
"$user_account_id",
"$compartment_id"
],
"additionalProperties": false
},
"UserAgentIdentifier": {
"type": "object",
"properties": {
"$type": {
"type": "string",
"const": "USER_AGENT"
},
"$user_agent_id": {
"$ref": "#/definitions/ID"
}
},
"required": [
"$type",
"$user_agent_id"
],
"additionalProperties": false
},
"Nullable<UserActivityOrigin>": {
"anyOf": [
{
"$ref": "#/definitions/UserActivityOrigin"
},
{
"type": "null"
}
]
},
"UserActivityOrigin": {
"type": "object",
"properties": {
"$campaign_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$campaign_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$channel": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$creative_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$creative_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$engagement_content_id": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$gclid": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$keywords": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$log_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$message_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$message_technical_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$referral_path": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$social_network": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$source": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$sub_campaign_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$sub_campaign_technical_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$ts": {
"type": "number"
}
},
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"Nullable<number>": {
"type": [
"number",
"null"
]
},
"JsonType": {
"anyOf": [
{
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
{
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
{
"type": "boolean"
},
{
"type": "object"
},
{
"type": "array",
"items": {}
},
{
"not": {}
}
]
},
"Nullable<UserActivityLocation>": {
"anyOf": [
{
"$ref": "#/definitions/UserActivityLocation"
},
{
"type": "null"
}
]
},
"UserActivityLocation": {
"type": "object",
"properties": {
"$source": {
"$ref": "#/definitions/LocationSource"
},
"$country": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$region": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$iso_region": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$city": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$iso_city": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$zip_code": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$latlon": {
"$ref": "#/definitions/Nullable%3Cnumber%5B%5D%3E"
}
},
"required": [
"$latlon"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"LocationSource": {
"type": "string",
"enum": [
"GPS",
"IP",
"OTHER"
]
},
"Nullable<number[]>": {
"anyOf": [
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "null"
}
]
},
"UUID": {
"type": "string",
"pattern": "^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$"
},
"UserActivityEvent": {
"anyOf": [
{
"$ref": "#/definitions/GenericUserActivityEvent"
},
{
"$ref": "#/definitions/AdTrackingEvent"
},
{
"$ref": "#/definitions/SetUserChoiceEvent"
},
{
"$ref": "#/definitions/SetUserProfilePropertiesEvent"
},
{
"$ref": "#/definitions/RetailEvent"
},
{
"$ref": "#/definitions/ConversionEvent"
}
]
},
"GenericUserActivityEvent": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$expiration_ts": {
"$ref": "#/definitions/Nullable%3CTimestamp%3E"
},
"$event_name": {
"anyOf": [
{
"$ref": "#/definitions/EventName"
},
{
"type": "string"
}
]
},
"$properties": {
"$ref": "#/definitions/Customizable"
}
},
"required": [
"$event_name",
"$properties",
"$ts"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"Nullable<Timestamp>": {
"anyOf": [
{
"$ref": "#/definitions/Timestamp"
},
{
"type": "null"
}
]
},
"EventName": {
"anyOf": [
{
"$ref": "#/definitions/DefaultEventName"
},
{
"type": "string"
}
]
},
"DefaultEventName": {
"type": "string",
"enum": [
"$page_view",
"$home_view",
"$category_view",
"$email_view",
"$email_click",
"$email_sent",
"$email_delivered",
"$email_soft_bounce",
"$email_hard_bounce",
"$email_unsubscribe",
"$email_complaint",
"$content_corrections"
]
},
"Customizable": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"AdTrackingEvent": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$expiration_ts": {
"$ref": "#/definitions/Nullable%3CTimestamp%3E"
},
"$event_name": {
"type": "string",
"enum": [
"$ad_view",
"$ad_click"
]
},
"$properties": {
"$ref": "#/definitions/AdTrackingEventProperties"
}
},
"required": [
"$event_name",
"$properties",
"$ts"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"AdTrackingEventProperties": {
"type": "object",
"properties": {
"$url": {
"type": "string"
},
"$referrer": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$campaign_technical_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$sub_campaign_technical_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$creative_technical_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$message_technical_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$campaign_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$sub_campaign_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$message_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$creative_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
}
},
"additionalProperties": {
"$ref": "#/definitions/JsonType"
},
"required": [
"$url"
]
},
"SetUserChoiceEvent": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$expiration_ts": {
"$ref": "#/definitions/Nullable%3CTimestamp%3E"
},
"$event_name": {
"type": "string",
"const": "$set_user_choice"
},
"$properties": {
"$ref": "#/definitions/SetUserChoiceEventProperties"
}
},
"required": [
"$event_name",
"$properties",
"$ts"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"SetUserChoiceEventProperties": {
"type": "object",
"properties": {
"$url": {
"type": "string"
},
"$referrer": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$processing_token": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$processing_id": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$choice_acceptance_value": {
"type": "boolean"
},
"$choice_source_id": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
}
},
"required": [
"$choice_acceptance_value",
"$url"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"SetUserProfilePropertiesEvent": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$expiration_ts": {
"$ref": "#/definitions/Nullable%3CTimestamp%3E"
},
"$event_name": {
"type": "string",
"const": "$set_user_profile_properties"
},
"$properties": {
"$ref": "#/definitions/Customizable"
}
},
"required": [
"$event_name",
"$properties",
"$ts"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"RetailEvent": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$expiration_ts": {
"$ref": "#/definitions/Nullable%3CTimestamp%3E"
},
"$event_name": {
"$ref": "#/definitions/RetailEventName"
},
"$properties": {
"$ref": "#/definitions/RetailEventProperties"
}
},
"required": [
"$event_name",
"$properties",
"$ts"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"RetailEventName": {
"type": "string",
"enum": [
"$item_view",
"$item_list_view",
"$product_view",
"$product_list_view",
"$basket_view",
"$transaction_confirmed"
]
},
"RetailEventProperties": {
"type": "object",
"properties": {
"$url": {
"type": "string"
},
"$referrer": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$items": {
"$ref": "#/definitions/Nullable%3Cdef-interface-792792747-3521-3897-792792747-0-7494%5B%5D%3E"
}
},
"additionalProperties": {
"$ref": "#/definitions/JsonType"
},
"required": [
"$url"
]
},
"Nullable<def-interface-792792747-3521-3897-792792747-0-7494[]>": {
"anyOf": [
{
"type": "array",
"items": {
"$ref": "#/definitions/RetailEventPropertiesItem"
}
},
{
"type": "null"
}
]
},
"RetailEventPropertiesItem": {
"type": "object",
"properties": {
"$id": {
"type": "string"
},
"$ean": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$qty": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$price": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$brand": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$category1": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$category2": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$category3": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$category4": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
}
},
"required": [
"$id"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"ConversionEvent": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$expiration_ts": {
"$ref": "#/definitions/Nullable%3CTimestamp%3E"
},
"$event_name": {
"type": "string",
"const": "$conversion"
},
"$properties": {
"$ref": "#/definitions/ConversionEventProperties"
}
},
"required": [
"$event_name",
"$properties",
"$ts"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"ConversionEventProperties": {
"type": "object",
"properties": {
"$conversion_id": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$goal_id": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$conversion_technical_id": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$goal_technical_id": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$conversion_value": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$log_id": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$conversion_external_id": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
},
"$goal_technical_name": {
"$ref": "#/definitions/Nullable%3Cstring%3E"
}
},
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"SiteVisitUserActivity": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$session_status": {
"$ref": "#/definitions/UserActivitySessionStatus"
},
"$ttl": {
"type": "number"
},
"$user_agent_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$user_account_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$compartment_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$email_hash": {
"$ref": "#/definitions/Nullable%3Calias-1071211137-70767-70920-1071211137-0-212510%3Cdef-interface-792792747-896-1013-792792747-0-7494%2C%22%24type%22%3E%3E"
},
"$user_identifiers": {
"$ref": "#/definitions/Nullable%3Cdef-alias-792792747-1226-1323-792792747-0-7494%5B%5D%3E"
},
"$origin": {
"$ref": "#/definitions/Nullable%3CUserActivityOrigin%3E"
},
"$location": {
"$ref": "#/definitions/Nullable%3CUserActivityLocation%3E"
},
"$unique_key": {
"$ref": "#/definitions/UUID"
},
"$session_duration": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$error_analyzer_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$analyzer_errors": {
"type": "array",
"items": {
"type": "object"
}
},
"$topics": {
"$ref": "#/definitions/Nullable%3Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Cnumber%3E%3E%3E"
},
"$type": {
"type": "string",
"const": "SITE_VISIT"
},
"$events": {
"type": "array",
"items": {
"$ref": "#/definitions/UserActivityEvent"
}
},
"$site_id": {
"$ref": "#/definitions/ID"
}
},
"required": [
"$email_hash",
"$events",
"$location",
"$origin",
"$session_status",
"$site_id",
"$ts",
"$ttl",
"$type"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"Nullable<alias-1071211137-70404-70537-1071211137-0-212510<string,alias-1071211137-70404-70537-1071211137-0-212510<string,number>>>": {
"anyOf": [
{
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "number"
}
}
},
{
"type": "null"
}
]
},
"AppVisitUserActivity": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$session_status": {
"$ref": "#/definitions/UserActivitySessionStatus"
},
"$ttl": {
"type": "number"
},
"$user_agent_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$user_account_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$compartment_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$email_hash": {
"$ref": "#/definitions/Nullable%3Calias-1071211137-70767-70920-1071211137-0-212510%3Cdef-interface-792792747-896-1013-792792747-0-7494%2C%22%24type%22%3E%3E"
},
"$user_identifiers": {
"$ref": "#/definitions/Nullable%3Cdef-alias-792792747-1226-1323-792792747-0-7494%5B%5D%3E"
},
"$origin": {
"$ref": "#/definitions/Nullable%3CUserActivityOrigin%3E"
},
"$location": {
"$ref": "#/definitions/Nullable%3CUserActivityLocation%3E"
},
"$unique_key": {
"$ref": "#/definitions/UUID"
},
"$session_duration": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$error_analyzer_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$analyzer_errors": {
"type": "array",
"items": {
"type": "object"
}
},
"$topics": {
"$ref": "#/definitions/Nullable%3Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Cnumber%3E%3E%3E"
},
"$type": {
"type": "string",
"const": "APP_VISIT"
},
"$events": {
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserActivityEvent"
},
{
"$ref": "#/definitions/AppActivityEvent"
}
]
}
},
"$app_id": {
"$ref": "#/definitions/ID"
}
},
"required": [
"$app_id",
"$email_hash",
"$events",
"$location",
"$origin",
"$session_status",
"$ts",
"$ttl",
"$type"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"CTVVisitUserActivity": {
"type": "object",
"properties": {
"$ts": {
"$ref": "#/definitions/Timestamp"
},
"$session_status": {
"$ref": "#/definitions/UserActivitySessionStatus"
},
"$ttl": {
"type": "number"
},
"$user_agent_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$user_account_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$compartment_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$email_hash": {
"$ref": "#/definitions/Nullable%3Calias-1071211137-70767-70920-1071211137-0-212510%3Cdef-interface-792792747-896-1013-792792747-0-7494%2C%22%24type%22%3E%3E"
},
"$user_identifiers": {
"$ref": "#/definitions/Nullable%3Cdef-alias-792792747-1226-1323-792792747-0-7494%5B%5D%3E"
},
"$origin": {
"$ref": "#/definitions/Nullable%3CUserActivityOrigin%3E"
},
"$location": {
"$ref": "#/definitions/Nullable%3CUserActivityLocation%3E"
},
"$unique_key": {
"$ref": "#/definitions/UUID"
},
"$session_duration": {
"$ref": "#/definitions/Nullable%3Cnumber%3E"
},
"$error_analyzer_id": {
"$ref": "#/definitions/Nullable%3CID%3E"
},
"$analyzer_errors": {
"type": "array",
"items": {
"type": "object"
}
},
"$topics": {
"$ref": "#/definitions/Nullable%3Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Cnumber%3E%3E%3E"
},
"$type": {
"type": "string",
"const": "CTV_VISIT"
},
"$events": {
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/UserActivityEvent"
},
{
"$ref": "#/definitions/AppActivityEvent"
}
]
}
},
"$ctv_id": {
"$ref": "#/definitions/ID"
}
},
"required": [
"$ctv_id",
"$email_hash",
"$events",
"$location",
"$origin",
"$session_status",
"$ts",
"$ttl",
"$type"
],
"additionalProperties": {
"$ref": "#/definitions/JsonType"
}
},
"AppActivityEvent": {
"type": "object",
"properties": {
"$event_name": {
"type": "string",
"enum": [
"$app_open",
"$app_update",
"$app_install"
]
},
"$properties": {
"$ref": "#/definitions/Customizable"
}
},
"required": [
"$event_name",
"$properties"
],
"additionalProperties": false
}
}
}
# UserProfile object
{
"$compartment_id": 1606,
"$user_account_id": "c9879698769OIUYOIY9879879",
"$last_modified_ts": 5467987654613,
"$creation_ts": 6579874654654654,
"firstname": "David",
"lastname": "Guetta",
"gender": 1,
"newsletter_options": {
"subscribed": true,
"preferred_periods": "MONTHLY"
}
}# Complete payload when importing a profile
{
"operation": "UPSERT",
"compartment_id": "1600",
"user_account_id": "identifier_account_id",
"force_replace": true,
"user_profile": {
"$compartment_id": 1606,
"$user_account_id": "c9879698769OIUYOIY9879879",
"$last_modified_ts": 5467987654613,
"$creation_ts": 6579874654654654,
"firstname": "David",
"lastname": "Guetta",
"gender": 1,
"newsletter_options": {
"subscribed": true,
"preferred_periods": "MONTHLY"
}
}
}# Create the document import
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"document_type": "USER_IDENTIFIERS_DELETION",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'# Create the execution
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/1162/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '
{
"type": "USER_ACCOUNT",
"compartment_id": "1000",
"user_account_id": "8541254132"
}
{
"type": "USER_EMAIL",
"hash": "982f50d88d437d13bdbd541edfv4fe5176cc8d862f8cbe7ca4f0dc8ea"
}
{ "type": "USER_AGENT", "user_agent_id": "vec:89998434" }
'{
"type": "USER_ACCOUNT",
"compartment_id": "1000",
"user_account_id": "8541254132"
}{
"type": "USER_EMAIL",
"hash": "982f50d88d437d13bdbd541edfv4fe5176cc8d862f8cbe7ca4f0dc8ea"
}{ "type": "USER_AGENT", "user_agent_id": "vec:89998434" }{
"$ts": 3489009384393,
"$event_name": "$transaction_confirmed", // Conversion detected
"$properties": {
"$items": [
{
"$id": "product_ID", // Used to filter in funnel analytics
"$qty": 20, // Used for conversion amounts
"$price": 102.8, // Used or conversion amounts
"$brand": "Apple" // Used to filter in funnel analytics
"$category1": "Category 1", // Used to filter in funnel analytics
"$category2": "Category 2", // Used to filter in funnel analytics
"$category3": "Category 3", // Used to filter in funnel analytics
"$category4": "Category 4" // Used to filter in funnel analytics
},
{
"$id": "product_ID2",
"$qty": 12,
"$price": 3.4,
"$brand": "Microsoft"
}
],
"$currency": "EUR"
}
}{
"id": 15, // Read only
"datamart_id": "3333", // Read only
"created_ts": <>, // Read only
"created_by": <>, // Read only
"last_modified_by": <>, // Read only
"last_modified_ts": <>, // Read only
"channel_id": "8888",
"source_event_name": "order",
"target_event_name": "$transaction_confirmed",
"mapping_id": 15
}// Comments are here to help you understand,
// remove them before uploading mappings as they are not accepted in JSON
{
"id": 17, // Read only
"created_by": <>, // Read only
"created_ts": <>, // Read only
"mapping": {
"values": [
{
// Maps $properties.order.order_products[] to $items[]
"target_attribute_name": "$items",
"source_attribute_path": {
"attribute_name": "$properties",
"sub_path": {
"attribute_name": "order",
"sub_path": {
"attribute_name": "order_products"
}
}
},
// Alternative : mapping directly $properties if there are no multiple
// elements in the event. It will be treated as an array of only one item
"target_attribute_name": "$items",
"source_attribute_path": {
"attribute_name": "$properties"
},
// Maps $properties.order.order_products.xxx to $items.xxx
// You can't use other target attributes than the ones
// in this example.
// But they are not all mandatory : a non used target
// attribute will use the default value
"children": [
// $properties.order.order_products.product.id
// becomes $items.$id
// to be used by analytics database
{
"target_attribute_name": "$id",
"source_attribute_path": {
"attribute_name": "product",
"sub_path": {
"attribute_name": "id"
}
}
},
// $properties.order.order_products.qty
// becomes $items.$qty
// to be used by analytics database
{
"target_attribute_name": "$qty",
"source_attribute_path": {
"attribute_name": "qty"
}
},
{
"target_attribute_name": "$price",
"source_attribute_path": {
"attribute_name": "price"
}
},
{
"target_attribute_name": "$ean",
"source_attribute_path": {
"attribute_name": "ean",
}
},
{
"target_attribute_name": "$brand",
"source_attribute_path": {
"attribute_name": "brand",
}
},
{
"target_attribute_name": "$category1",
"source_attribute_path": {
"attribute_name": "cat1"
}
},
{
// In this example $category2 will be
// event.$event_name instead of
// $properties.order.order_products[].$event_name
// thanks to absolute_path
"target_attribute_name": "$category2",
"source_attribute_path": {
"absolute_path": true,
"attribute_name": "$event_name",
}
},
{
"target_attribute_name": "$category3",
"source_attribute_path": {
"attribute_name": "cat3"
}
},
{
"target_attribute_name": "$category4",
"source_attribute_path": {
"attribute_name": "cat4"
}
}
]
}
]
}
}{
"status": "ok",
"data": [
{
"datamart_id": ":datamartId",
"channel_id": "8888",
"source_event_name": "order",
"target_event_name": "$transaction_confirmed",
"mapping_id": xxx
},
{
...
}
]
}{
"status": "ok",
"data": {
id: 17,
created_by: <>
...
}
}{
"status": "ok"
}{
"status": "error",
"error": "Deleting a property mapping used in a transformation is forbidden",
"error_code": "BAD_REQUEST_DATA",
"error_id": "9460be23-0f80-4acb-9a33-dd8a1c5d08a9"
}SELECT @count{} FROM UserPoint WHERE
events {
nature = "$transaction_confirmed" and
date >= $date
and products {brand in $brand and name in $name}
}{
"first_result": 0,
"count": 0,
"max_results": 0,
"status": "ok",
"data": [
{
"id": "string",
"children_ids": [
"string"
],
"audience_features_ids": [
"string"
],
"parent_id": "string",
"datamart_id": "string",
"name": "string"
}
],
"total": 0
}{
"status": "ok",
"data": {
"id": "string",
"children_ids": [
"string"
],
"audience_features_ids": [
"string"
],
"parent_id": "string",
"datamart_id": "string",
"name": "string"
}
}// Create a folder payload
{
"children_ids": [
"string"
],
"audience_features_ids": [
"string"
],
"parent_id": "string",
"datamart_id": "string",
"name": "string"
}{
"status": "ok",
"data": {
"id": "string",
"children_ids": [
"string"
],
"audience_features_ids": [
"string"
],
"parent_id": "string",
"datamart_id": "string",
"name": "string"
}
}// Editing a folder payload
{
"children_ids": [
"string"
],
"audience_features_ids": [
"string"
],
"parent_id": "string",
"datamart_id": "string",
"name": "string"
}{
"first_result": 0,
"total": 0,
"count": 0,
"data": [
{
"object_tree_expression": "string",
"description": "string",
"id": "string",
"variables": [
{
"field_name": "string",
"data_type": "string",
"reference_model_type": "string",
"type": "string",
"parameter_name": "string",
"path": [
"string"
],
"reference_type": "string",
"directive": "string",
"container_type": "string"
}
],
"token": "string",
"datamart_id": "string",
"addressable_object": "string",
"name": "string",
"folder_id": "string",
"creation_date": 0
}
],
"max_results": 0,
"status": "ok"
}{
"status": "ok",
"data": {
"object_tree_expression": "string",
"description": "string",
"id": "string",
"variables": [
{
"field_name": "string",
"data_type": "string",
"reference_model_type": "string",
"type": "string",
"parameter_name": "string",
"path": [
"string"
],
"reference_type": "string",
"directive": "string",
"container_type": "string"
}
],
"token": "string",
"datamart_id": "string",
"addressable_object": "string",
"name": "string",
"folder_id": "string",
"creation_date": 0
}
}{
"status": "ok",
"data": {
"object_tree_expression": "string",
"description": "string",
"id": "string",
"variables": [
{
"field_name": "string",
"data_type": "string",
"reference_model_type": "string",
"type": "string",
"parameter_name": "string",
"path": [
"string"
],
"reference_type": "string",
"directive": "string",
"container_type": "string"
}
],
"token": "string",
"datamart_id": "string",
"addressable_object": "string",
"name": "string",
"folder_id": "string",
"creation_date": 0
}
}// Creating an audience feature payload
{
"object_tree_expression": "string",
"description": "string",
"datamart_id": "string",
"addressable_object": "string",
"name": "string",
"folder_id": "string"
}{
"status": "ok",
"data": {
"object_tree_expression": "string",
"description": "string",
"id": "string",
"variables": [
{
"field_name": "string",
"data_type": "string",
"reference_model_type": "string",
"type": "string",
"parameter_name": "string",
"path": [
"string"
],
"reference_type": "string",
"directive": "string",
"container_type": "string"
}
],
"token": "string",
"datamart_id": "string",
"addressable_object": "string",
"name": "string",
"folder_id": "string",
"creation_date": 0
}
}// Editing an audience feature payload
{
"object_tree_expression": "string",
"description": "string",
"datamart_id": "string",
"addressable_object": "string",
"name": "string",
"folder_id": "string"
}// The gender will be selectable by the user
SELECT @count{} FROM UserPoint
where profiles {gender in $gender}
// The date will be selectable by the user,
// but the nature will always be $transaction_confirmed
SELECT @count{} FROM UserPoint
where events { nature = "$transaction_confirmed" and date >= $date }
// User will only be able to select one gender
SELECT @count{} FROM UserPoint
where profiles {gender == $gender}
// User will be able to select multiple gender values
SELECT @count{} FROM UserPoint
where profiles {gender in $gender}// User will be able to select the minimum number of transactions
SELECT @count{} FROM UserPoint
WHERE events@ScoreSum(min: $frequency) {
purchase in $user_purchase
}

$category2$category3$category4$items.$category1, $items.$category2, $items.$category3 and $items.$category4 : for the categorization in funnel analytics
/<DOCUMENT_TYPE>/<DOCUMENT_SELECTOR><USER_POINT_ID> or user_point_id=<USER_POINT_ID>
user_agent_id=<USER_AGENT_ID>
compartment_id=<COMPARTMENT_ID>,user_account_id=<USER_ACCOUNT_ID>
email_hash=<EMAIL_HASH>user_identifiers
user_profiles
user_activities
user_choices
user_scenarios
user_segmentsuser_profiles/compartment_id=<COMPARTMENT_ID>
user_profiles/compartment_id=<COMPARTMENT_ID>/user_account_id=<USER_ACCOUNT_ID>
user_choices/processing_id=<PROCESSING_ID>
user_scenarios/scenario_id=<SCENARIO_ID>
user_segments/audience_segment_id=<SEGMENT_ID>{h,w,x,y}
<amp-analytics type="mediarithmics">
<script type="application/json">
{
"vars": {
"site_token": <SITE_TOKEN>,
"event_name": "amp-test-pageview"
},
"extraUrlParams": {
"prop1": "value1",
"prop2": "value2"
}
}
</script>
</amp-analytics>
// With standard directives
SELECT { id } FROM UserPoint
WHERE activity_events @ScoreSum(min : 100) {
basket {
items @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="IT" AND date >= "now-3M/M"
}
}
}//With a COmputed field "IT_amount_3months"
SELECT { id } FROM UserPoint WHERE IT_amount_3months >= 100# Create the document import
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"document_type": "USER_ACTIVITY",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'# Create the execution
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/1162/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '{ "$user_agent_id": "<USER_AGENT_ID>", "$type":"TOUCH","$session_status":"NO_SESSION","$ts":<TIMESTAMP>,"$events":[{"$event_name":"$email_mapping","$ts":<TIMESTAMP>,"$properties":{}}]}'# Create the document import
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"document_type": "USER_POINTS_DELETION",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'# Create the execution
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '
{
"type": "USER_ACCOUNT",
"compartment_id": "1000",
"user_account_id": "8541254132"
}
{
"type": "USER_EMAIL",
"hash": "982f50d88d437d13bdbd541edfv4fe5176cc8d862f8cbe7ca4f0dc8ea"
}
{ "type": "USER_AGENT", "user_agent_id": "vec:89998434" }
{ "type": "USER_AGENT", "user_agent_id": "udp:987654" }
{ "type": "USER_POINT", "user_point_id": "95772db3-e762-45da-8cf1-4893debffae7" }
'Schema decorators allow you to customize how your graph appear within the mediarithmics platform interfaces, specifically the Advanced Segment Builder and the Query Tool.
{
// Using technical names of compartments, segments or channels
// will result in IDs being automatically replaced by names in the UI
"technical_name": String,
"title": String,
"values_retrieve_method": 'Query', // Only available value at the moment
// OTQL query to retrieve list of selectable values
// Use a query string, not the ID of a query
"values_query": String,
// How to adapt queries in the dashboard to the selected value(s)
"query_fragments": [QueryFragment],
"multi_select": Boolean, // If the user can select multiple values
}{
// Any available data source such as 'activities_analytics' or 'OTQL'
"type": String,
// Only for OTQL type, chooses which queries should be transformed
// Select 'ActivityEvent' to transform queries FROM ActivityEvent
"starting_object_type": String,
// The query part to add
"fragment": String,
}{
"available_filters": [
{
"values_retrieve_method": "query",
"values_query": "SELECT {compartment_id @map} FROM UserProfile",
"technical_name": "compartments",
"query_fragments": [
{
"type": "OTQL",
"starting_object_type": "UserPoint",
"fragment": "profiles {compartment_id IN $values}"
},
{
"type": "OTQL",
"starting_object_type": "UserProfile",
"fragment": "compartment_id IN $values"
}
],
"multi_select": true,
"title": "Data provider"
},
{
"values_retrieve_method": "query",
"values_query": "SELECT {channel_id @map} FROM UserEvent",
"technical_name": "channels",
"query_fragments": [
{
"type": "OTQL",
"starting_object_type": "UserPoint",
"fragment": "events {channel_id IN $values}"
},
{
"type": "OTQL",
"starting_object_type": "UserEvent",
"fragment": "channel_id IN $values"
},
{
"type": "activities_analytics",
"fragment": [
{
"dimension_name": "channel_id",
"operator": "IN_LIST",
"not": false,
"expressions": "$values"
}
]
}
],
"multi_select": true,
"title": "Channels"
}
],
"sections": ...
}



OBJECT_NAME,FIELD_NAME,HIDDEN,LABEL,HELP_TEXT,LOCALE
UserPoint,id,false,User ID,Unique identifier for the user point,en-US
UserPoint,technical_hash,true,,,en-US
UserEvent,subcategory,false,Subcategory,The specific sub-category of the event,en-US
UserEvent,subcategory_id,true,,,en-US
UserEvent,title,false,Event Title,The main title or headline of the event,en-US
UserEvent,region,false,Region,The geographic region associated with the event,en-UScurl -H "Authorization:$MICS_API_TOKEN" \
-X GET \
--location "https://api.mediarithmics.com/v1/datamarts/$DATAMART_ID/graphdb_runtime_schemas/$SCHEMA_ID/schema_decorators"curl -H "Authorization:$MICS_API_TOKEN" \
-X PUT \
--location "https://api.mediarithmics.com/v1/datamarts/$DATAMART_ID/graphdb_runtime_schemas/$SCHEMA_ID/schema_decorators" \
--data-raw "$(cat path/to/schema_decorators.csv)"// Trigger by a new activity
onUpdateActivity(state, userActivity) {
// Logic to update state
return updatedState;
}// Trigger by an update on the UserProfile
onUpdateUserProfile(state, userProfile, operation) {
// Logic to handle UserProfile updates
return updatedState;
}// Trigger by the result computation of another computed field
onUpdateComputedFields(state) {
// Logic to compute result
return state;
}buildResult(state) {
// Logic to compute result
return result;
}CREATE SCHEMA IF NOT EXISTS `project-name.mediarithmics_dataset`
OPTIONS (
location = 'EU',
description = 'Working schema mediarithmics'
);export interface State {
activities_for_the_last_12 _months: {
[date: number] : [{
amount: number;
}]
}
}export interface Result {
IT_amount_for_the_last_12_months: number;
}interface Items {
category: string;
price: number;
}
interface UserActivity {
items_bought: Items[];
}export class MyComputedField extends core.ComputedFieldPlugin<State, Result, UserActivity, UserProfile, ComputedField> {
constructor() {
super();
}
// Function to Update the state
onUpdateActivity(state: State, userActivity: UserActivity): State { ... }
// Won't be used but need to be declared;
onUpdateUserProfile(state: State, userProfile: UserProfile, operation: core.Operation): State {
return state;
}
// Won't be used but need to be declared;
onUpdateComputedField(state: State, computedField: ComputedField): State {
return state;
}
// Function to compute the Result
buildResult(state: State | null): Result { ... }
}type UserPoint {
id: ID!
accounts: [UserAccount]
…
IT_amount_for_the_last_12_months: Int! @ComputedField(technical_name = “IT_Amount”) @TreeIndex(index:"USER_INDEX")
}-- =============================================================
-- Setup variables - update these values for your environment
-- =============================================================
SET mics_username = 'MICS_USER';
SET mics_default_warehouse = '<warehouse>';
SET mics_database = '<database>';
SET mics_default_namespace = '<database.schema>';
SET mics_default_role = 'MICS_ROLE';
-- =============================================================
-- Switch to admin role
-- =============================================================
USE ROLE ACCOUNTADMIN;
-- =============================================================
-- Provision resources: warehouse, role and service user
-- =============================================================
CREATE WAREHOUSE IF NOT EXISTS identifier($mics_default_warehouse);
CREATE ROLE IF NOT EXISTS identifier($mics_default_role);
CREATE USER IF NOT EXISTS identifier($mics_username)
TYPE = SERVICE
DEFAULT_WAREHOUSE = $mics_default_warehouse
DEFAULT_NAMESPACE = $mics_default_namespace
DEFAULT_ROLE = $mics_default_role;
-- =============================================================
-- Role assignments
-- =============================================================
GRANT ROLE identifier($mics_default_role) TO ROLE SYSADMIN;
GRANT ROLE identifier($mics_default_role) TO USER identifier($mics_username);
-- =============================================================
-- Warehouse access
-- =============================================================
GRANT USAGE ON WAREHOUSE identifier($mics_default_warehouse) TO ROLE identifier($mics_default_role);
-- =============================================================
-- Read-only access on the database, schemas, tables and views
-- (includes future objects to cover tables/views created later)
-- =============================================================
GRANT USAGE ON DATABASE identifier($mics_database) TO ROLE identifier($mics_default_role);
GRANT USAGE ON ALL SCHEMAS IN DATABASE identifier($mics_database) TO ROLE identifier($mics_default_role);
GRANT SELECT ON ALL TABLES IN DATABASE identifier($mics_database) TO ROLE identifier($mics_default_role);
GRANT SELECT ON ALL VIEWS IN DATABASE identifier($mics_database) TO ROLE identifier($mics_default_role);
GRANT SELECT ON FUTURE TABLES IN DATABASE identifier($mics_database) TO ROLE identifier($mics_default_role);
GRANT SELECT ON FUTURE VIEWS IN DATABASE identifier($mics_database) TO ROLE identifier($mics_default_role);
-- =============================================================
-- Dedicated schema with full ownership
-- =============================================================
USE identifier($mics_database);
CREATE SCHEMA IF NOT EXISTS mediarithmics_schema;
GRANT OWNERSHIP ON SCHEMA mediarithmics_schema TO ROLE identifier($mics_default_role);openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocryptopenssl rsa -in rsa_key.p8 -pubout -out rsa_key.pubALTER USER <MICS_USER> SET RSA_PUBLIC_KEY='MIIBIjANBgkqh...';{
"user" : "MICS_USER",
"account" : "ORGANIZATION_NAME-ACCOUNT_NAME",
"database" : "DATABASE",
"private_key" : "-----BEGIN PRIVATE KEY-----\nMII..."
}

// Example in your schema
type UserPoint {
id: ID!
accounts: [UserAccount]
…
rfm_score: RfmScore @ComputedField(technical_name = “RfmScore”) @TreeIndex(index:"USER_INDEX")
}
type RfmScore {
…
}SELECT { rfm_score } FROM UserPointSELECT { id } FROM UserPoint WHERE rfm_score = "PASSIVE"# Create the document import
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"document_type": "USER_CHOICE",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'# Create the execution
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/1162/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '{
"operation": "UPSERT",
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"force_replace": true,
"user_choice": {
"$processing_id": "<PROCESSING_ID>",
"$choice_ts": "<CHOICE_TS>"
}
}'
import-data-for-customer# Create the plugin definition
curl -X POST \
https://api.mediarithmics.com/v1/plugins \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"organisation_id": "my_organisation_id",
"plugin_type": "INTEGRATION_BATCH",
"group_id": "com.my-client.integration_batch",
"artifact_id": "integration-batch-my-client"
}'# Create the plugin version
curl -X POST \
https://api.mediarithmics.com/v1/plugins/<PLUGIN_ID>/versions \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"version_id":"1.0.0",
"plugin_properties":[
{
"technical_name": "one_more_property",
"value": {
"value": ""
},
"property_type": "STRING",
"origin": "PLUGIN",
"writable": true,
"deletable": true
},
{
"technical_name": "provider",
"value": {
"value": "mediarithmics"
},
"property_type": "STRING",
"origin": "PLUGIN_STATIC",
"writable": false,
"deletable": false
},
{
"technical_name": "name",
"value": {
"value": "My Plugin Name"
},
"property_type": "STRING",
"origin": "PLUGIN_STATIC",
"writable": false,
"deletable": false
}
]
}'# Create the plugin instance
curl -X POST \
https://api.mediarithmics.com/v1/integration_batch_instances \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"group_id": "com.my-client.integration_batch",
"artifact_id": "integration-batch-my-client",
"version_id": "my-version-id",
"organisation_id": "my-plugin-id",
"name": "The name of my instance",
"archived": false,
"cron" :"* * * 7 *",
"cron_status": "ACTIVE | PAUSED",
"ram_size": "LOW | MEDIUM | LARGE | EXTRA_LARGE",
"disk_size": "LOW | MEDIUM | LARGE | EXTRA_LARGE",
"cpu_size": "LOW | MEDIUM | LARGE | EXTRA_LARGE"
}'// Create an execution
curl -X POST \
https://api.mediarithmics.com/v1/integration_batch_instances/<INSTANCE_ID>/executions \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"parameters": {
execution_type: "MANUAL | CRON",
expected_start_date: 1562595783663
},
"organisation_id": "1185",
"user_id": "1007",
"error": null,
"status": "PENDING",
"external_model_id: "42",
"external_model_name": "PUBLIC_INTEGRATION_BATCH",
"start_date": 1562595789171,
"job_type": "BATCH_INTEGRATION",
}
# Create the document import
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"document_type": "USER_SEGMENT",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'# Create the execution
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '{
"operation": "UPDATE",
"expiration_duration": <INTEGER>,
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"segment_id": "<SEGMENT_ID>"
}'# Create the document import
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"document_type": "USER_IDENTIFIERS_ASSOCIATION_DECLARATIONS",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'# Create the execution
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/1162/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '
{
"identifiers":[
{ "type": "USER_EMAIL", "hash":"<EMAIL_HASH>" },
{ "type": "USER_AGENT", "user_agent_id": "<USER_AGENT_ID>" },
{ "type": "USER_ACCOUNT", "user_account_id": "<USER_ACCOUNT_ID>", "compartment_id": "<COMPARTMENT_ID>" }
]
}
'{
"datamart_id": {{datamartId}},
"query_language": "OTQL",
"query_text": "select @count{} FROM UserPoint"
}{
"datamart_id": {{datamartId}},
"query_language": "OTQL",
"query_text": "SELECT {agents {user_agent_info{form_factor @map}}} FROM UserPoint"
}{
"title": "My awesome dashboards",
"scopes": [
"home"
],
"segment_ids": [],
"builder_ids": [],
"archived": false,
"organisation_id": "{{orgId}}",
"community_id": "{{communityId}}"
}{
"sections": [
{
"title": "",
"cards": [
{
"x": 0,
"y": 0,
"h": 3,
"layout": "vertical",
"w": 8,
"charts": [
{
"title": "User points",
"type": "Metric",
"dataset": {
"type": "OTQL",
"query_id": "{{ID of query 1}}"
}
},
{
"title": "Device form factors",
"type": "Bars",
"dataset": {
"type": "OTQL",
"query_id": "{{ID of query 2}}"
},
"options": {}
}
]
}
]
}
]
}This page demonstrates different useful queries that can be handled through the activities analytics API
{
"date_ranges": [
{
"start_date": "2021-09-26T00:00:00",
"end_date": "2021-10-28T23:59:59"
}
],
"dimensions": [],
"metrics": [
{
"expression": "users"
}
]
} "report_view": {
"items_per_page": 100,
"total_items": 1,
"columns_headers": [
"users"
],
"rows": [
[
114353272
]
]
}{
"date_ranges": [
{
"start_date": "2021-10-20T00:00:00",
"end_date": "2021-10-28T23:59:59"
}
],
"dimensions": [
{"name": "date_yyyymmdd"}
],
"metrics": [
{
"expression": "sessions"
}
]
} "report_view": {
"items_per_page": 100,
"total_items": 9,
"columns_headers": [
"date_yyyymmdd",
"sessions"
],
"rows": [
[
"20211020",
1372624
],
[
"20211021",
1368085
],
...
]
}Bars chartPie chart with legend {
"title": "Device form factors", // Could be an empty string
"type": "Bars", // Bars || Pie || Metric || Radar
"dataset": { // See Datasets and datasources page
"type": "OTQL",
"query_id": "50171"
},
"options": {} // Options depending on the type of chart
}Bars chartsArea chartsPie chartsRadar chartsMetric charts






{
"data": { ...GraphQL response... }
}{
"error": "..."
}# Return the UserPoint creation_ts field
query MyQuery {
user_point(user_point_id: "xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx") {
creation_ts
}
}# Return profiles, accounts, segments and scenarios data of a UserPoint
# Warning: This query relies on a customer defined schema so it may not
# work as-is on your datamart.
query MyQuery {
user_point(user_point_id: "xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx") {
id
creation_ts
profiles {
gender
birth_date
}
accounts {
compartment_id
user_account_id
}
segments {
id
}
scenarios {
scenario_id
}
}
}# Select by UserPoint ID
query MyQuery {
user_point(user_point_id: "xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx") {
id
creation_ts
}
}
# Select by email hash
query MyQuery {
user_point_by_email_hash(email_hash: "xxxxxxxxxxxxxxxxxxx") {
id
creation_ts
}
}
# Select by user account
# Both compartment ID and user account ID are mandatory
query MyQuery {
user_point_by_user_account_id(
compartment_id: "XXXX",
user_account_id: "xxxx-xxx-xx-xxxxx"
) {
id
creation_ts
}
}
# Select by user agent ID
query MyQuery {
user_point_by_user_agent_id(user_agent_id: "xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"){
id
creation_ts
}
}query micsQuery {
user_point(user_point_id:"xxx") {
activities {
#only return events with the name "$home_view"
events @filter(clause: "name == \"$home_view\""){
ts
}
}
}
}{
"date_ranges": [
{
"start_date": "2021-10-20T00:00:00",
"end_date": "2021-10-28T23:59:59"
}
],
"dimensions": [
{"name": "type"}
],
"metrics": [
]
}"report_view": {
"items_per_page": 100,
"total_items": 4,
"columns_headers": [
"type"
],
"rows": [
[
"DISPLAY_AD"
],
[
"SITE_VISIT"
],
[
"USER_SCENARIO_NODE_ENTER"
],
[
"USER_SCENARIO_NODE_EXIT"
]
]
}{
"date_ranges": [
{
"start_date": "2021-10-20T00:00:00",
"end_date": "2021-10-28T23:59:59"
}
],
"dimensions": [
{"name": "date_yyyymmdd"},
{"name": "device_form_factor"}
],
"dimension_filter_clauses": {
"operator": "AND",
"filters": [
{
"dimension_name": "channel_id",
"operator": "EXACT",
"not": false,
"expressions": [
"666"
]
}
]
},
"metrics": [
{"expression": "users"},
{"expression": "revenue"}
]
}"report_view": {
"items_per_page": 100,
"total_items": 54,
"columns_headers": [
"date_yyyymmdd",
"device_form_factor",
"users",
"revenue"
],
"rows": [
[
"20211020",
"OTHER",
141,
222.74
],
[
"20211020",
"PERSONAL_COMPUTER",
821923,
87656567.1
],
[
"20211020",
"SMART_TV",
11,
null
]
[
"20211020",
"SMARTPHONE",
1901978,
98435875.79
],
...
]
}
{
"id": "1",
"name": "Demographics",
"other_metadata_as_you_wish": "SEGMENT",
"genders": [
{
"key": "male",
"value": 358
},
{
"key": "female",
"value": 66
}
],
"ages": [
{
"key": "18-24",
"count": 277
},
{
"key": "45-54",
"count": 8
},
{
"key": "65+",
"count": 9
},
{
"key": "25-34",
"count": 12
},
{
"key": "35-44",
"count": 9
},
{
"key": "55-64",
"count": 3
}
],
"total": 666
}{
"key_value_dataset": [
{
"key": "Dimension 1",
"value": 666
}
...
{
"key": "Dimension X",
"value": 999
}
]
}{
...
"total": 666
}{
"type": "data_file",
// URI of the JSON data file containing data
// Format "mics://data_file/tenants/1426/dashboard-1.json"
"uri": String,
// Path of the property in the JSON that should be used as dataset
// This allows you to have multiple datasets in the same JSON file
// Should use the JSONPath syntax. See https://jsonpath.com/
// For example, "$[0].components[1].component.data"
"JSON_path": String,
// Optional. Title of the series for tooltips and legends
"series_title": String
}{
"sections": [
{
"title": "Section",
"cards": [
{
"x": 0,
"charts": [
{
"title": "Gender",
"type": "Bars",
"dataset": {
"type": "data_file",
"uri": "mics://data_file/tenants/XXX/dashboard-1.json",
"JSON_path": "$.genders"
}
}
],
"y": 0,
"h": 3,
"layout": "vertical",
"w": 4
},
{
"x": 4,
"charts": [
{
"options": {
"legend": {
"enabled": true,
"position": "right"
}
},
"dataset": {
"type": "data_file",
"uri": "mics://data_file/tenants/XXX/dashboard-1.json",
"JSON_path": "$.ages",
"series_title": "count"
},
"title": "Age range",
"type": "Pie"
}
],
"y": 0,
"h": 3,
"layout": "vertical",
"w": 5
},
{
"x": 9,
"charts": [
{
"title": "Totals",
"type": "Metric",
"dataset": {
"type": "data_file",
"uri": "mics://data_file/tenants/XXX/dashboard-1.json",
"JSON_path": "$.total"
}
}
],
"y": 0,
"h": 3,
"layout": "vertical",
"w": 3
}
]
}
]
}[
{
"type": "FREQUENCY_ENUM",
"field_path": "agents.user_agent_info.os_family",
"values": [
"OTHER",
"WINDOWS",
"MAC_OS",
"LINUX",
"ANDROID",
"IOS"
]
},
{
"type": "FREQUENCY_NUMBER",
"field_path": "profiles.age",
"intervals": [
{
"from": 0,
"to": 10
},
{
"from": 10,
"to": 100
}
]
},
{
"type": "FREQUENCY_TEXT",
"field_path": "events.city",
"vector_size": 100
}
]{agents {user_agent_info {os_family}} profiles {age} events{city}}PUT https://api.mediarithmics.com/v1/ml_functions/<id_ml_function>
{
"batch_mode": true,
"status": "ACTIVE"
}type UserPoint @TreeIndexRoot(index:"USER_INDEX") {
...
clustering_cohort:ClusteringCohort
...
}type ClusteringCohort {
id:ID! @TreeIndex(index:"USER_INDEX")
expiration_ts:Timestamp @TreeIndex(index:"USER_INDEX")
cohort_id:String! @TreeIndex(index:"USER_INDEX")
last_modified_ts:Timestamp! @TreeIndex(index:"USER_INDEX")
}https://events.mediarithmics.com/v1/touches/pixel?
$ev=$email_view&
$dat_token=<DATAMART_TOKEN>&
$email_hash=78b04074e616166938cf672f70f41b4d&
Any Custom Properties ...https://events.mediarithmics.com/v1/touches/pixel?
$ev=$email_view&
$dat_token=<DATAMART_TOKEN>&
$uids=jso-[{"$tpe":"EM","$eh":"78b04074e616166938cf672f70f41b4d"}]&
Any Custom Properties ...https://analytics.custom-domain.com/v1/touches/pixel?
$ev=$email_view&
$dat_token=<DATAMART_TOKEN>&
$email_hash=78b04074e616166938cf672f70f41b4d&
Any Custom Properties ...https://events.mediarithmics.com/v1/touches/click?
$ev=$email_click&
$dat_token=<DATAMART_TOKEN>&
$email_hash=78b04074e616166938cf672f70f41b4d&
Any Custom Properties &
$redirect=<CLICK_URL>{
"$ts": 1568296040000,
"$event_name": "article_view",
"$properties": {
"category": "0001",
"article_id": "super-awesome-article",
"source": "web"
}
}{
"$ts": 1568296040000,
"$event_name": "article_view",
"$properties": {
"category": "0001",
"article_id": "super-awesome-article",
"visit_origin": "email",
"source_event_rule": "1"
}
}{
"$ts": 1568296040000,
"$event_name": "article_view",
"$properties": {
"category": "0001",
"article_id": "super-awesome-article",
"visit_origin": "{{origin}}",
"source_event_rule": "1"
}
}{
"$event_name": "PageView",
"$properties": {
"user_id": "<USER_ID>"
}
}{
"status": "ok",
{
// Retrieve the data in the specified date range
// Mandatory. The data is only queryable for the last 4 months
// Only one range is allowed now, but the API is prepared to accept
// multiple ranges in the future.
// Tip : you can use dates in "now-Xd/d" format as in OTQL queries
"date_ranges": [
{
"start_date": "2021-10-10T00:00:00",
"end_date": "2021-10-25T23:59:59"
}
],
// List of dimensions to retrieve
"dimensions": [
{
"name": "date_yyyy_mm_dd"
},
{
"name": "channel_id"
}
],
// Filters on dimensions
"dimension_filter_clauses": {
"operator": "OR",
"filters": [
{
"dimension_name": "type",
"operator": "EXACT",
"expressions": [
"SITE_VISIT"
]
}
]
},
// Order by dates, beginning with the most recent
"order_by": {
"field_name": "-date_yyyy_mm_dd"
},
// List of metrics to retrieve
"metrics": [
{
"expression": "users"
},
{
"expression": "number_of_transactions"
}
]
}{
"status": "ok",
"data": {
"report_view": {
// Note : pagination not implemented yet
"items_per_page": 100,
"total_items": 100,
// To know which data is in which column
"columns_headers": [
"date_yyyy_mm_dd",
"channel_id",
"users",
"number_of_transactions"
],
// Data
"rows": [
[
"2021-10-10",
666,
3881,
17800.0
],
[
"2021-10-10",
555,
1838,
4200.0
],
[
"2021-10-11",
666,
532,
3900.0
],
[
"2021-10-11",
555,
8,
100.0
]
// ...[
]
}
}
}"options": {
"legend": {
enabled: boolean; # Show or hide the legend. Defaults to FALSE.
position: ‘bottom’ | ‘right’; # Display legend on the bottom or on the right of the chart. Defaults to bottom
},
"colors": string[]; # Defaults to current theme colors
"format": ‘count’ | ‘percentage’ | ‘index’; # Defaults to count. Pass percentage or index if dataset is compatible (comes from a percentage or index transformation) to automatically change labels, and tooltips and have more info.
"drilldown": boolean; # Enables drill down if dataset is compatible. Defaults to FALSE
"stacking": boolean; # Enables stacking if dataset is compatible. Prioritized over drilldown. Defaults to FALSE
"type": ‘bar’ || ‘column’; # Set to ‘bar’ to display horizontal bars instead of columns. Defaults to ‘column’
"plot_line_value": int; # Set to draw a line at the specified value
"hide_x_axis": boolean; # TRUE to hide X axis. Defaults to FALSE
"hide_y_axis": boolean; # TRUE to hide Y axis. Defaults to FALSE
"tooltip": {format: string} # Highcharts tooltip pointFormat. Defaults to “{point.y}” if dataset don’t have a -count field, “{point.y}% ({point.count})” otherwise.
"big_bars": boolean; # TRUE displays large bars close to each other, FALSE smaller bars with more space between them. Defaults to TRUE
}"options": {
"legend": {
enabled: boolean; # Show or hide the legend. Defaults to FALSE.
position: ‘bottom’ | ‘right’; # Display legend on the bottom or on the right of the chart. Defaults to bottom
},
"colors": string[]; # Defaults to current theme colors
"format": ‘count’ | ‘percentage’; # Defaults to count. Pass percentage if dataset is compatible (comes from a percentage transformation) to automatically change labels, and tooltips and have more info.
"type": ‘area’ || ‘line’; # Set to ‘line’ to only display lines and no area. Defaults to ‘area’
"plot_line_value": int; # Set to draw a line at the specified value
"hide_x_axis": boolean; # TRUE to hide X axis. Defaults to FALSE
"hide_y_axis": boolean; # TRUE to hide Y axis. Defaults to FALSE
"double_y_axis": boolean; # TRUE for each serie to have its own scale (and shows 2 vertical axis). Defaults to FALSE
"tooltip": {format: string} # Highcharts tooltip pointFormat. Defaults to “{point.y}” if dataset don’t have a -count field, “{point.y}% ({point.count})” otherwise.
}"options": {
"legend": {
"enabled": boolean; # Show or hide the legend. Defaults to FALSE.
"position": ‘bottom’ | ‘right’; # Display legend on the bottom or on the right of the chart. Defaults to bottom
},
"colors": string[]; # Defaults to current theme colors
"drilldown": boolean; # Enables drill down if dataset is compatible. Defaults to FALSE
"inner_radius": boolean; # True displays the chart as a Donut, false as a Pie. Defaults to TRUE
"is_half": boolean; # True to only display half of a donut or half of a pie. Defaults to FALSE.
"size": number | string | undefined; # The diameter of the pie relative to the plot area. Can be a percentage (75%) or a value.
"data_labels": {
"enabled": boolean; # If labels are displayed or not, default to TRUE
"distance": int; # Distance between labels and the figure. Defaults to 10 if isHalf:true, else 0
"format": string; # Labels text. See Labels and string format. Defaults to “{point.percentage:.2f}%” if legend.enable:false, “{point.name} {point.percentage:.2f}%” otherwise.
"filter": Highcharts.filter; # To hide labels under certain values. Defaults to undefined.
};
"tooltip": {"format": string} # Highcharts tooltip pointFormat. Defaults to “{point.percentage:.2f}%” if legend.enable:false, “{point.name} {point.percentage:.2f}%” otherwise.
}"options": {
"legend": {
"enabled": boolean; # Show or hide the legend. Defaults to FALSE.
"position": ‘bottom’ | ‘right’; # Display legend on the bottom or on the right of the chart. Defaults to bottom
},
"colors": string[]; # Defaults to current theme colors
"format": ‘count’ | ‘percentage’; # Defaults to count. Pass percentage if dataset is compatible to automatically change labels, and tooltips.
"data_labels": {
"enabled": boolean; # If labels are displayed or not, default to TRUE
"format": string; # Labels text. See Labels and string format. Defaults to “{point.y}” if dataset don’t have a -count field, “{point.y}%” otherwise
"filter": Highcharts.filter; # To hide labels under certain values. Defaults to undefined.
};
"tooltip": {"format": string} # Highcharts tooltip pointFormat. Defaults to “{point.y}” if dataset don’t have a -count field, “{point.y}% ({point.count})” otherwise.
}"options": {
"format": ‘count’ | ‘percentage’ | 'float'; # Defaults to count. If count, simply displays the number, else displays the number with %
}
percentage formatcount format


mediarithmics modules can trigger alerts to grab the attention of users/integrators on specific points to improve or fix.




data/partner/events/${DATE?string["yyyy/MM/dd"]}/data/partner/events/2025/03/18/24 hours / min_upload_per_day24 hours / max_upload_per_dayFile max size (in kB) = 100000
Min upload per day = 1File max size (in kB) = 100000
Min upload per day = 24"dataset": {
"type": "transformation-1",
// Transformations always take a list of sources
// Even if only one is used
"sources": [
{
// Transformations can be chained
"type": "transformation-2"
"sources": [
{
// End the end we have one more
// query data sources
"type": "OTQL"
...
}
]
}
]
}to-listjointo-percentagesratioindexformat-datesreduceget-decorators




{
"title": String,
"scopes": [Scope]
"segment_ids": [String],
"builder_ids": [String],
"archived": Boolean,
"dashboard_content_id": String,
"organisation_id": String,
"community_id": String,
// Readonly fields
"created_ts": Timestamp,
"created_by": String,
"last_modified_ts": Timestamp,
"last_modified_by": String
}{
"id": String,
"content": DashboardContent
"organisation_id": String,
"created_ts": Timestamp,
"created_by": String
}{
"available_filters": [Filter]
"sections": [Section]
}{
// Using technical names of compartments, segments or channels
// will result in IDs being automatically replaced by names in the UI
"technical_name": String,
"title": String,
"values_retrieve_method": 'Query', // Only available value at the moment
// OTQL query to retrieve list of selectable values
// Use a query string, not the ID of a query
"values_query": String,
// How to adapt queries in the dashboard to the selected value(s)
"query_fragments": [QueryFragment],
"multi_select": Boolean, // If the user can select multiple values
}{
// Any available data source such as 'activities_analytics' or 'OTQL'
"type": String,
// Only for OTQL type, chooses which queries should be transformed
// Select 'ActivityEvent' to transform queries FROM ActivityEvent
"starting_object_type": String,
// The query part to add
"fragment": String,
}{
"title": String,
"cards": [Card],
}{
"x": Int,
"y": Int,
"h": Int,
"w": Int,
"layout": "vertical" || "horizontal",
"charts": [Chart],
} {
"title": String,
"type": "Pie" || "Bars" || "Radar" || "Metric" || "Area",
"dataset": Dataset,
"options": PieOptions || BarsOptions || RadarOptions || MetricOptions || AreaOptions
}"dataset": {
"type": "to-list",
"sources": [
{
"type": "OTQL",
"query_id": "666", // SELECT @count{} FROM UserPoint WHERE...
"series_title": "Unknown"
},
{
"type": "OTQL",
"query_id": "777", // SELECT @count{} FROM UserPoint WHERE...
"series_title": "With online account"
},
{
"type": "OTQL",
"query_id": "888", // SELECT @count{} FROM UserPoint WHERE...
"series_title": "With fidelity program"
}
]
}"dataset": {
"type": "join",
"sources": [
{
"type": "OTQL",
"query_id": 666, // Select {interests @map} FROM UserPoint WHERE...
"series_title": "Unkwnown"
},
{
"type": "OTQL",
"query_id": 777, // Select {interests @map} FROM UserPoint WHERE...
"series_title": "With fidelity program"
}
]
}"type": "Radar",
"dataset": {
"type": "to-percentages",
"sources": [{
"type": "OTQL",
"query_id": 666 // Select {interests @map} FROM UserPoint WHERE...
}]
},
"options": {
"format": "percentage"
}"dataset": {
"type": "ratio",
"sources": [
{
"type": "OTQL",
"query_id": "666" // SELECT @count{} FROM UserPoint WHERE...
}, // Returns 100k
{
"type": "OTQL",
"query_id": "777" // SELECT @count{} FROM UserPoint
} // Returns 200k
]
}
// Result is 100k/200k*100 = 50"type": "Bars",
"dataset": {
"type": "index",
// Use limits like "limit:20" wisely
// as the index will be calculated for each return value, then ordered.
// If you only do a @map with a limit of 10 elements returned and you are asking
// to show the top 10 indexes, you will have the top 10 indexes from the top 10 values
// A value could be in position 20 by numbers, but in position 2 by index
"sources": [
{
// This query adapts to the current segment
"type": "OTQL",
"query_id": 666, // SELECT {interests @map} FROM UserPoint
"series_title": "Segment"
},
{
// Same query without adapting to the current segment
// and always returns data for the whole datamart
"type": "OTQL",
"query_id": 666,
"series_title": "Datamart"
"adapt_to_scope": false
}
],
"options": {
"limit": 10 // Number of elements to display. 10 by default
"order": "Ascending" | "Descending" // Descending by default
// This means that indexes will only be calculated for values
// representing 0.65% of values in source 1.
"minimum_percentage" : 0.65 // 0 by default. Values between 0 and 100
}
},
"options": {
"type": "bar",
"plotLineValue": 100,
"format": "index" // So that the index is correctly displayed in tooltips
}"dataset": {
"type": "format-dates",
"sources": [ // Only one source allowed
{
"type": "OTQL",
"query_id": "666" // SELECT {date @date_histogram} FROM UserEvent WHERE...
},
],
"date_options": {
"format": "YYYY-MM-DD"
}
}"type": "Metric",
"dataset": {
"type": "reduce",
"sources": [{
"type": "OTQL",
"query_id": 666 // Select {interests @map} FROM UserPoint WHERE...
}],
"reduce_options": {
// avg || count || first || last || max || min || sum
"type": "count"
}
},// This returns channel IDs associated with the value
"dataset":
{
"type": "OTQL",
"query_id": "666" // SELECT {channel_id @map} FROM UserEvent WHERE...
}
}
// This returns channel names associated with the value
"dataset": {
"type": "get-decorators",
"sources": [ // Only one source allowed
{
"type": "OTQL",
"query_id": "666" // SELECT {channel_id @map} FROM UserEvent WHERE...
},
],
"decorators_options": {
"model_type": "CHANNELS", // CHANNELS || COMPARTMENTS || SEGMENTS
// Optional if the data source returns sub buckets,
// to define the transformation for those sub buckets
"buckets": {
// Recursive
"buckets": {
"model_type": "SEGMENTS"
}
}
}
}





{
"status": "ok",
"data": {
"report_view": {
"items_per_page": 100,
"total_items": 7,
"columns_headers": [
"type"
],
"rows": [
[
"DISPLAY_AD"
],
[
"EMAIL"
],
[
"SITE_VISIT"
],
[
"USER_SCENARIO_NODE_ENTER"
],
[
"USER_SCENARIO_NODE_EXIT"
],
[
"USER_SCENARIO_START"
],
[
"USER_SCENARIO_STOP"
]
]
}
}
}{
"date_ranges": [
{
"start_date": "2021-04-22T00:00:00",
"end_date": "2021-04-29T23:59:59"
}
],
"dimensions": [
{
"name": "TYPE"
}
],
"dimension_filter_clauses": {
"operator": "OR", // OR or AND
"filters": [
{
"dimension_name": "TYPE",
"operator": "LIKE", // LIKE, EXACT or IN_LIST
"expressions": [
""
]
}
]
},
"metrics": []
}{
"status": "ok",
"data": {
"global": {
"total": 879879879,
"steps": [
{
"name": "Step 1",
"count": 546546546,
"interaction_duration": 0
},
{
"name": "Step 2",
"count": 897987984651,
"amount": 1213213.27,
"conversion": 11221,
"interaction_duration": 515151
}
]
},
"grouped_by": []
}
}{
"for": [
{
"name": "Step 1",
"filter_clause": {
"operator": "OR",
"filters": [
{
"dimension_name": "TYPE",
"not": false,
"operator": "EXACT",
"expressions": [
"DISPLAY_AD"
]
}
]
}
},
{
"name": "Step 2",
"filter_clause": {
"operator": "AND",
"filters": [
{
"dimension_name": "EVENT_TYPE",
"not": false,
"operator": "EXACT",
"expressions": [
"$transaction_confirmed"
]
},
{
"dimension_name": "CHANNEL_ID",
"not": false,
"operator": "IN_LIST",
"expressions": [
"8888",
"6666"
]
}
]
}
}
],
"in": {
"type": "DATES",
"start_date": "2021-04-23",
"end_date": "2021-05-01"
},
"limit": 5
}"filter_clause": {
"operator": "OR", // OR or AND
"filters": [
...
]
} // TYPE should be DISPLAY_AD
{
"dimension_name": "TYPE",
"not": false,
"operator": "EXACT",
"expressions": [
"DISPLAY_AD"
]
}
// TYPE should contain SITE
// SITE_VISIT activities will be used
{
"dimension_name": "TYPE",
"not": false,
"operator": "LIKE",
"expressions": [
"SITE"
]
}
// TYPE should not contain SITE
{
"dimension_name": "TYPE",
"not": true,
"operator": "LIKE",
"expressions": [
"SITE"
]
}
// CHANNEL_ID should be either 8888 or 6666
{
"dimension_name": "CHANNEL_ID",
"not": false,
"operator": "IN_LIST",
"expressions": [
"8888",
"6666"
]
}{
"status": "ok",
"data": [
{
"id": "1555",
"datafarm_key": "DF_EU_2020_02",
"datamart_id": "1509",
"query_id": "50659",
"technical_name": "user_accounts",
"display_name": "User Profiles",
"icon": "users",
"status": "LIVE",
"creation_date": 1613125152462,
"last_modified_date": 1613125152462,
"last_published_date": null
},
{
"id": "1558",
"datafarm_key": "DF_EU_2020_02",
"datamart_id": "1509",
"query_id": "50659",
"technical_name": "mobile_cookie_ids",
"display_name": "User Profiles",
"icon": "users",
"status": "LIVE",
"creation_date": 1613125314757,
"last_modified_date": 1613125314757,
"last_published_date": null
},
{
"id": "1566",
"datafarm_key": "DF_EU_2020_02",
"datamart_id": "1509",
"query_id": "50659",
"technical_name": "mobile_ad_ids",
"display_name": "User Profiles 7",
"icon": "users",
"status": "ARCHIVED",
"creation_date": 1613128930707,
"last_modified_date": 1613128930707,
"last_published_date": null
},
{
"id": "1569",
"datafarm_key": "DF_EU_2020_02",
"datamart_id": "1509",
"query_id": "50659",
"technical_name": "desktop_cookie_ids",
"display_name": "User Profiles 4",
"icon": "gears",
"status": "LIVE",
"creation_date": 1613129103522,
"last_modified_date": 1613129103522,
"last_published_date": null
},
{
"id": "1570",
"datafarm_key": "DF_EU_2020_02",
"datamart_id": "1509",
"query_id": "50659",
"technical_name": "desktop_cookie_ids",
"display_name": "User Profiles 4",
"icon": "gears",
"status": "DRAFT",
"creation_date": 1613129261878,
"last_modified_date": 1613129261878,
"last_published_date": null
}
],
"count": 5,
"total": 5,
"first_result": 0,
"max_result": 50,
"max_results": 50
}{
"status": "ok",
"data": {
"id": "1571",
"datafarm_key": "DF_EU_2020_02",
"datamart_id": "1509",
"query_id": "50659",
"technical_name": "emails",
"display_name": "User Profiles 7",
"icon": "users",
"status": "DRAFT",
"creation_date": 1613130322659,
"last_modified_date": 1613130322659,
"last_published_date": null
}
}{
"status": "error",
"error": "Json object is not structured as expected",
"error_code": "BAD_REQUEST_FORMAT",
"error_id": "e18c26a1-7497-470d-8480-2bcb66fc8f16"
}{
"datamart_id": "<<DATAMART ID>>",
"query_id": "<OTQL QUERY ID>",
"technical_name": "<TECHNICAL_NAME>",
"display_name": "User Profiles",
"icon": "users"
}$email_hard_bounce$email_unsubscribe$email_complaint$set_user_profile_properties$set_user_consent$content_correction$quit_while_running$cleaned_referrer



Failed{
"$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" : {}
}]
}{
"$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" : {}
}]
}{
"$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"
}
}]
}// Sample UserActivity 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_id": "<your_processing_id>", // Mandatory
"$choice_acceptance_value":<true/false>, // Mandatory
"<your_custom_field>" : "<your_custom field_value>"
}
}
]
}// Select a UserPoint 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 UserPoint 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 UserPoint 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 UserPoint using an email_hash
/v1/datamarts/<DATAMART_ID>/user_points/email_hash=<EMAIL_HASH>/user_profiles/compartment_id=:compartmentId/user_account_id=:userAccountId{
"$compartment_id" : ":compartment_id",
"$user_account_id" : ":user_account_id",
"gender" : "female",
"zipcode" : "75001"
}// Sample payload
{
"$choice_ts": "<a_timestamp (ex:1573135588140)>", // Mandatory
"$choice_acceptance_value":<true/false>, // Mandatory
"<your_custom_field>" : "<your_custom field_value> // Optional
}{
"status": "ok",
"data": {
// New UserActivity object
}
}{
"status": "error",
"error": "Your error message"
}{
"status": "ok",
"data": {
"id": "1000",
"name": "my analyzer",
"organisation_id": "1000",
"visit_analyzer_plugin_id": "1001",
"group_id": "com.mediarithmics.visit-analyzer",
"artifact_id": "default"
}
}{
"status": "ok",
"data": [
{
"technical_name": "debug",
"value": { "value": false },
"property_type": "BOOLEAN",
"origin": "PLUGIN",
"writable": true,
"deletable": false
},
{
"technical_name": "topic_properties",
"value": { "value": "vertical" },
"property_type": "STRING",
"origin": "PLUGIN",
"writable": true,
"deletable": false
}
],
"count": 2
}import { core } from "@mediarithmics/plugins-nodejs-sdk";
import { CustomInstanceContext } from "./interfaces/InstanceContextInterface";
export class ActivityAnalyzerPlugin extends core.ActivityAnalyzerPlugin {
// Called to update a UserActivity
// Uses the instance context built with instanceContextBuilder
// to adapt to the properties and technical files
protected async onActivityAnalysis(
request: core.ActivityAnalyzerRequest,
instanceContext: CustomInstanceContext)
: Promise<core.ActivityAnalyzerPluginResponse> {
try{
const updatedActivity = request.activity;
// Your code to modify the activity.
// Exemple adding product infos in each event
// If the technical configuration allows it
if (instanceContext.technicalConfig.updateActivities){
updatedActivity.$events.forEach(event => {
if (event.$properties && event.$properties.$items && event.$properties.$items.length > 0) {
event.$properties.$items.forEach((item: any) => {
var product = Products.find(p => p.$id == item.$id);
item.$name = product.$name;
item.categories = product.categories;
item.inStock = product.inStock;
});
}
});
}
const response: core.ActivityAnalyzerPluginResponse = {
status: "ok",
data: updatedActivity
};
return Promise.resolve(response);
}
catch (err) {
const errorResponse: core.ActivityAnalyzerPluginResponse = {
status: 'error',
data: request.activity
};
this.logger.error(`TRANSFORMATION ERROR while processing activity: ${JSON.stringify(request.activity)}`);
return Promise.resolve(errorResponse)
}
}
// Build the instance context
// by fetching properties and configuration files
protected async instanceContextBuilder(activityAnalyzerId: string)
: Promise<CustomInstanceContext> {
const baseInstanceContext = await super.instanceContextBuilder(activityAnalyzerId);
try {
// Retrieve a technical configuration file
const validator = new Jsonschema.Validator();
const technicalConfig: ITechnicalConfig = await this.validateJSONSchema(TECH_CONFIG_FILE, validator, technicalConfigurationSchema, activityAnalyzerId);
// Retrieve a property from the plugin instance
const eventExclusionList = baseInstanceContext.properties.findStringProperty("events_exclusion_list");
// Return the completed instance context
const result: CustomInstanceContext = {
...baseInstanceContext,
event_exclusion_list: eventExclusionList,
technicalConfig: technicalConfig
};
this.logger.debug(`Loaded InstanceContext with: ${JSON.stringify(result,null,4)}`);
return Promise.resolve(result);
} catch (err) {
this.logger.error(`Something bad happened during the build of the Instance Context ${err}`);
return Promise.reject(`Something bad happened during the build of the Instance Context ${err}`);
}
};
}import { core } from "@mediarithmics/plugins-nodejs-sdk";
export interface CustomInstanceContext
extends core.ActivityAnalyzerBaseInstanceContext
{
event_exclusion_list: string[];
technicalConfig: ITechnicalConfig;
}{
"processed_by": "<YOUR_ANALYZER_ID>",
"$error_analyzer_id": "<ERROR_ID>"
}{
"status": "ok",
"data": [
{
"type": "QUERY",
"id": "9879",
"organisation_id": "1426",
"name": "2018-08-29 - Export test segments for Facebook and Adwords",
"query_id": "65987",
"datamart_id": "1509",
"output_format": "JSON"
},
{
"type": "QUERY",
"id": "9872",
"organisation_id": "1426",
"name": "export-visiteurs",
"query_id": "45987",
"datamart_id": "1509",
"output_format": "JSON"
},
...
],
"count": 50,
"total": 163,
"first_result": 0,
"max_result": 50,
"max_results": 50
}{
"status": "ok",
"data": {
"type": "QUERY",
"id": "8978",
"organisation_id": "1426",
"name": "2018-08-29 - Export test segments for Facebook and Adwords",
"query_id": "98798",
"datamart_id": "1509",
"output_format": "JSON"
}
}{
"status":"ok",
"data":
{
"type": "QUERY",
"id": "8205",
"organisation_id": "1426",
"name": "test",
"query_id": "50409",
"datamart_id": "1509",
"output_format": "JSON"
}
}// Creating an export payload
{
"name": "<YOUR_EXPORT_NAME>",
"output_format": "JSON",
"query_id": "<ID_OF_QUERY_CREATED_IN_PREVIOUS_STEP>",
"type": "QUERY"
}{
"status": "ok",
"data": {
"parameters": {},
"organisation_id": "1426",
"user_id": "2886",
"result": null,
"error": null,
"id": "879879879",
"status": "PENDING",
"creation_date": 1612789702668,
"start_date": null,
"duration": null,
"cancel_status": null,
"debug": null,
"is_retryable": false,
"permalink_uri": "MTowOjA65985NjYyOQ==",
"num_tasks": null,
"completed_tasks": null,
"erroneous_tasks": null,
"retry_count": 0,
"job_type": "DATAMART_QUERY_EXPORT"
}
}{
"status": "ok",
"data": [
{
"parameters": {},
"organisation_id": "1426",
"user_id": "8987",
"result": {
"output_files": [
"export"
]
},
"error": null,
"id": "7897897",
"status": "SUCCEEDED",
"creation_date": 1562595783663,
"start_date": 1562595789171,
"duration": 292617,
"cancel_status": null,
"debug": null,
"is_retryable": false,
"permalink_uri": "",
"num_tasks": 299808,
"completed_tasks": 277105,
"erroneous_tasks": 22703,
"retry_count": 0,
"job_type": "DATAMART_QUERY_EXPORT",
"end_date": 1562596081788
},
{
"parameters": {},
"organisation_id": "1426",
"user_id": "8987",
"result": {
"output_files": [
"export"
]
},
"error": null,
"id": "9879879",
"status": "SUCCEEDED",
"creation_date": 1561655188369,
"start_date": 1561655192158,
"duration": 413140,
"cancel_status": null,
"debug": null,
"is_retryable": false,
"permalink_uri": "",
"num_tasks": 284602,
"completed_tasks": 263822,
"erroneous_tasks": 20780,
"retry_count": 0,
"job_type": "DATAMART_QUERY_EXPORT",
"end_date": 1561655605298
},
{
"parameters": {},
"organisation_id": "1426",
"user_id": "9879",
"result": {
"output_files": [
"export"
]
},
"error": null,
"id": "4564564",
"status": "SUCCEEDED",
"creation_date": 1535555844642,
"start_date": 1535555850435,
"duration": 337507,
"cancel_status": null,
"debug": null,
"is_retryable": false,
"permalink_uri": "",
"num_tasks": null,
"completed_tasks": null,
"erroneous_tasks": null,
"retry_count": 0,
"job_type": "DATAMART_QUERY_EXPORT",
"end_date": 1535556187942
}
],
"count": 3,
"total": 3,
"first_result": 0,
"max_result": 10,
"max_results": 10
}// For query SELECT {emails {id}} FROM UserPoint WHERE segments {id="<SEGMENTID>"}
{"emails":[{"id":"87987987985465432198"}]}
{"emails":[]}
{"emails":[]}
{"emails":[{"id":"46546549879879845654"},{"id":"564654987987465465465"}]}{
"status": "error",
"error": "Resource Not Found",
"error_id": "9eedef5f-dfe3-4354-9a2f-d79760113386"
}This page references recipes you can use to speed up your data visualization learning curve.



{
"status": "ok",
"data": [
{
"id": "1266",
"datamart_id": "1509",
"status": "ARCHIVED",
"creation_date": 1602860201358,
"last_modification_date": 1602860221562,
"publication_date": 1602860275189,
"suspension_date": 1602860362588
},
{
"id": "1281",
"datamart_id": "1509",
"status": "LIVE",
"creation_date": 1603198414771,
"last_modification_date": 1603198415117,
"publication_date": 1603198415733,
"suspension_date": null
},
{
"id": "1385",
"datamart_id": "1509",
"status": "DRAFT",
"creation_date": 1609888013947,
"last_modification_date": 1610443926552,
"publication_date": null,
"suspension_date": null
}
],
"count": 3,
"total": 3,
"first_result": 0,
"max_result": 2147483647,
"max_results": 2147483647
}{
"status": "ok",
"data": {
"id": "1266",
"datamart_id": "1509",
"status": "ARCHIVED",
"creation_date": 1602860201358,
"last_modification_date": 1602860221562,
"publication_date": 1602860275189,
"suspension_date": 1602860362588
}
}##
type UserPoint @TreeIndexRoot(index:"USER_INDEX") {
events:[ActivityEvent!]!
creation_ts:Timestamp! @TreeIndex(index:"USER_INDEX")
id:ID!
}
##
type ActivityEvent {
referrer:String @TreeIndex(index:"USER_INDEX") @Property(path:"$properties.$referrer")
url:String @TreeIndex(index:"USER_INDEX") @Property(path:"$properties.$url")
date:Date! @TreeIndex(index:"USER_INDEX") @Function(params:["ts"], name:"ISODate")
nature:String @Property(path:"$event_name") @TreeIndex(index:"USER_INDEX")
ts:Timestamp!
id:ID!
}
{
"status": "ok",
"data": {
"id": "1395",
"datamart_id": "1509",
"status": "DRAFT",
"creation_date": 1610449867207,
"last_modification_date": 1610449867207,
"publication_date": null,
"suspension_date": null
}
}{
"status": "error",
"error": "Impossible to create a new schema, there is already one draft schema",
"error_code": "CONSTRAINT_VIOLATION_EXCEPTION",
"error_id": "690596a9-b0e0-43b3-88e8-b90d08b98029"
}{
"status": "ok",
"data": {
"id": "1395",
"datamart_id": "1509",
"status": "DRAFT",
"creation_date": 1610449867207,
"last_modification_date": 1610449867207,
"publication_date": null,
"suspension_date": null
}
}{
"status": "error",
"error": "Impossible to create a new schema, there is already one draft schema",
"error_code": "CONSTRAINT_VIOLATION_EXCEPTION",
"error_id": "690596a9-b0e0-43b3-88e8-b90d08b98029"
}{
"status": "ok"
}{
"status": "ok",
"data": {
"datamart_id": "1509",
"schema_id": "1266",
"tree_index_operations": [
{
"datamart_id": "1509",
"index_selection_id": "2121",
"index_name": "USER_INDEX",
"init_strategy": "FORCE_NO_BUILD",
"driver_version_major_number": 1,
"driver_version_minor_number": 2,
"current_index_id": "574",
"current_index_size": "SMALL",
"new_index": false,
"new_index_size": "SMALL",
"init_job": null,
"error_code": null,
"error_message": null
}
],
"schema_errors": []
}
}{
"status": "error",
"error": "2 error(s) found when validating schema : Type 'UserPoint' which is root of tree index 'USER_INDEX' requires a scalar field named 'creation_ts' to be annotated with '@TreeIndex(index:\"USER_INDEX\")' and to be typed 'Timestamp!', Type 'UserAccount' which is root of tree index 'USER_INDEX' requires a scalar field named 'compartment_id' to be annotated with '@TreeIndex(index:\"USER_INDEX\")' and to be typed 'String!'",
"error_code": "BAD_REQUEST_DATA",
"error_id": "6a52cea9-6de4-40f5-972e-a8480c268d19"
}{
"status": "ok",
"data": {
"datamart_id": "1509",
"schema_id": "1395",
"tree_indices": [
{
"index_name": "USER_INDEX",
"new_index": false,
"index_id": "574",
"index_size": "SMALL",
"init_strategy": "FORCE_NO_BUILD",
"driver_version_major_number": 1,
"driver_version_minor_number": 2,
"init_job": null
}
]
}
}{
"status": "error",
"error": "Impossible to publish schema, validate the schema before a new publication",
"error_code": "BAD_REQUEST_DATA",
"error_id": "76e70020-02cb-40ec-8109-adf204aa0a7b"
}// DRAFT Schema
{
"id": "1385",
"datamart_id": "1509",
"status": "DRAFT",
"creation_date": 1609888013947,
"last_modification_date": 1610443926552,
"publication_date": null,
"suspension_date": null
}
// LIVE Schema
{
"id": "1281",
"datamart_id": "1509",
"status": "LIVE",
"creation_date": 1603198414771,
"last_modification_date": 1603198415117,
"publication_date": 1603198415733,
"suspension_date": null
}
// ARCHIVED Schema
{
"id": "1276",
"datamart_id": "1509",
"status": "ARCHIVED",
"creation_date": 1603102827888,
"last_modification_date": 1603102828087,
"publication_date": 1603102828479,
"suspension_date": 1603102848269
}USAGE
$ mics-cli schema:fetch DATAMARTID [SCHEMAID]
ARGUMENTS
DATAMARTID the ID of the datamart
SCHEMAID [default: LIVE] the ID of the schema, or LIVE to get the live schema
OPTIONS
--stdout output the content of the file instead of saving it in a file"dataset": {
"type": "OTQL",
"query_id": 666 // SELECT @count FROM UserPoint
}"dataset": {
"type": "activities_analytics",
"query_json": { // This query returns the number of active users
"dimensions": [],
"metrics": [
{
"expression": "users"
}
]
}
}// key-value dataset built with an OTQL query
"dataset": {
"type": "OTQL",
"query_id": 666 // SELECT {gender @map} FROM UserProfile
}
// key-value dataset built with an activities analytics query
"dataset": {
"type": "activities_analytics",
"query_json": { // This query returns the number of active users per channel
"dimensions": [
{"name": "channel_id"}
],
"metrics": [
{
"expression": "users"
}
]
}
}"dataset": {
"type": "to-list",
"sources": [
{
"type": "OTQL",
"query_id": "666",
"series_title": "Female"
},
{
"type": "OTQL",
"query_id": "777",
"series_title": "Male"
}
]
}// key-value dataset built with an OTQL query
"dataset": {
"type": "OTQL",
"query_id": 666 // SELECT {cat1 @map{cat2 @map{cat3 @map}}} FROM UserProfile
}
// key-value dataset built with an activities analytics query
"dataset": {
"type": "activities_analytics",
"query_json": { // Number of active users per day per channel
"dimensions": [
{"name": "date_yyyymmdd"}
{"name": "channel_id"}
],
"metrics": [
{
"expression": "users"
}
]
}
}"dataset": {
"type": "join",
"sources": [
{
"type": "OTQL",
"query_id": 777, // Select {interests @map} FROM UserPoint WHERE ...
"series_title": "Group 1"
},
{
"type": "OTQL",
"query_id": 666, // Select {interests @map} FROM UserPoint WHERE...
"series_title": "Group 2"
}
]
}"dataset": {
"type": "transformation-name",
"sources": [
{
"type": "transformation-name",
"sources": [
{
// OTQL data source
"type": "OTQL",
// ID of the OTQL query to call
"query_id": Int,
// Optional. Title of the series for tooltips and legends
"series_title": String,
// Optional. Datamart on which to run the query.
// Defaults to current datamart
"datamart_id": Int,
// Optional. To adapt the query to the current scope
// for example by adding current segment's query
// when dashboard is executed on a segment
// Defaults to TRUE
// COMING SOON
"adapt_to_scope": Boolean
// Optional. To run the query in a specific precision
// To be used when charts take too long to load and
// a lower precision is accepted
// Defaults to FULL_PRECISION
"precision": "FULL_PRECISION" | "LOWER_PRECISION" | "MEDIUM_PRECISION"
}
]
},
{
"type": "activities_analytics",
// JSON representation of the activities analytics query
"query_json": Object,
// Optional. Title of the series for tooltips and legends
"series_title": String,
// Optional. Datamart on which to run the query.
// Defaults to current datamart
"datamart_id": Int,
// Optional. To adapt the query to the current scope
// for example by only selecting activities of users
// that were in the segment while doing it
// when dashboard is executed on a segment
// Defaults to TRUE
// COMING SOON
"adapt_to_scope": Boolean
},
{
"type": "collection_volumes",
// JSON representation of the activities analytics query
"query_json": Object,
// Optional. Title of the series for tooltips and legends
"series_title": String
},
{
"type": "resources_usage",
// JSON representation of the activities analytics query
"query_json": Object,
// Optional. Title of the series for tooltips and legends
"series_title": String
},
{
"type": "data_ingestion",
// JSON representation of the activities analytics query
"query_json": Object,
// Optional. Title of the series for tooltips and legends
"series_title": String
},
{
"type": "data_file",
// URI of the JSON data file containing data
// Format "mics://data_file/tenants/1426/dashboard-1.json"
"uri": String,
// Path of the property in the JSON that should be used as dataset
// This allows you to have multiple datasets in the same JSON file
// Should use the JSONPath syntax. See https://jsonpath.com/
// For example, "$[0].components[1].component.data"
"JSON_path": String,
// Optional. Title of the series for tooltips and legends
"series_title": String
}
]
}"dataset": {
"type": "join",
"sources": [
{
"type": "OTQL",
"query_id": 777, // Select {interests @map} FROM UserPoint WHERE ...
"series_title": "Segment"
},
{
"type": "OTQL",
"query_id": 666, // Select {interests @map} FROM UserPoint WHERE...
"series_title": "Datamart",
"adapt_to_scope": false
}
]
} {
"title": "Application events (last 6 months)",
"type": "Bars",
"dataset": {
"type": "format-dates",
"sources": [
{
// @date_histogram query
"type": "OTQL",
"query_id": "666"
}
],
"date_options": {
"format": "YYYY-MM-DD"
}
}
}{
"title": "Montly events per channel or type-",
"type": "Bars",
"dataset": {
"type": "format-dates",
"sources": [
{
// This works with a join but this can also work from a single source
// without the join
"type": "join",
"sources": [
{
"type": "OTQL",
// Select {date @date_histogram } FROM UserEvent
// WHERE channel_id = XXX
"query_id": "666",
"series_title": "Group 1"
},
{
"type": "OTQL",
// Select {date @date_histogram } FROM UserEvent
// WHERE channel_id = YYY
"query_id": "777",
"series_title": "Group 2"
},
{
"type": "OTQL",
// Select {date @date_histogram } FROM UserEvent
// WHERE channel_id = ZZZ
"query_id": "888",
"series_title": "Group 3"
}
]
}
],
"date_options": {
"format": "YYYY-MM-DD" // The date format we want to return
}
},
// Show the legend for a better event display
"options": {
"legend": {
"enabled": true,
"position": "bottom"
},
"big_bars": false // Allow space between dates
}
}{
"title": "Events",
"type": "Bars",
"dataset": {
"type": "join",
"sources": [
// Get some counts from activities analytics by month
{
"type": "activities_analytics",
"query_json": {
"dimensions": [
{
"name": "date_YYYYMMDD"
}
],
"metrics": [
{
"expression": "number_of_user_events"
}
]
},
"series_title": "activities_analytics"
},
// Get other counts from OTQL by month with @date_histogram
// and format the result in the same format as activities analytics
{
"type": "format-dates",
"sources": [
{
"type": "OTQL",
"query_id": "666"
}
],
"series_title": "OTQL",
"date_options": {
"format": "YYYYMMDD"
}
}
]
},
"options": {
"hide_x_axis": true // We hide the x axis as there are a lot of values
}
}{
// Card display options.
// Here we show a small card with a vertical layout
"x": 0,
"y": 0,
"h": 2,
"w": 3,
"layout": "vertical",
// The two charts in the card
"charts": [
{
// The number of UserPoint as a metric
"title": "UserPoint",
"type": "Metric",
"dataset": {
"type": "OTQL",
"query_id": "666" // SELECT @count FROM UserPoint
}
},
{
// Bars showing a history of the number of UserPoint
"title": "",
"type": "Bars",
"dataset": {
// We do use the format-dates transformation to display
// friendly dates instead of timestamps
"type": "format-dates",
"sources": [
{
"type": "collection_volumes",
"query_json": {
"dimensions": [
{
"name": "date_time"
},
{
"name": "collection"
}
],
"dimension_filter_clauses": {
"operator": "AND",
"filters": [
{
"dimension_name": "datamart_id",
"operator": "EXACT",
"expressions": [
YOUR_DATAMART_ID
]
},
{
"dimension_name": "collection",
"operator": "EXACT",
"expressions": [
"UserPoint"
]
}
]
},
"metrics": [
{
"expression": "count"
}
]
}
}
],
"date_options": {
"format": "YYYY-MM-DD HH:mm"
}
},
// We hide axis to have a nice little chart only showing trends
// with the ability for the user to get values by hovering the bars
"options": {
"hide_x_axis": true,
"hide_y_axis": true
}
}
]
}{
"x": 0,
"charts": [
{
"title": "UserPoint",
"type": "Metric",
"dataset": {
"type": "OTQL",
"query_id": "666"
}
},
{
"title": "Activability",
"type": "Bars",
"dataset": {
"type": "to-list",
"sources": [
{
"type": "OTQL",
"query_id": "111",
"series_title": "Total UserPoint"
},
{
"type": "OTQL",
"query_id": "222",
"series_title": "With accounts"
},
{
"type": "OTQL",
"query_id": "333",
"series_title": "With emails"
},
{
"type": "OTQL",
"query_id": "444",
"series_title": "With web cookies"
},
{
"type": "OTQL",
"query_id": "555",
"series_title": "With apple Mobile ID"
},
{
"type": "OTQL",
"query_id": "666",
"series_title": "With google Mobile ID"
}
]
},
"options": {
"type": "bar",
"hide_y_axis": true,
"colors": [
"#333333"
]
}
}
],
"y": 0,
"h": 5,
"layout": "vertical",
"w": 4
}{
"title": "Viewing modes",
"type": "Bars",
"dataset": {
"type": "index",
"sources": [
{
"type": "OTQL",
"query_id": "666", // SELECT {events {session_mode @map}} FROM UserPoint
"series_title": "Segment"
},
{
"type": "OTQL",
"query_id": "666", // SELECT {events {session_mode @map}} FROM UserPoint
"series_title": "Datamart",
"adapt_to_scope": false
}
],
"options": {
"limit": 10,
"minimum_percentage": 1,
"sort": "Descending"
}
},
"options": {
"type": "bar",
"plot_line_value": 100,
"format": "index"
}
}{
"title": "Data by channels",
"type": "Bars",
"dataset": {
"type": "get-decorators",
"sources": [
{
"type": "to-percentages",
"sources": [
{
"type": "OTQL",
"query_id": "666" // SELECT { channel_id @map} FROM UserEvent WHERE ...
}
]
}
],
"decorators_options": {
"model_type": "CHANNELS"
}
},
"options": {
"format": "percentage"
}
}{
"title": "Number of different event names retrieved",
"type": "Metric",
"dataset": {
"type": "reduce",
"sources": [
{
"type": "OTQL",
"query_id": "666" // SELECT {nature @cardinality} FROM ActivityEvent
}
],
"reduce_options": {
"type": "first"
}
}
}
https://events.mediarithmics.com/v1/touches/pixel? \
$ev=$ad_view& \
$dat_token=<DATAMART_TOKEN>&
$catn=<CAMPAIGN_TECHNICAL_NAME>&
$scatn=<AD_GROUP_TECHNICAL_NAME>&
$crtn=<CREATIVE_TECHNICAL_NAME>&
$cb=<CACHEBUSTER>&
gdpr=<GDPR>&
gdpr_consent=<GDPR_CONSENT_184>
... any custom propertyhttps://events.mediarithmics.com/v1/touches/click?
$ev=$ad_click&
$dat_token=<DATAMART_TOKEN>&
$catn=<CAMPAIGN_TECHNICAL_NAME>&
$scatn=<AD_GROUP_TECHNICAL_NAME>&
$crtn=<CREATIVE_TECHNICAL_NAME>&
$cb=<CACHEBUSTER>&
$redirect=<CLICK_URL>&
gdpr=<GDPR>&
gdpr_consent=<GDPR_CONSENT_184>
... any custom propertyhttps://events.mediarithmics.com/v1/touches/pixel?
$ev=$ad_view&
$dat_token=<DATAMART_TOKEN>&
$catn=${CAMPAIGN_ID}&
$scatn=${INSERTION_ORDER_ID}&
$crtn=${CREATIVE_ID}&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$cb=${CACHEBUSTER}https://events.mediarithmics.com/v1/touches/click?
$ev=$ad_click&
$dat_token=<DATAMART_TOKEN>&
$catn=${CAMPAIGN_ID}&
$scatn=${INSERTION_ORDER_ID}&
$crtn=${CREATIVE_ID}&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$cb=${CACHEBUSTER}&
$redirect=${CLICK_URL_ENC}https://events.mediarithmics.com/v1/touches/pixel?
$ev=$ad_view&
$dat_token=<DATAMART_TOKEN>&
$catn=%ebuy!&
$scatn=%eaid!&
$crtn=%ecid!&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$cb=%nhttps://events.mediarithmics.com/v1/touches/click?
$ev=$ad_click&
$dat_token=<DATAMART_TOKEN>&
$catn=%ebuy!&
$scatn=%eaid!&
$crtn=%ecid!&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$cb=%n&
$redirect=<CLICK_URL>https://events.mediarithmics.com/v1/touches/pixel?
$ev=$ad_view&
$dat_token=<DATAMART_TOKEN>&
$catn=%ebuy!&
$scatn=%eaid!&
$crtn=%ecid!&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$cb=%%CACHEBUSTER%%https://events.mediarithmics.com/v1/touches/click?
$ev=$ad_click&
$dat_token=<DATAMART_TOKEN>&
$catn=%ebuy!&
$scatn=%eaid!&
$crtn=%ecid!&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$cb=%%CACHEBUSTER%%&
$redirect=<CLICK_URL>https://events.mediarithmics.com/v1/touches/pixel?
$ev=$ad_view&
$dat_token=<DATAMART_TOKEN>&
$catn=${CP_CODE}&
$scatn=${CPG_CODE}&
$crtn=${CREATIVE_CODE}&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$cb=${CACHEBUSTER}https://events.mediarithmics.com/v1/touches/click?
$ev=$ad_click&
$dat_token=<DATAMART_TOKEN>&
$catn=${CP_CODE}&
$scatn=${CPG_CODE}&
$crtn=${CREATIVE_CODE}&
$cb=${CACHEBUSTER}&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$redirect=${CLICK_URL_ENC}https://events.mediarithmics.com/v1/touches/pixel?
$ev=$ad_view&
$dat_token=<DATAMART_TOKEN>&
$catn=%%TTD_CAMPAIGNID%%&
$scatn=%%TTD_ADGROUPID%%&
$crtn=%%TTD_CREATIVEID%%&
$cb=%%TTD_CACHEBUSTER%%&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}https://events.mediarithmics.com/v1/touches/click?
$ev=$ad_click&
$dat_token=<DATAMART_TOKEN>&
$catn=%%TTD_CAMPAIGNID%%&
$scatn=%%TTD_ADGROUPID%%&
$crtn=%%TTD_CREATIVEID%%&
$cb=%%TTD_CACHEBUSTER%%&
gdpr=${GDPR}&
gdpr_consent=${GDPR_CONSENT_184}&
$redirect=%%TTD_CLK_ESC%%...
domain=%%TTD_SITE%%&
device=%%TTD_DEVICETYPE%%&
...https://events.mediarithmics.com/v1/touches/pixel? \
$ev=$ad_view& \
$dat_token=<DATAMART_TOKEN>&
$catn=<CAMPAIGN_TECHNICAL_NAME>&
$scatn=<AD_GROUP_TECHNICAL_NAME>&
$crtn=<CREATIVE_TECHNICAL_NAME>&
gdpr=<GDPR>&
gdpr_consent=<GDPR_CONSENT>&
$cb=<CACHEBUSTER>&
$uids=jso-[{"$tpe":"AG","$agid":"vec:1234"}]&
... any custom property







<script type="text/javascript">
/* YOU SHOULD NOT EDIT THIS PART */
!function(t,e,a){"use strict";var i=t.scimhtiraidem||{};function s(t){var e=i[a]||{};i[a]=e,e[t]||(e[t]=function(){i._queue[a].push({method:t,args:Array.prototype.slice.apply(arguments)})})}t.googletag=t.googletag||{},t.googletag.cmd=t.googletag.cmd||[],t.googletag.cmd.push(function(){var e=t.localStorage.getItem("mics_sgmts"),a=JSON.parse(e),i=a||{};Object.keys(i).forEach(function(e){t.googletag.pubads().setTargeting("mics_"+e,i[e].map(String))})});var r="init call config push pushDefault addIdentifier addProperties addProperty onFinish onStart _reset".split(" ");i._queue=i._queue||{},i._names=i._names||[],i._names.push(a),i._queue[a]=i._queue[a]||[],i._startTime=(new Date).getTime(),i._snippetVersion="2.0";for(var o=0;o<r.length;o++)s(r[o]);t.scimhtiraidem=i,t[a]=i[a];var n=e.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src","https://static.mediarithmics.com/tag/2/tag.min.js"),n.setAttribute("async","true"),e.getElementsByTagName("script")[0].parentNode.appendChild(n)}(window,document,"mics");
mics.init("<SITE_TOKEN>");
// Enables client-side feeds
mics.call("syncFeeds");
/* CUSTOMIZE THE TAG CALL BELOW */
// remove next line to customize what you track
mics.pushDefault();
</script><script type="text/javascript">
/* YOU SHOULD NOT EDIT THIS PART */
!function(t,e,a){"use strict";var i=t.scimhtiraidem||{};function s(t){var e=i[a]||{};i[a]=e,e[t]||(e[t]=function(){i._queue[a].push({method:t,args:Array.prototype.slice.apply(arguments)})})}t.googletag=t.googletag||{},t.googletag.cmd=t.googletag.cmd||[],t.googletag.cmd.push(function(){var e=t.localStorage.getItem("mics_sgmts"),a=JSON.parse(e),i=a||{};Object.keys(i).forEach(function(e){t.googletag.pubads().setTargeting("mics_"+e,i[e].map(String))})});var r="init call config push pushDefault addIdentifier addProperties addProperty onFinish onStart _reset".split(" ");i._queue=i._queue||{},i._names=i._names||[],i._names.push(a),i._queue[a]=i._queue[a]||[],i._startTime=(new Date).getTime(),i._snippetVersion="2.0";for(var o=0;o<r.length;o++)s(r[o]);t.scimhtiraidem=i,t[a]=i[a];var n=e.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src","https://static.mediarithmics.com/tag/2/tag.min.js"),n.setAttribute("async","true"),e.getElementsByTagName("script")[0].parentNode.appendChild(n)}(window,document,"umbrella_corp");
umbrella_corp.init("<SITE_TOKEN>");
// Enables client-side feeds
umbrella_corp.call("syncFeeds");
/* CUSTOMIZE THE TAG CALL BELOW */
// remove next line to customize what you track
umbrella_corp.pushDefault();
</script><script type="text/javascript">
/* YOU SHOULD NOT EDIT THIS PART */
!function(t,e,a){"use strict";var i=t.scimhtiraidem||{};function s(t){var e=i[a]||{};i[a]=e,e[t]||(e[t]=function(){i._queue[a].push({method:t,args:Array.prototype.slice.apply(arguments)})})}t.googletag=t.googletag||{},t.googletag.cmd=t.googletag.cmd||[],t.googletag.cmd.push(function(){var e=t.localStorage.getItem("mics_sgmts"),a=JSON.parse(e),i=a||{};Object.keys(i).forEach(function(e){t.googletag.pubads().setTargeting("mics_"+e,i[e].map(String))})});var r="init call config push pushDefault addIdentifier addProperties addProperty onFinish onStart _reset".split(" ");i._queue=i._queue||{},i._names=i._names||[],i._names.push(a),i._queue[a]=i._queue[a]||[],i._startTime=(new Date).getTime(),i._snippetVersion="2.0";for(var o=0;o<r.length;o++)s(r[o]);t.scimhtiraidem=i,t[a]=i[a];var n=e.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src","https://static.mediarithmics.com/tag/2/tag.min.js"),n.setAttribute("async","true"),e.getElementsByTagName("script")[0].parentNode.appendChild(n)}(window,document,"umbrella_corp");
umbrella_corp.init({ mode: "VISIT", site_token: "<SITE_TOKEN>", domain_name: "<YOUR_DOMAIN_NAME>" });
// Enables client-side feeds
umbrella_corp.call("syncFeeds");
/* CUSTOMIZE THE TAG CALL BELOW */
// remove next line to customize what you track
umbrella_corp.pushDefault();
</script><script type="text/javascript">
/* YOU SHOULD NOT EDIT THIS PART */
!function(t,e,a){"use strict";var i=t.scimhtiraidem||{};function s(t){var e=i[a]||{};i[a]=e,e[t]||(e[t]=function(){i._queue[a].push({method:t,args:Array.prototype.slice.apply(arguments)})})}t.googletag=t.googletag||{},t.googletag.cmd=t.googletag.cmd||[],t.googletag.cmd.push(function(){var e=t.localStorage.getItem("mics_sgmts"),a=JSON.parse(e),i=a||{};Object.keys(i).forEach(function(e){t.googletag.pubads().setTargeting("mics_"+e,i[e].map(String))})});var r="init call config push pushDefault addIdentifier addProperties addProperty onFinish onStart _reset".split(" ");i._queue=i._queue||{},i._names=i._names||[],i._names.push(a),i._queue[a]=i._queue[a]||[],i._startTime=(new Date).getTime(),i._snippetVersion="2.0";for(var o=0;o<r.length;o++)s(r[o]);t.scimhtiraidem=i,t[a]=i[a];var n=e.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src","https://static.mediarithmics.com/tag/2/tag.min.js"),n.setAttribute("async","true"),e.getElementsByTagName("script")[0].parentNode.appendChild(n)}(window,document,"mics");
mics.init({mode: "VISIT", site_token: "<SITE_TOKEN>"});
mics.call("syncFeeds");
$(".your_button").on("click", function () {
mics.push("click button", {
button_type: "button1"
// ...
});
});
</script>mics.addIdentifier(
"USER_ACCOUNT",
{
$user_account_id:"account 1",
$compartment_token:"token1"
}
);
mics.addIdentifier(
"USER_ACCOUNT",
{
$user_account_id:"account 2",
$compartment_token:"token2"
});
);
mics.addIdentifier(
"USER_EMAIL",
{
$email_hash:"email hash",
$email:"email address"
}
);
mics.addIdentifier(
"USER_AGENT",
{
$user_agent_id:"user agent id"
}
);mics.pushDefault();mics.push("view my form", {
"form subject": "auto trial"
});// Add the user account id if available
mics.addIdentifier(
"USER_ACCOUNT",
{
$user_account_id:"<USER_ACCOUNT_ID>",
$compartment_token:"<COMPARTMENT_TOKEN>"
}
);
// Push the event
mics.push("$home_view");// Add the user account id if available
mics.addIdentifier(
"USER_ACCOUNT",
{
$user_account_id:"<USER_ACCOUNT_ID>",
$compartment_token:"<COMPARTMENT_TOKEN>"
}
);
// Push the event
mics.push("$item_list_view", {
"$items": [
{"$id": "78798978"},
{"$id": "444444"},
{"$id": "78808900"}
]
});// Add the user account id if available
mics.addIdentifier(
"USER_ACCOUNT",
{
$user_account_id:"<USER_ACCOUNT_ID>",
$compartment_token:"<COMPARTMENT_TOKEN>"
}
);
// Push the event
mics.push("$item_view", {
"$items": [
{ "$id": "89999999" }
]
});// Add the user account id if available
mics.addIdentifier(
"USER_ACCOUNT",
{
$user_account_id:"<USER_ACCOUNT_ID>",
$compartment_token:"<COMPARTMENT_TOKEN>"
}
);
// Push the event
mics.push("$basket_view", {
"$items" : [
{"$id" : "78794", "$price" : 10.8, "$qty" : 1 },
{"$id" : "78677", "$price" : 56.99, "$qty" : 1 }
],
"$currency" : "EUR"
});// Add the user account id if available
mics.addIdentifier(
"USER_ACCOUNT",
{
$user_account_id:"<USER_ACCOUNT_ID>",
$compartment_token:"<COMPARTMENT_TOKEN>"
}
);
// Push the event
mics.push("$transaction_confirmed", {
"$items" : [
{"$id" : "78794", "$price" : 10.8, "$qty" : 1 },
{"$id" : "78677", "$price" : 56.99, "$qty" : 1 }
],
"$transaction_id" : "transact-XYZ",
"$currency" : "EUR"
});// Add the user account id if available
mics.addIdentifier(
"USER_ACCOUNT",
{
$user_account_id:"<USER_ACCOUNT_ID>",
$compartment_token:"<COMPARTMENT_TOKEN>"
}
);
// Push the profile
mics.push("$set_user_profile_properties", {
gender: "male",
// add any other properties you whish
});umbrella_corp.push(
'$set_user_profile_properties',
{
'gender': 'female'
}
);umbrella_corp.push(
'$set_user_profile_properties',
{
'$set_user_profile_comp_token': 'my_compartment_token',
'gender': 'female'
}
);umbrella_corp.push(
'$set_user_profile_properties',
{
'$set_user_profile_comp_token': 'my_compartment_token',
'$set_user_profile_user_account_id': '456',
'gender': 'female'
}
);<script type="text/javascript">
/* YOU SHOULD NOT EDIT THIS PART */
!function(t,e,a){"use strict";var i=t.scimhtiraidem||{};function s(t){var e=i[a]||{};i[a]=e,e[t]||(e[t]=function(){i._queue[a].push({method:t,args:Array.prototype.slice.apply(arguments)})})}t.googletag=t.googletag||{},t.googletag.cmd=t.googletag.cmd||[],t.googletag.cmd.push(function(){var e=t.localStorage.getItem("mics_sgmts"),a=JSON.parse(e),i=a||{};Object.keys(i).forEach(function(e){t.googletag.pubads().setTargeting("mics_"+e,i[e].map(String))})});var r="init call config push pushDefault addIdentifier addProperties addProperty onFinish onStart _reset".split(" ");i._queue=i._queue||{},i._names=i._names||[],i._names.push(a),i._queue[a]=i._queue[a]||[],i._startTime=(new Date).getTime(),i._snippetVersion="2.0";for(var o=0;o<r.length;o++)s(r[o]);t.scimhtiraidem=i,t[a]=i[a];var n=e.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src","https://static.mediarithmics.com/tag/2/tag.min.js"),n.setAttribute("async","true"),e.getElementsByTagName("script")[0].parentNode.appendChild(n)}(window,document,"mics");
mics.init("<SITE_TOKEN>")
mics.push("hit", {})
</script><script type="text/javascript">
/* YOU SHOULD NOT EDIT THIS PART */
!function(t,e,a){"use strict";var i=t.scimhtiraidem||{};function s(t){var e=i[a]||{};i[a]=e,e[t]||(e[t]=function(){i._queue[a].push({method:t,args:Array.prototype.slice.apply(arguments)})})}t.googletag=t.googletag||{},t.googletag.cmd=t.googletag.cmd||[],t.googletag.cmd.push(function(){var e=t.localStorage.getItem("mics_sgmts"),a=JSON.parse(e),i=a||{};Object.keys(i).forEach(function(e){t.googletag.pubads().setTargeting("mics_"+e,i[e].map(String))})});var r="init call config push pushDefault addIdentifier addProperties addProperty onFinish onStart _reset".split(" ");i._queue=i._queue||{},i._names=i._names||[],i._names.push(a),i._queue[a]=i._queue[a]||[],i._startTime=(new Date).getTime(),i._snippetVersion="2.0";for(var o=0;o<r.length;o++)s(r[o]);t.scimhtiraidem=i,t[a]=i[a];var n=e.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src","https://static.mediarithmics.com/tag/2/tag.min.js"),n.setAttribute("async","true"),e.getElementsByTagName("script")[0].parentNode.appendChild(n)}(window,document,"mics");
function micsGetAllProperties() {
var data={};
if (Object.keys(dataLayer).length > 0) {
dataLayer.forEach((item, index) => {
Object.keys(item).forEach( key => {
if (isNaN(key) && key!="event" && !key.startsWith("gtm")) {
data[key] = item[key];
}
})
})
}
return data;
};
mics.init("<SITE_TOKEN>")
mics.push("hit", { "data": micsGetAllProperties()})
</script><script type="text/javascript">
/* YOU SHOULD NOT EDIT THIS PART */
!function(t,e,a){"use strict";var i=t.scimhtiraidem||{};function s(t){var e=i[a]||{};i[a]=e,e[t]||(e[t]=function(){i._queue[a].push({method:t,args:Array.prototype.slice.apply(arguments)})})}t.googletag=t.googletag||{},t.googletag.cmd=t.googletag.cmd||[],t.googletag.cmd.push(function(){var e=t.localStorage.getItem("mics_sgmts"),a=JSON.parse(e),i=a||{};Object.keys(i).forEach(function(e){t.googletag.pubads().setTargeting("mics_"+e,i[e].map(String))})});var r="init call config push pushDefault addIdentifier addProperties addProperty onFinish onStart _reset".split(" ");i._queue=i._queue||{},i._names=i._names||[],i._names.push(a),i._queue[a]=i._queue[a]||[],i._startTime=(new Date).getTime(),i._snippetVersion="2.0";for(var o=0;o<r.length;o++)s(r[o]);t.scimhtiraidem=i,t[a]=i[a];var n=e.createElement("script");n.setAttribute("type","text/javascript"),n.setAttribute("src","https://static.mediarithmics.com/tag/2/tag.min.js"),n.setAttribute("async","true"),e.getElementsByTagName("script")[0].parentNode.appendChild(n)}(window,document,"mics");
mics.init("<SITE_TOKEN>")
mics.push("hit", { "data": tc_vars})
</script>




{
"first_result": 0,
"count": 0,
"max_results": 0,
"status": "ok",
"data": [
{
"id": "string",
"children_ids": [
"string"
],
"audience_features_ids": [
"string"
],
"parent_id": "string",
"datamart_id": "string",
"name": "string"
}
],
"total": 0
}{
"first_result": 0,
"count": 0,
"max_results": 0,
"status": "ok",
"data": [
{
"id": "string",
"children_ids": [
"string"
],
"audience_features_ids": [
"string"
],
"parent_id": "string",
"datamart_id": "string",
"name": "string"
}
],
"total": 0
}// Create a standard segment builder payload
{
"datamart_id": "string",
"demographics_features_ids": [
"string"
],
"name": "string"
}// Edit a standard segment builder payload
{
"datamart_id": "string",
"demographics_features_ids": [
"string"
],
"name": "string"
}// Create a dashboard payload example
[
{
"id": "1",
"name": "Standard segment builder",
"type": "AUDIENCE_BUILDER",
"datamart_id": "xxxx",
"components": [
{
"layout": {
"h": 1,
"static": false,
"w": 6,
"x": 0,
"y": 0
},
"component": {
"id": 2,
"component_type": "COUNT",
"title": "User Profiles",
"query_id": "22252"
}
},
{
"layout": {
"h": 1,
"static": false,
"w": 6,
"x": 6,
"y": 0
},
"component": {
"id": 2,
"component_type": "COUNT",
"title": "User Cookies",
"query_id": "22264"
}
},
{
"layout": {
"h": 3,
"static": false,
"w": 12,
"x": 0,
"y": 1
},
"component": {
"id": 5,
"component_type": "MAP_BAR_CHART",
"title": "Genre",
"show_legend": true,
"query_id": "47031",
"sortKey": "A-Z",
"percentage": true,
"labels": {
"enable": true,
"filterValue": "",
"format": "{point.y}%"
},
"tooltip": {
"formatter": "{point.y}% ({point.count})"
}
}
},
{
"layout": {
"h": 3,
"static": false,
"w": 12,
"x": 0,
"y": 4
},
"component": {
"id": 5,
"component_type": "COUNT_BAR_CHART",
"labels_enabled": true,
"plot_labels": [
"Email",
"Print",
"Sms",
"Tel",
"Web",
"App"
],
"title": "Contactabilité",
"show_legend": false,
"query_ids": [
"47033",
"47034",
"47035",
"47036",
"47037",
"47038"
]
}
}
]
}
]level1,level2, ... ,final_valuelevel1,level2,level3,level4,final_value
activities,channel_id,,,my channel id1
segments,creation_ts,,,123
...{
"status": "ok",
"data": {
"parameters": null,
"result": null,
"error": null,
"id": "xxxxxx",
"status": "PENDING",
"creation_date": 1634134417792,
"start_date": null,
"duration": null,
"organisation_id": "xxxx",
"user_id": "xxxx",
"cancel_status": null,
"debug": null,
"is_retryable": false,
"num_tasks": null,
"completed_tasks": null,
"erroneous_tasks": null,
"retry_count": 0,
"permalink_uri": null,
"job_type": "REFERENCE_TABLE",
"import_mode": "MANUAL_FILE",
"import_type": null
}
}curl -k --location --request POST 'https://api.mediarithmics.com/v1/datamarts/{datamart_id}/reference_table_job_executions' \
-H 'Content-Type: text/csv' \
-H 'Authorization: TOKEN' \
--data-binary '@./final_value_file.csv'



// Sample document import object
{
"document_type": "USER_ACTIVITY",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}{
"status": "ok",
"data": {
"id": "36271",
"datafarm_key": "DF_KEY",
"datamart_id": "DATAMART_ID",
"document_type": "USER_PROFILE",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "YOUR_DOCUMENT_IMPORT_NAME",
"priority": "MEDIUM",
"shuffle_lines" : true,
"use_processing_pipeline" : false
}
}curl -X POST \
"https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports"
-H 'Authorization: <YOUR_API_TOKEN>'
-H 'Content-Type: application/json'
-d '{
"document_type": "USER_ACTIVITY",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'{
"status": "ok",
"data": [
{
"id": "19538",
"datafarm_key": "DF_KEY",
"datamart_id": "DATAMART_ID",
"document_type": "USER_PROFILE",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "December 2020 user profiles",
"priority": "MEDIUM",
"shuffle_lines" : true,
"use_processing_pipeline" : false
},
{
"id": "19552",
"datafarm_key": "DF_KEY",
"datamart_id": "DATAMART_ID",
"document_type": "USER_PROFILE",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "January 2021 user profiles",
"priority": "MEDIUM",
"shuffle_lines" : true,
"use_processing_pipeline" : false
},
{
"id": "19553",
"datafarm_key": "DF_EU_2020_02",
"datamart_id": "1509",
"document_type": "USER_PROFILE",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "February 2021 user profiles",
"priority": "MEDIUM",
"shuffle_lines" : true,
"use_processing_pipeline" : false
}
],
"count": 3,
"total": 3,
"first_result": 0,
"max_result": 50,
"max_results": 50
}{
"status": "ok",
"data": {
"id": "36271",
"datafarm_key": "DF_KEY",
"datamart_id": "DATAMART_ID",
"document_type": "USER_PROFILE",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "December 2020 user profiles",
"priority": "MEDIUM",
"shuffle_lines" : true,
"use_processing_pipeline" : false
}
}{
"status": "ok",
"data": {
"id": "36271",
"datafarm_key": "DF_KEY",
"datamart_id": "DATAMART_ID",
"document_type": "USER_PROFILE",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "YOUR_DOCUMENT_IMPORT_NAME",
"priority": "MEDIUM",
"shuffle_lines" : true,
"use_processing_pipeline" : false
}
}{
"status": "ok",
"data": {
"parameters": null,
"result": null,
"error": null,
"id": "11597785",
"status": "PENDING",
"creation_date": 1609410143659,
"start_date": null,
"duration": null,
"organisation_id": "1426",
"user_id": null,
"cancel_status": null,
"debug": null,
"is_retryable": false,
"permalink_uri": "MTowOjA6NDI1MzAxMg==",
"num_tasks": null,
"completed_tasks": null,
"erroneous_tasks": null,
"retry_count": 0,
"job_type": "DOCUMENT_IMPORT",
"import_mode": "MANUAL_FILE",
"import_type": null
}
}curl --location --request POST 'https://api.mediarithmics.com/v1/datamarts/:datamartId/document_imports/:executionId/executions/' \
--header 'Content-Type: application/x-ndjson; \
--header 'Authorization: api:TOKEN' \
--data-binary '@/Users/username/path/to/the/file.ndjson'{
"status": "ok",
"data": [
{
"parameters": {
"datamart_id": 1609,
"document_import_id": 19718,
"mime_type": "APPLICATION_X_NDJSON",
"document_type": "USER_PROFILE",
"input_file_name": "requestBody9664967795462448677asRaw",
"file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody9664967795462448677asRaw-2020-12-31_10.22.23-KzgivDim3y.json",
"number_of_lines": 4,
"segment_id": null
},
"result": {
"total_success": 4,
"total_failure": 0,
"input_file_name": "requestBody9664967795462448677asRaw",
"input_file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody9664967795462448677asRaw-2020-12-31_10.22.23-KzgivDim3y.json",
"error_file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody9664967795462448677asRaw-2020-12-31_10.22.23-KzgivDim3y_errors.csv",
"possible_issue_on_identifiers": false,
"top_identifiers": {}
},
"error": null,
"id": "11597785",
"status": "SUCCEEDED",
"creation_date": 1609410143659,
"start_date": 1609410150976,
"duration": 3059,
"organisation_id": "1426",
"user_id": null,
"cancel_status": null,
"debug": null,
"is_retryable": false,
"permalink_uri": "MTowOjA6NDI1MzAxMg==",
"num_tasks": 4,
"completed_tasks": 4,
"erroneous_tasks": 0,
"retry_count": 0,
"job_type": "DOCUMENT_IMPORT",
"import_mode": "MANUAL_FILE",
"import_type": null,
"end_date": 1609410154035
},
{
"parameters": {
"datamart_id": 1609,
"document_import_id": 19718,
"mime_type": "APPLICATION_X_NDJSON",
"document_type": "USER_PROFILE",
"input_file_name": "requestBody17471990940413569967asRaw",
"file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody17471990940413569967asRaw-2020-10-19_09.54.45-JvP1ssxKSu.json",
"number_of_lines": 4,
"segment_id": null
},
"result": {
"total_success": 0,
"total_failure": 4,
"input_file_name": "requestBody17471990940413569967asRaw",
"input_file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody17471990940413569967asRaw-2020-10-19_09.54.45-JvP1ssxKSu.json",
"error_file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody17471990940413569967asRaw-2020-10-19_09.54.45-JvP1ssxKSu_errors.csv",
"possible_issue_on_identifiers": false,
"top_identifiers": {}
},
"error": {
"message": "0 success, 4 failures\nSaved errors:\nNo profile id found while upserting a user profile Error id = 9d5016ea-6b7b-4c64-bc74-60ba207e3bed.\nNo profile id found while upserting a user profile Error id = 99f8d9bb-4c94-49ea-8bb2-934bc6056cac.\nNo profile id found while upserting a user profile Error id = d1216b0e-619c-4d92-9098-cc5ae4ac8e16.\nNo profile id found while upserting a user profile Error id = a92d3258-163c-4b9d-949e-94f9006cd77d.\n"
},
"id": "11170897",
"status": "SUCCEEDED",
"creation_date": 1603101286198,
"start_date": 1603101317674,
"duration": 1062,
"organisation_id": "1426",
"user_id": null,
"cancel_status": null,
"debug": null,
"is_retryable": false,
"permalink_uri": "MTowOjA6MzgyNjEyNA==",
"num_tasks": 4,
"completed_tasks": 0,
"erroneous_tasks": 4,
"retry_count": 0,
"job_type": "DOCUMENT_IMPORT",
"import_mode": "MANUAL_FILE",
"import_type": null,
"end_date": 1603101318736
}
],
"count": 2,
"total": 2,
"first_result": 0,
"max_result": 50,
"max_results": 50
}{
"status": "ok",
"data": {
"parameters": {
"datamart_id": 1609,
"document_import_id": 19718,
"mime_type": "APPLICATION_X_NDJSON",
"document_type": "USER_PROFILE",
"input_file_name": "requestBody9664967795462448677asRaw",
"file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody9664967795462448677asRaw-2020-12-31_10.22.23-KzgivDim3y.json",
"number_of_lines": 4,
"segment_id": null
},
"result": {
"total_success": 4,
"total_failure": 0,
"input_file_name": "requestBody9664967795462448677asRaw",
"input_file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody9664967795462448677asRaw-2020-12-31_10.22.23-KzgivDim3y.json",
"error_file_uri": "mics://data_file/tenants/1426/datamarts/1509/document_imports/19518/requestBody9664967795462448677asRaw-2020-12-31_10.22.23-KzgivDim3y_errors.csv",
"possible_issue_on_identifiers": false,
"top_identifiers": {}
},
"error": null,
"id": "11597785",
"status": "SUCCEEDED",
"creation_date": 1609410143659,
"start_date": 1609410150976,
"duration": 3059,
"organisation_id": "1426",
"user_id": null,
"cancel_status": null,
"debug": null,
"is_retryable": false,
"permalink_uri": "MTowOjA6NDI1MzAxMg==",
"num_tasks": 4,
"completed_tasks": 4,
"erroneous_tasks": 0,
"retry_count": 0,
"job_type": "DOCUMENT_IMPORT",
"import_mode": "MANUAL_FILE",
"import_type": null,
"end_date": 1609410154035
}
}{
"status": "ok",
"data": {
"parameters": null,
"result": null,
"error": null,
"id": "22747195",
"status": "CANCELED",
"creation_date": 1646060596034,
"start_date": null,
"duration": null,
"organisation_id": "1581",
"user_id": null,
"cancel_status": "REQUESTED",
"debug": null,
"is_retryable": false,
"community_id": "1581",
"num_tasks": null,
"completed_tasks": null,
"erroneous_tasks": null,
"retry_count": 0,
"permalink_uri": null,
"job_type": "DOCUMENT_IMPORT",
"import_mode": "MANUAL_FILE",
"import_type": null
}
}split -l <LINE_NUMBER> ./your/file/pathtype UserPoint @TreeIndexRoot(index:"USER_INDEX"){
id: ID!
creation_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
creation_date:Date! @Function(name:"ISODate", params:["creation_ts"])
# User identifiers
accounts: [UserAccount!]!
emails: [UserEmail!]!
devices: [UserDevicePoint!]!
# User content
activities: [UserActivity!]!
events: [UserEvent!]!
profiles: [UserProfile!]!
choices: [UserChoice!]!
# Technical objects
scenarios: [UserScenario!]!
segments: [UserSegment!]!
# Deprecated identifiers
# agents: [UserAgent!]!
}
### User identifiers
type UserAccount {
id:ID! @TreeIndex(index:"USER_INDEX")
creation_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
creation_date:Date! @TreeIndex(index:"USER_INDEX") @Function(params:["creation_ts"], name:"ISODate")
compartment_id: String! @TreeIndex(index:"USER_INDEX") @ReferenceTable(model_type:"COMPARTMENTS", type:"CORE_OBJECT")
user_account_id: String! @TreeIndex(index:"USER_INDEX")
}
type UserEmail {
id:ID! @TreeIndex(index:"USER_INDEX")
creation_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
last_activity_ts: Timestamp @TreeIndex(index:"USER_INDEX")
email: String @TreeIndex(index:"USER_INDEX")
}
type UserDevicePoint {
id:ID! @TreeIndex(index:"USER_INDEX")
creation_ts:Timestamp! @TreeIndex(index:"USER_INDEX")
creation_date:Date! @Function(name:"ISODate", params:["creation_ts"])
device_info:DeviceInfo
technical_identifiers:[UserDeviceTechnicalId!]!
mappings:[UserAgentMapping!]! @Function(name:"ThirdPartyCookieMappings", params:["id"])
}
type DeviceInfo {
brand:String @TreeIndex(index:"USER_INDEX")
browser_version:String @TreeIndex(index:"USER_INDEX")
carrier:String @TreeIndex(index:"USER_INDEX")
model:String @TreeIndex(index:"USER_INDEX")
os_version:String @TreeIndex(index:"USER_INDEX")
agent_type:UserAgentType @TreeIndex(index:"USER_INDEX")
browser_family:BrowserFamily @TreeIndex(index:"USER_INDEX")
form_factor:FormFactor @TreeIndex(index:"USER_INDEX")
os_family:OperatingSystemFamily @TreeIndex(index:"USER_INDEX")
}
type UserDeviceTechnicalId {
id:ID! @TreeIndex(index:"USER_INDEX")
creation_ts:Timestamp! @TreeIndex(index:"USER_INDEX")
expiration_ts:Timestamp! @TreeIndex(index:"USER_INDEX")
last_seen_ts:Timestamp! @TreeIndex(index:"USER_INDEX")
registry_id:String! @TreeIndex(index:"USER_INDEX")
type:String! @TreeIndex(index:"USER_INDEX")
}
type UserAgentMapping {
last_seen:Timestamp
user_agent_id:String @TreeIndex(index:"USER_INDEX")
vector_id:String
}
### User content
type UserActivity {
id: ID!
type: UserActivityType!
channel_id:String @TreeIndex(index:"USER_INDEX") @ReferenceTable(type:"CORE_OBJECT", model_type:"CHANNELS") @Property(paths:["$site_id", "$app_id"])
source: UserActivitySource!
ts: Timestamp! @TreeIndex(index:"USER_INDEX")
duration: Int @TreeIndex(index:"USER_INDEX")
events: [UserEvent!]!
}
type UserEvent @Mirror(object_type:"UserEvent") {
id: ID!
ts: Timestamp! @TreeIndex(index:"USER_INDEX")
date:Date! @Function(params:["ts"], name:"ISODate")
name:String! @TreeIndex(index:"USER_INDEX")
channel_id:String @TreeIndex(index:"USER_INDEX") @ReferenceTable(model_type:"CHANNELS", type:"CORE_OBJECT") @Property(paths:["[parent].$site_id", "[parent].$app_id"])
url: String @TreeIndex(index:"USER_INDEX")
referrer:String @TreeIndex(index:"USER_INDEX")
}
type UserProfile {
id: ID!
creation_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
last_modified_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
compartment_id: String! @TreeIndex(index:"USER_INDEX") @ReferenceTable(model_type:"COMPARTMENTS", type:"CORE_OBJECT")
user_account_id: String @TreeIndex(index:"USER_INDEX")
}
type UserChoice {
id: ID!
creation_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
choice_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
processing_id: String! @TreeIndex(index:"USER_INDEX")
choice_acceptance_value: Boolean! @TreeIndex(index:"USER_INDEX")
user_account_id: String
compartment_id: String
email_hash: String
user_agent_id: String
channel_id: String
}
### Technical objects
type UserSegment {
id: ID! @TreeIndex(index:"USER_INDEX") @ReferenceTable(model_type:"SEGMENTS", type:"CORE_OBJECT")
creation_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
last_modified_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
expiration_ts: Timestamp @TreeIndex(index:"USER_INDEX")
}
type UserScenario {
id: ID! @TreeIndex(index:"USER_INDEX")
scenario_id: String! @TreeIndex(index:"USER_INDEX")
execution_id: String! @TreeIndex(index:"USER_INDEX")
node_id: String! @TreeIndex(index:"USER_INDEX")
callback_ts: Timestamp @TreeIndex(index:"USER_INDEX")
start_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
node_start_ts: Timestamp! @TreeIndex(index:"USER_INDEX")
active: Boolean @TreeIndex(index:"USER_INDEX")
}
### Deprecated identifiers
# type UserAgent {
# id:ID!
# creation_ts: Timestamp!
# last_activity_ts: Timestamp
# user_agent_info:UserAgentInfo @Function(name:"DeviceInfo", params:["id"])
# }
# type UserAgentInfo {
# form_factor:FormFactor
# brand:String
# browser_family:BrowserFamily
# browser_version:String
# carrier:String
# model:String
# os_family:OperatingSystemFamily
# os_version:String
# agent_type:UserAgentType
# }type MyType {
user_account_id: String # doesn't necessarily have a user account
user_account_id: String! # has a user account
events: [UserEvent!]! # has a list of events, in which each event can't be null
events: [UserEvent!] # doesn't necessarily have a list of events, but lists can't have null elements
}type UserChoice {
id: ID!
}type UserProfile {
id: ID!
creation_ts: Timestamp
email: String
age: Int
active: Boolean
}// Origin activity
{
...
"$ts": 1632753811859,
"other_date": "2021-09-27T14:43:31.859Z",
"other_ts": 1632753811859
...
}type UserActivity {
...
ts: Timestamp @TreeIndex(index:"USER_INDEX")
other_date: Date
other_ts: Timestamp
date: Date @Function(name:"ISODate", params:["ts"])
...
}
## Doing SELECT { ts other_date other_ts date } ...
## returns
## "ts": 1632753811859,
## "other_date": "2021-09-27T14:43:31.859Z",
## "other_ts": 1632753811859,
## "date": "2021-09-27T14:43:31.859Z",// Origin activity
{
...
"other_date": 1632753811859,
...
}
type UserActivity {
# This won't work as received data is a timestamp.
other_date: Date
}
## SELECT { other_date } ...
## throws an errortype UserPoint @TreeIndexRoot(index:"USER_INDEX"){
}type UserEvent {
id:ID!
ts:Timestamp!
# url and referrr properties are now available in WHERE clauses
url:String @TreeIndex(index:"USER_INDEX")
referrer:String @TreeIndex(index:"USER_INDEX")
}type myType {
mystring:String @TreeIndex(index:"USER_INDEX", data_type: "text")
secondstring:String @TreeIndex(index:"USER_INDEX", data_type: "keyword")
}type UserEvent {
id:ID!
ts:Timestamp!
name:String!
# We are creating shortcuts to the $url, $referrer and $items properties
# that are normaly in a $properties object in the user event.
# This will make them easier to query
url:String @Property(path:"$properties.$url")
referrer:String @Property(path:"$properties.$referrer")
products:[Product] @Property(path:"$properties.$items")
}
type Product {
# Here we simply change the name into id and name instead of $id and $name
id: String @TreeIndex(index:"USER_INDEX") @Property(path:"$id")
name: String @TreeIndex(index:"USER_INDEX") @Property(path:"$name")
}type UserPoint {
# What should have been declared
creation_ts: Timestamp! @Property(path:"$creation_ts")
# What is declared as a shortcut
creation_ts: Timestamp!
}
type Product {
# We do have to use the @Property directive as those properties
# don't exist in the default schema for a Product object type
id: String @Property(path:"$id")
name: String @Property(path:"$name")
}type MyType {
channel_id: String @Property(paths:["$site_id", "$app_id"])
}type MyType {
creative_id:String @Property(path:"[parent].[parent].$origin.$creative_id")
}# UserEvent type has been renamed ArticleView
# Not really interesting and should be avoided
type ArticleView @Mirror(object_type:"UserEvent"){}
# More advanced usage : ArticleView object are UserEvents
# with a name of "navigation.article"
type ArticleView @Mirror(object_type:"UserEvent", filter:"name == \"navigation.article\""){}type UserPoint @TreeIndexRoot(index:"USER_INDEX"){
###
basketviews: [BasketView]
productviews: [ProductView]
}
type BasketView @Mirror(object_type:"UserEvent", filter:"name == \"$basket_view\""){}
type ProductView @Mirror(object_type:"UserEvent", filter:"name == \"$page_view\""){}type MyType {
# creation_date is a Date created from the timestamp creation_ts
creation_date:Date! @Function(name:"ISODate", params:["creation_ts"])
}type UserDevicePoint {
id:ID! @TreeIndex(index:"USER_INDEX")
...
mappings:[UserAgentMapping!]! @Function(name:"ThirdPartyCookieMappings", params:["id"])
}
type UserAgentMapping {
last_seen:Timestamp
user_agent_id:String
vector_id:String
}type UserAgent {
id:ID! @TreeIndex(index:"USER_INDEX")
user_agent_info:UserAgentInfo @Function(name:"DeviceInfo", params:["id"])
}type UserAgentInfo {
form_factor:FormFactor
brand:String
browser_family:BrowserFamily
browser_version:String
carrier:String
model:String
os_family:OperatingSystemFamily
os_version:String
agent_type:UserAgentType
}
### The following enums are predefined.
### It is not necessary to define them
enum FormFactor {
WEARABLE_COMPUTER
TABLET
SMARTPHONE
GAME_CONSOLE
SMART_TV
PERSONAL_COMPUTER
OTHER
}
enum BrowserFamily {
OTHER
CHROME
IE
FIREFOX
SAFARI
OPERA
STOCK_ANDROID
BOT
EMAIL_CLIENT
MICROSOFT_EDGE
}
enum OperatingSystemFamily {
OTHER
WINDOWS
MAC_OS
LINUX
ANDROID
IOS
}
enum UserAgentType {
WEB_BROWSER
MOBILE_APP
}type UserSegment {
id:ID! @ReferenceTable(type:"CORE_OBJECT", model_type:"SEGMENTS") @TreeIndex(index:"USER_INDEX")
}
type UserActivity {
channel_id:String @ReferenceTable(model_type:"CHANNELS", type:"CORE_OBJECT") @TreeIndex(index:"USER_INDEX") @Property(paths:["$site_id", "$app_id"])
}
type UserProfile {
compartment_id:String! @ReferenceTable(model_type:"COMPARTMENTS", type:"CORE_OBJECT") @TreeIndex(index:"USER_INDEX")
}
type UserEvent {
channel_id:String @ReferenceTable(model_type:"CHANNELS", type:"CORE_OBJECT") @Property(paths:["[parent].$site_id", "[parent].$app_id"]) @TreeIndex(index:"USER_INDEX")
}type UserAccount {
id:ID!
# This property won't be usable in Edge segment queries
compartment_id:String!
# This property will be usable in Edge segment queries
user_account_id:String! @TreeIndex(index:"USER_INDEX") @EdgeAvailability
}type UserPoint {
id: ID!
accounts: [UserAccount]
…
rfm_score: RfmScore @ComputedField(technical_name = “RfmScore”) @TreeIndex(index:"USER_INDEX")
}
type RfmScore {
…
}type UserProfile {
…
loyalty: Loyalty
}
type Loyalty {
cards:[LoyaltyCards]
}
type LoyaltyCards {
card_id : String! @UpdateStrategyKey
benefits : String
last_visit_date : String
}# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
segmentations: [Segmentation]
}
type Segmentation @UpdateValueObject {
type: String
label: String
}# DO
type UserAgent {
creation_ts:Timestamp! @TreeIndex(index:"USER_INDEX")
creation_date:Date! @Function(name:"ISODate", params:["creation_ts"])
user_agent_info:UserAgentInfo @Function(params:["id"], name:"DeviceInfo")
id:ID!
last_activity_ts:Timestamp
}
# DON'T
type UserAgent {
creation_ts:Timestamp!
creation_date:Date! @Function(name:"ISODate", params:["creation_ts"]) @TreeIndex(index:"USER_INDEX")
user_agent_info:UserAgentInfo @Function(params:["id"], name:"DeviceInfo")
id:ID!
last_activity_ts:Timestamp
}# Only do if in a specific scenario requiring it
type UserPoint @TreeIndexRoot(index:"USER_INDEX"){
###
activities: [UserActivity!]!
events:[UserEvent!]!
}
type UserActivity {
###
events: [UserEvent!]!
}
type UserEvent @Mirror(object_type:"UserEvent") {
name:String! @TreeIndex(index:"USER_INDEX")
id:ID!
ts:Timestamp!
}@UpdateStrategyKey directive@UpdateStrategyKey directive@UpdateStrategyKey directive@UpdateStrategyKey directivecurl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
-H 'Authorization: <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"document_type": "USER_PROFILE",
"mime_type": "APPLICATION_X_NDJSON",
"encoding": "utf-8",
"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'# Here we use the combination of compartment_id and user_account_id acting as identifier
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '{
"operation": "UPSERT",
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"user_profile": {
this": "is",
"a":"test"
}
}'# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
loyalty: [Loyalty]
}
type Loyalty {
cards : [Cards]
}
type Cards {
card_id: String! @UpdateStrategyKey
benefits: String
last_visit_date: String
}// Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc",
"benefits": 500,
"last_visit_date": "2024-01-01"
}
]
}
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [ //adding a new cards object
{
"card_id": "def",
"benefits": 100,
"last_visit_date": "2025-01-01"
}
]
}
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [ // the cards object contains both cards
{
"card_id": "abc",
"benefits": 500,
"last_visit_date": "2024-01-01"
},
{
"card_id": "def",
"benefits": 100,
"last_visit_date": "2025-01-01"
}
]
}
}# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
loyalty: [Loyalty]
}
type Loyalty {
cards : [Cards]
}
type Cards {
card_id: String! @UpdateStrategyKey
benefits: String
last_visit_date: String
}// Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc",
"benefits": 500,
"last_visit_date": "2024-01-01"
}
]
}
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [ //request changing the benefits value of the existing card
{
"card_id": "abc", // value of the field marked with @UpdateStrategyKey of the inner object to update
"benefits": 100
}
]
}
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [ //
{
"card_id": "abc",
"benefits": 100, // value has been updated
"last_visit_date": "2024-01-01"
}
]
}
}// Extract of existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"my_array_of_scalars": [1,2,3],
...
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"my_array_of_scalars": [4,5,6],
...
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"my_array_of_scalars": [4,5,6], // the value of the property has been replaced by the new value
...
}
# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
loyalty: [Loyalty]
}
type Loyalty {
cards : [Cards]
}
type Cards {
card_id: String! @UpdateStrategyKey
benefits: String
last_visit_date: String
}// Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc",
"benefits": 500,
"last_visit_date": "2024-01-01"
}
]
}
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc",
"benefits": null // set the value to null
}
]
}
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [ // benefits value has been cleared
{
"card_id": "abc",
"last_visit_date": "2024-01-01"
}
]
}
}# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
loyalty: [Loyalty]
}
type Loyalty {
cards : [Cards]
}
type Cards {
card_id: String! @UpdateStrategyKey
benefits: String
last_visit_date: String
}// Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc",
"benefits": 500,
"last_visit_date": "2024-01-01"
}
]
}
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc",
"benefits": 100 //updating exsisting object
},
{
"card_id": "def", //adding a new object
"benefits": 600,
"last_visit_date": "2025-01-01"
}
]
}
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc",
"benefits": 100, // value has been updated
"last_visit_date": "2024-01-01"
},
{
"card_id": "def", // object has been added
"benefits": 600,
"last_visit_date": "2025-01-01"
}
]
}
}# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
loyalty: [Loyalty]
}
type Loyalty {
cards : [Cards]
}
type Cards {
card_id: String! @UpdateStrategyKey
benefits: String
last_visit_date: String
}//Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc",
"benefits": 100,
"last_visit_date": "2024-01-01"
},
{
"card_id": "def",
"benefits": 600,
"last_visit_date": "2025-01-01"
}
]
}
}
//Profile in update payload with update_strategy == PARTIAL_DELETE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"card_id": "abc" // value of the field marked with @UpdateStrategyKey of the inner object to delete
}
]
}
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [ // the card with card_id = "abc" has been deleted
{
"card_id": "def",
"benefits": 600,
"last_visit_date": "2025-01-01"
}
]
}
}
# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
segmentations: [Segmentation]
}
type Segmentation @UpdateValueObject {
type: String
label: String
}//Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"segmentations": [
{ "type": "segRFM", "label": "seg1" },
{ "type": "segRFM", "label": "seg2" }
]
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"segmentations": [ // contains the new value of the object
{ "type": "segOther", "label": "seg3" },
{ "type": "segOther", "label": "seg4" }
]
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"segmentations": [ //full array of objects was replaced
{ "type": "segOther", "label": "seg3" },
{ "type": "segOther", "label": "seg4" }
]
}
# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
geolocation: Geolocation
}
type Geolocation @UpdateValueObject {
address: String
city: String
postal_code : String
}//Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geolocation":
{ "address": "1 first avenue",
"city": "new york",
"postal_code" :"0101"
}
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geolocation":
{ "address": "1 first avenue",
"city": "new york"
}
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geolocation":
{ "address": "1 first avenue",
"city": "new york"
}
}
# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
first_name: String
last_name : String
}//Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"first_name" : "john"
"last_name" : "doe"
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"first_name" : null
"last_name" : "smith"
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"last_name" : "smith"
}
# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
geo_location: GeoLocation
}
type GeoLocation {
address: String
postal_code: String
city: String
country: String
}//Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geo_location": {
"address": "1 main street",
"city": "paris",
"postal_code" : "0001",
"country" : "France"
}
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geo_location": {
"address": null,
"city": "New york",
}
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geo_location": {
"city": "new york",
"postal_code" : "0001",
"country" : "France"
}
}
# Schema extract
type UserProfile {
compartment_id : String!
user_account_id : String
geo_location: GeoLocation
}
type GeoLocation {
address: String
postal_code: String
city: String
country: String
}//Existing profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geo_location": {
"address": "1 main street",
"city": "paris",
"postal_code" : "0001",
"country" : "France"
}
}
//Profile in update payload with update_strategy == PARTIAL_UPDATE
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geo_location": {
"address": "52 fifth avenue",
"city": "New York City",
"postal_code" : "12345",
"country" : "USA"
}
}
//New profile
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"geo_location": {
"address": "52 fifth avenue",
"city": "New York City",
"postal_code" : "12345",
"country" : "USA"
}
}
#This is allowed
type LoyaltyCard {
card_id:String @UpdateStrategyKey
benefits: Int
last_visit_date: String
other_information : [OtherInformation]
}
type OtherInformation {
info_id: String @UpdateStrategyKey
}
################################
#This is not allowed
type LoyaltyCard {
card_id:String @UpdateStrategyKey
benefits: Int @UpdateStrategyKey
last_visit_date: Date
}
# Stored profile:
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"benefits": 200,
"card_id": "abc",
"last_visit_date": "2024-01-01"
}
]
}
}
# New profile in request payload
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '{
"operation": "UPSERT",
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"update_strategy": "FORCE_REPLACE",
"user_profile": {
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"benefits": 500,
"card_id": "xyz",
"last_visit_date": "2025-01-01"
}
]
}
}
}'
# New saved profile:
{
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"loyalty": {
"cards": [
{
"benefits": 500,
"card_id": "xyz",
"last_visit_date": "2025-01-01"
}
]
}
}# Stored profile:
{
"my_property_1": "value1",
"my_property_2": "value1",
"my_array_property": ["value1"]
"my_array_object_property": [
{
"my_sub_array_object_property_1": "value1",
"my_sub_array_object_property_2": "value1"
}
],
"my_object_property": {
"my_sub_object_property_1": "value1",
"my_sub_object_property_2": "value1"
}
}
# New profile in request payload
curl -X POST \
https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports/<DOCUMENT_IMPORT_ID>/executions \
-H 'Authorization: <API_TOKEN>' \
-H 'Content-Type: application/x-ndjson' \
-d '{
"operation": "UPSERT",
"compartment_id": "<COMPARTMENT_ID>",
"user_account_id": "<USER_ACCOUNT_ID>",
"force_replace": false,
"merge_objects": true,
"user_profile": {
"my_property_2": "value2",
"my_property_3": "value3",
"my_array_property": ["value2"]
"my_array_object_property": [
{
"my_sub_array_object_property_2": "value2"
"my_sub_array_object_property_3": "value3"
}
],
"my_object_property": {
"my_sub_object_property_2": "value2"
"my_sub_object_property_3": "value3"
}
}
}'
# New saved profile:
{
"my_property_1": "value1",
"my_property_2": "value2", # override scalar property
"my_property_3": "value3",
"my_array_property": ["value1","value2"] # merge arrays
"my_array_object_property": [ # merge arrays
{
"my_sub_array_object_property_1": "value1"
"my_sub_array_object_property_2": "value1"
},
{
"my_sub_array_object_property_2": "value2"
"my_sub_array_object_property_3": "value3"
}
],
"my_object_property": { # merge objects
"my_sub_object_property_1": "value1"
"my_sub_object_property_2": "value2" # override scalar property within object
"my_sub_object_property_3": "value3"
}
}SELECT only be apply in userpoint still in the list, after the WHERE filterWHERE clause WHERE SELECT @filter{ activities { id events @filter(clause: "page_type == \"newsarticle\" AND page_category == \"actu\""){ url } } }
FROM UserPoint
WHERE activities { ts >= "now-1d/d" } AND events { page_type == "newsarticle" AND page_category == "actu" }[
[
{
"activities": [
{
"events": [
{
"url": "xxx"
},
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
]
},
{
"events": [],
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
]
}
]
]type UserPoint {
id : ID!
activities : [UserActivity!]!
profiles : [UserProfile!]!
}
type UserActivity {
id : ID!
events : [UserEvent!]!
}
type UserEvent {
id : ID!
name : String
}
type UserProfile {
id : ID!
age : String
}// SELECT <objects fields or aggregates> # fields returned
// FROM <object collection> # where the query will be executed
// WHERE <object tree expression> # filter applied
SELECT { activities { events { name } } }
FROM UserPoint
WHERE activities { events { name = "$transaction_confirmed" } }[
{
activities : [ { events : [ { name : "$page_view" } ] },
{ events : [ { name : "$page_view" },
{ name : "$transaction_confirmed" } ] } ]
}
]# Example : Get all event’s name by user with at least one transaction confirmed
SELECT { activities { events { name } } }
FROM UserPoint
WHERE activities { events { name = "$transaction_confirmed" } }[
{
activities : [ { events : [ { name : "$page_view" },
{ name : "$transaction_confirmed" } ] } ]
},
{
activities : [ { events : [ { name : "$page_view" },
{ name : "$transaction_confirmed" } ] },
{ events : [ { name : "$page_view" } ] } ]
}
]# Example : Get the name of each event where the name is "$trasaction_confirmed"
# Here, we just want to be sure this query return only events we want
SELECT { name }
FROM UserEvent
WHERE name = "$transaction_confirmed"[
{
name : "$transaction_confirmed"
}
]# Example : Get events named "$page_view" by user with at least one transaction confirmed
SELECT { activities { events @filter(clause:"name = \"$page_view\"") { name } } }
FROM UserPoint
WHERE activities { events { name = “$transaction_confirmed” } }[
{
activities : [ { events : [ { name : "$page_view" } ] } ]
},
{
activities : [ { events : [ { name : "$page_view" } ] },
{ events : [ { name : "$page_view" } ] } ]
}
]# Example : Get event’s names by user with at least one transaction confirmed
# and an age between 20 and 30 years old
SELECT { activities { events { name } } }
FROM UserPoint WHERE profiles { age = "20-30" }
AND activities {events { name = "$transaction_confirmed" } }[
{
activities : [ { events : [ { name : "$page_view" },
{ name : "$transaction_confirmed" } ] },
{ events : [ { name : "$page_view" } ] } ]
}
]# Example : Get event’s names by events named "$transaction_confirmed"
# and where the user is between 20 and 30 years old
SELECT { name }
FROM UserEvent WHERE name = "$transaction_confirmed"
JOIN UserPoint WHERE profiles { age == "20-30" }[
{
name : "$transaction_confirmed"
}
]# Example : Get event’s names by events named "$transaction_confirmed"
# and where the user is between 20 and 30 years old
SELECT { name }
FROM UserEvent WHERE name = "$transaction_confirmed"
JOIN UserProfile WHERE age == "20-30"type UserPoint @TreeIndexRoot(index:"USER_INDEX") {
id:ID!
activity_events:[ActivityEvent!]!
}
type ActivityEvent @Mirror(object_type:"UserEvent") {
order:Order @Property(path:"$properties.order")
}
type Order {
order_products:[OrderProduct]!
date: Timestamp!
}
type OrderProduct {
id:String @TreeIndex(index:"USER_INDEX")
price: Float @TreeIndex(index:"USER_INDEX") # in €
category:String @TreeIndex(index:"USER_INDEX") # possible value : "IT" or "Book"
}# More than 1000€ in one order :
SELECT @count{} FROM UserPoint
WHERE activity_events {
order {
order_products @ScoreField(name: "price") @ScoreSum(min: 1000) {
category="IT"
}
}
}
# More than 1000€ in cross orders (explicite):
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000, result:"boolean_value") {
order {
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="IT"
}
}
}
# More than 1000€ in cross orders (implicite):
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name:"price") {
category="IT"
}
}
}
# More than 1000€ in cross orders this last 10 days:
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name:"price") {
category="IT"
}
AND date > "now-10d"
}
}
# More than 1000€ in cross orders with at least products which cost 10€:
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name: "price") @ScoreSum(min: 10, result:"score_value") {
category="IT"
}
}
}
# More than 1000€ in cross orders with at least 10 products :
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name: "price") @ScoreSum(result:"score_value") {
category="IT"
}
AND order_products @ScoreSum(min: 10) {
category="IT"
}
}
}
# More than 1000€ in cross orders with at least one product which costs more than 10€ :
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name: "price") @ScoreSum(result:"score_value") {
category="IT"
}
AND order_products @ScoreField(name: "price") @ScoreMax(min: 10) {
category="IT"
}
}
}
# WARNING : DOES NOT WORK
# More than 1000€ in cross orders with at least 10 orders more than 100€ :
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order @ScoreSum(min: 10, result: "score_value") {
@ScoreSum(min: 100, result: "boolean_value") {
order_products @ScoreField(name: "price") @ScoreSum(result:"score_value") {
category="IT"
}
}
}
}# More than 1000€ in one order :
SELECT @count {} FROM UserPoint
WHERE activity_events {
order {
order_products @ScoreField(name: "price") @ScoreAvg(min: 1000) {
category="IT"
}
}
}
# More than 1000€ in cross orders :
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreAvg(min : 1000) {
order {
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="IT"
}
}
}# More than 1000€ in cross orders in IT or Book category :
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="IT"
OR category="BOOK"
}
}
}
# Same result :
#Doesn't work yet
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="IT"
},
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="BOOK"
}
}
}
# More than 1000€ in cross orders in only with product of IT or Book category :
# maximum of separately IT products and Book products is superior to 1000€
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="IT"
}
OR order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="BOOK"
}
}
}
# More than 1000€ in cross orders of products in IT and products in Book category :
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="IT"
OR category="BOOK"
}
}
}
# More than 1000€ in cross orders in IT and Book category :
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="IT"
}
}
AND activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name:"price") @ScoreSum(result:"score_value") {
category="BOOK"
}
}
}
# More than 1000€ in cross orders with at least 10 IT products and 10 BOOK products :
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name: "amount") @ScoreSum(){
category="IT"
OR category="BOOK"
}
AND order_products @ScoreSum(min: 10) {
category="IT"
}
AND order_products @ScoreSum(min: 10) {
category="BOOK"
}
}
}
### DUPLICATE WITH PREVIOUS QUERY
# More than 1000€ in cross orders in IT or Book category with at least 10€ of each in each order:
SELECT @count {} FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name: "amount") @ScoreSum(){
category="IT"
OR category="BOOK"
}
AND order_products @Scorefield(name: "amount") @ScoreSum(min: 10) {
category="IT"
}
AND order_products @Scorefield(name: "amount") @ScoreSum(min: 10) {
category="BOOK"
}
}
}type UserPoint @TreeIndexRoot(index:"USER_INDEX") {
id:ID!
profiles:[UserProfile!]!
}
type UserProfile {
id:ID!
birth_date:Date @TreeIndex(index:"USER_INDEX")
}SELECT { id }
FROM UserPoint
WHERE profiles { birth_date IN ["now-18y/d", "now-19y/d", "now-20y/d", "now-21y/d",
"now-22y/d", "now-23y/d", "now-24y/d", "now-25y/d", "now-26y/d", "now-27y/d", "now-28y/d"]
}SELECT { id }
FROM UserPoint
WHERE profiles { ( birth_date >= "now-18y/d" AND birth_date < "now+7d-18y" ) OR
( birth_date >= "now-19y/d" AND birth_date < "now+7d-19y" ) OR
( birth_date >= "now-20y/d" AND birth_date < "now+7d-20y" ) OR
( birth_date >= "now-21y/d" AND birth_date < "now+7d-21y" ) OR
( birth_date >= "now-22y/d" AND birth_date < "now+7d-22y" ) OR
( birth_date >= "now-23y/d" AND birth_date < "now+7d-23y" ) OR
( birth_date >= "now-24y/d" AND birth_date < "now+7d-24y" ) OR
( birth_date >= "now-25y/d" AND birth_date < "now+7d-25y" ) OR
( birth_date >= "now-26y/d" AND birth_date < "now+7d-26y" ) OR
( birth_date >= "now-27y/d" AND birth_date < "now+7d-27y" ) OR
( birth_date >= "now-28y/d" AND birth_date < "now+7d-28y" ) }type UserPoint @TreeIndexRoot(index:"USER_INDEX") {
id:ID!
events:[UserEvent!]!
activities:[UserActivity!]!
}
type UserActivity {
id:ID!
events:[UserEvent!]!
}
type UserEvent @Mirror(object_type:"UserEvent") {
id:ID!
event_name:String @Property(path:"$event_name") @TreeIndex(index:"USER_INDEX")
}SELECT { events @filter(clause: "page_type == \"newsarticle\" AND page_category == \"actu\""){ url } }
FROM UserPoint
WHERE activities { ts >= "now-1d/d" }// This query returns
[
[
{
"events": [
{
"url": "xxx"
}
]
},
{
"events": []
},
{
"events": [
{
"url": "xxx"
},
{
"url": "xxx"
},
{
"url": "xxx"
}
]
},
{
"events": []
},
//...
]
]SELECT { events @filter(clause: "page_type == \"newsarticle\" AND page_category == \"actu\""){ page_type page _category url } }
FROM UserPoint
WHERE activities { ts >= "now-1d/d" } AND events { page_type == "newsarticle" AND page_category == "actu" }// This query returns
[
[
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
},
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
}
]
]SELECT { activities { events @filter(clause: "page_type == \"newsarticle\" AND page_category == \"actu\""){ page_type page_category url } } }
FROM UserPoint
WHERE activities { ts >= "now-1d/d" } AND events { page_type == "newsarticle" AND page_category == "actu" }[
[
{
"activities": [
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
},
{
"events": []
},
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
}
]
}
]
]SELECT { activities @filter(clause: "events { page_type == \"newsarticle\" AND page_category == \"actu\"}"){ events { page_type page_category url } }
FROM UserPoint
WHERE activities { ts >= "now-1d/d" } AND events { page_type == "newsarticle" AND page_category == "actu" }[
[
{
"activities": [
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
},
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "video",
"page_category": "sport",
"url": "xxx"
},
{
"page_type": "video",
"page_category": "sport",
"url": "xxx"
}
]
}
]
]SELECT { activities @filter(clause: "events { page_type == \"newsarticle\" AND page_category == \"actu\"}"){
events @filter(clause: "page_type == \"newsarticle\" AND page_category == \"actu\""){ page_type page_category url } } }
FROM UserPoint
WHERE activities { ts >= "now-1d/d" } AND events { page_type == "newsarticle" AND page_category == "actu" }[
[
{
"activities": [
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
},
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
}
]
]SELECT @filter{ activities { events @filter(clause: "page_type == \"newsarticle\" AND page_category == \"actu\""){ page_type page_category url } } }
FROM UserPoint
WHERE activities { ts >= "now-1d/d" } AND events { page_type == "newsarticle" AND page_category == "actu" }[
[
{
"activities": [
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
},
{
"events": [
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
},
{
"page_type": "newsarticle",
"page_category": "actu",
"url": "xxx"
}
]
}
]
]doc_typeuser_point_system_version v202205











{
"ts": 1676627112685,
"doc_type": "UserActivity",
"doc_id": "XXXXXXX-XXXX-XXX-XXXXXXXX:XXXXXX-XXXXX-XXXX-XXXX-XXXXXXXXXX",
"op":" UPDATE",
"value":{
"$type":"SITE_VISIT",
"$source":"XXXX",
"etc": "etc"
}
}{
"ts":1676627112685,
"doc_type":"UserAgent",
"doc_id":"4700c85f-17e3-4304-aa7f-dc140173b08d:vec:32453299893",
"op":"UPDATE",
"value":{
"$os_family":"LINUX",
"$brand":null,
"$os_version":null,
"$form_factor":"PERSONAL_COMPUTER",
"$carrier":null,
"$model":null,
"$creation_ts":0,
"$browser_family":"FIREFOX"
}
}{
"ts":1676627112685,
"doc_type":"UserDevicePoint",
"doc_id":"4700c85f-17e3-4304-aa7f-dc140173b08d:udp:-32453299893",
"op":"UPDATE",
"value":{
"$os_family":"LINUX",
"$brand":null,
"$os_version":null,
"$form_factor":"PERSONAL_COMPUTER",
"$carrier":null,
"$model":null,
"$creation_ts":0,
"$browser_family":"FIREFOX"
}
}// exemple with a MumId
{
"ts":1676627112685,
"doc_type":"UserDeviceTechnicalId",
"doc_id":"4700c85f-17e3-4304-aa7f-dc140173b08d:udp:-32453299893:mum:7231822539",
"op":"UPDATE",
"value":{}
}
// exemple with an installationId
{
"ts":1676627112685,
"doc_type":"UserDeviceTechnicalId",
"doc_id":"4700c85f-17e3-4304-aa7f-dc140173b08d:udp:-32453299893:ins:1001:aZmFhOTVlM2ItMGRhOC00NDZlLWFhODMtNjZlZGI0YjNiNTk2",
"op":"UPDATE",
"value":{}
}{
"type": "record",
"name": "OperationRecord",
"namespace": "com.mediarithmics.replication.format",
"fields": [
{
"name": "ts",
"type": {
"type": "long",
"logicalType": "timestamp-micros"
}
},
{
"name": "doc_type",
"type": {
"name": "DocumentType",
"type": "enum",
"symbols": [
"UserPoint",
"UserActivity",
"UserProfile",
"UserSegment",
"UserDevicePoint",
"UserDeviceTechnicalId",
"UserAgent",
"UserAccount",
"UserEmail"
]
}
},
{
"name": "doc_id",
"type": "string",
"doc": "It will always start with the ctx_id (ie: user_point) followed by ':' and other internal ids. It identifies uniquely a document."
},
{
"name": "ctx_id",
"type": {
"type": "string",
"logicalType": "uuid"
},
"doc": "The UserPoint id"
},
{
"name": "op",
"type": "string",
"doc": "UPDATE or DELETE"
},
{
"name": "value",
"type": "string",
"doc": "The object in JSON format"
}
]
}{
"type": "service_account",
"project_id": "xxx-xxx-xx",
"private_key_id": "xxxxxxx",
"private_key": "-----BEGIN PRIVATE KEY-----\n xxxxxxx \n-----END PRIVATE KEY-----\n",
"client_email": "xxx@project_id.iam.gserviceaccount.com",
"client_id": "xxxxxx",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/projetc_id.iam.gserviceaccount.com"
}Endpoint=sb://<FQDN>/;SharedAccessKeyName=<KeyName>;SharedAccessKey=<KeyValue>{
"status": "PAUSED",
"name": ,
"project_id": "test",
"topic_id": "test",
"datamart_id": "1649",
"type": "GOOGLE_PUBSUB",
"replication_filters": [{
"document": "USER_SEGMENT",
"filter": null,
}, {
"document": "USER_ACCOUNT",
"filter": null,
}, { … }]
}
curl --location 'https://api.mediarithmics.com/v1/datamarts/:datamartID/replications/:replicationID/credentials' \
--header 'Authorization: api:XXX' \
--form 'file=@"/XXX/service-account.json"'{
"id": "1234",
"version" 2,
"status": "PAUSED",
"name": ,
"project_id": "test",
"topic_id": "test",
"datamart_id": "1649",
"type": "GOOGLE_PUBSUB",
"credentials_uri": "internal_path_to_credential_uri"
"replication_filters": [{
"id": "1",
"replication_id": "1234",
"document": "USER_SEGMENT",
"filter": null,
}, {
"id": "2",
"replication_id": "1234",
"document": "USER_ACCOUNT",
"filter": null,
}, { … }]
}
{
"replication_ids": ["123", "456"]
}





This page provides a formal description of OTQL capabilities.
data_type: text :data_type: keyword :
WHERE Object Tree Expression: It defines a logical expression mixing boolean operators and field operators to connect different objects in the object tree.@ScoreMaxSELECT (...) FROM UserPoint
WHERE activity @ScoreSum(min : 1000) {
events @ScoreField(name:"amount") {
name = "$transaction_confirmed"
}
}
# To be sure field "amount" exist
SELECT (...) FROM UserPoint
WHERE activity @ScoreSum(min : 1000) {
events @ScoreField(name:"amount") {
is_defined(amount) AND
name = "$transaction_confirmed"
}
}# Select UserPoints having spent at least 1000 orders, where IT product count twice
SELECT (...) FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreBoost(factor: 2.0) @ScoreSum(result: "score_value") {
category="IT"
},
order_products @ScoreSum() {
category!="IT"
}
}
}# Select user points having spent on average at least 1000 through $transaction_confirmed events during the past year
SELECT (...) FROM UserPoint
WHERE activities {
events @ScoreField(name: "amount") @ScoreAvg(min: 1000) {
name = "$transaction_confirmed" AND date >= "now-1y/y"
}
}
# Select user points having spent in average more than 1000€ by orders with at least products which cost 10€:
SELECT (...) FROM UserPoint
WHERE activity_events @ScoreAvg(min : 1000) {
order {
order_products @ScoreField(name: "amount") @ScoreSum(min: 10, result:"score_value") {
category="IT"
}
}
}# Select user points with at least 1 activity that contains at least 1 $transaction_confirmed event with amount >= 1000 during the past year
SELECT (...) FROM UserPoint
WHERE activities {
events @ScoreField(name: "amount") @ScoreMax(min: 1000) {
name = "$transaction_confirmed" AND date >= "now-1y/y"
}
} SELECT { id name } FROM Product WHERE price > 50.0SELECT [Operation] FROM [Object Type] WHERE [Object Tree Expression]# Counts number of new users in the past 7 days
SELECT @count{} FROM UserPoint WHERE creation_date >= "now-7d/d"
# Counts the number of transactions on a specific site (channel) 7 days ago
SELECT @count{} FROM UserEvent
WHERE name = "$transaction_confirmed"
AND date = "now-7d/d"
AND channel_id = 2419
# Counts the number of profiles with female gender
SELECT @count{} FROM UserProfile WHERE gender = "W"
# Lists all categories from universes in events done on a specific channel
SELECT { universe { category @map }} FROM UserEvent WHERE channel_id = 2417
# Lists all event names collected in the platform
SELECT {name @map} FROM UserEvent
# Number of users having at least 3 events related to laptops in the past 15 days
SELECT @count{} FROM UserPoint
WHERE activities { events @ScoreSum(min:3) {
category = "Laptop" AND date >= "now-15d/d"
}}
# Number of transactions per site and per day
SELECT { channel_id @map { date @date_histogram } } FROM UserEvent WHERE name = "$transaction_confirmed"
# Number of users having an account but no emails
SELECT @count{} FROM UserPoint where accounts{} and not emails{}UserPoint
├── UserActivity
│ └── UserEvent
├── UserEmail
└── UserAccount# Selects all names from all UserPoint
SELECT {name} FROM UserPoint
# Selects all names from all UserActivity
SELECT {name} FROM UserActivity
# Equivalent of
SELECT {activities { name }} FROM UserPoint
# Selects all names from all UserEvent
SELECT {name} FROM UserEvent
# Equivalent of
SELECT { activities { events { name }}} FROM UserPoint SELECT (...) FROM (...) WHERE (PredicateA AND PredicateB) OR PredicateC
SELECT (...) FROM (...) WHERE PredicateA AND (PredicateB OR PredicateC) SELECT (...) FROM (...) WHERE price > 50.0 SELECT (...) FROM (...) WHERE price > 50.0 AND last_modified_date > "now-10d"SELECT (...) FROM (...)
WHERE price > 50.0 AND last_modified_date > "now-10d"
# ( price > 50.0 ) x ( last_modified_date > "now-10d" )
SELECT (...) FROM (...)
WHERE price > 50.0 AND last_modified_date > "now-10d" OR price > 100.0 AND last_modified_date > "now-20d"
# (( price > 50.0 ) x ( last_modified_date > "now-10d" )) + (( price > 100.0 ) x ( last_modified_date > "now-20d" ))# Functional tree
UserPoint
└─ UserActivity
└─ UserEvent
# Associated schema
type UserPoint @TreeIndexRoot(index:"USER_INDEX") {
# activities is a link field to UserActivity objects
activities: [UserActivity]
}
type UserActivity {
# events is a link field to UserEvent objects
events: [UserEvent]
}
type UserEvent {
name: String @TreeIndex(index_name: "USER_INDEX")
amount: Int @TreeIndex(index_name: "USER_INDEX")
date: Timestamp!
}
# A UserPoint can have 0..n User Activity
# Each UserActivity can have 0..m UserEvent
# UserEvent has a "name" String field, an "amount" Int field and a "date" Timestamp field SELECT (...) FROM UserPoint WHERE activities { events { name = "$transaction_confirmed" } }# Select UserPoint that bought things through at least 3 different visits
SELECT (...) FROM UserPoint
WHERE activities @ScoreSum(min: 3.0){ events { name = "$transaction_confirmed" } }
# Select UserPoint that have at least 1 activity that contains at least 3 $transaction_confirmed events
SELECT (...) FROM UserPoint
WHERE activities { events @ScoreSum(min: 3.0) { name = "$transaction_confirmed" } }# Using @ScoreField alone is useless because it could be replace by logical operator
SELECT (...) FROM UserPoint
WHERE activity {
events @ScoreField(name:"amount") {
name = "$transaction_confirmed"
}
}
# Can be written
SELECT (...) FROM UserPoint
WHERE activity {
events {
name = "$transaction_confirmed"
}
}# Select UserPoint having spent more than 1000€ through $transaction_confirmed events during the past year
SELECT (...) FROM UserPoint
WHERE activities {
events @ScoreField(name: "amount") @ScoreSum(min: 1000) {
name = "$transaction_confirmed" AND date >= "now-1y/y"
}
}
# Select UserPoint having spent more than 1000€ in cross orders with at least products which cost 10€:
SELECT (...) FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order {
order_products @ScoreField(name: "amount") @ScoreSum(min: 10, result:"score_value") {
category="IT"
}
}
}# Select UserPoint having spent in average more than 1000 in one activity of events with a amount superior than 10
SELECT (...) FROM UserPoint
WHERE activity @ScoreAvg(min : 1000) { events @ScoreField(name:"amount") @ScoreSum(min 10, result:"score_value") {
name = "$transaction_confirmed" } }
# Select UserPoint having spent in average in one activity, more than 1000 events with a amount superior than 10
SELECT (...) FROM UserPoint
WHERE activity @ScoreAvg(min : 1000) { events @ScoreField(name:"amount") @ScoreSum(min: 10, result:"boolean_value") {
name = "$transaction_confirmed" } }# We wanted :
# Count UserPoint having spent more than 1000€ in cross orders with at least 10 orders more than 100€ :
SELECT (...) FROM UserPoint
WHERE activity_events @ScoreSum(min : 1000) {
order @ScoreSum(min: 10, result: "score_value") {
@ScoreSum(min: 100, result: "boolean_value") {
order_products @ScoreField(name: "price") @ScoreSum(result:"score_value") {
category="IT"
}
}
}
}
# But the query return :
# Count UserPoint having spent more than 1000 orders with at least 10 orders more than 100€SELECT (...) FROM UserPoint WHERE activities {creation_ts <= "2012-09-27"}
SELECT (...) FROM UserPoint WHERE activities {creation_ts > "1549365498507"}
SELECT (...) FROM UserPoint WHERE activities {creation_ts > "now-7d"}now+1h // Resolves to: 2001-01-01 13:00:00
now-1h // Resolves to: 2001-01-01 11:00:00
now-1h/d // Resolves to: 2001-01-01 00:00:00
2001.02.01||+1M/d // Resolves to: 2001-03-01 00:00:00# Doing
(...) WHERE match(url_as_text, "Hello World!")
# Will search in the text values for words matching 'hello' or 'world'
https://www.hello.com/
https://www.world.com/
https://www.hello.com/world/
(...)(...) WHERE starts_with(mykeyword, "Hello World!")
(...) WHERE mykeyword == "Hello World!"# Total sold in events for channel IDs 2456, 5489, 1426
SELECT {events {basket { amount @sum}}} FROM UserActivity
WHERE channel_id IN ["2456","5489","1426"]
# Equivalent of WHERE channel_id = "2456" OR channel_id = "5489" OR channel_id = "1426"# Return all UserPoint with a profile
SELECT { id } FROM UserPoint WHERE is_defined(profiles)
# Return all UserPoint with an email in their profile
SELECT { id } FROM UserPoint WHERE profiles{is_defined(email)}# Get the activity “$transaction_confirmed” of UserPoint of the segment id “1234“
SELECT { id }
FROM ActivityEvent WHERE name=="$transaction_confirmed"
JOIN Userpoint WHERE segments { id="1234" }# Get only 5 or fewer activities named “$transaction_confirmed”
SELECT { id }
FROM ActivityEvent WHERE name=="$transaction_confirmed"
LIMIT 5SELECT { id }
FROM ActivityEvent WHERE name=="$transaction_confirmed"
LIMIT 100
# This query returns 100 (or fewer) activities named “$transaction_confirmed”SELECT @count{ }
FROM ActivityEvent WHERE name=="$transaction_confirmed"
LIMIT 5
# Return the count of all activities named "$transaction_confirmed"
# Example: Return - 21,866,076# Select id and name in the root level
SELECT { id name } FROM UserPoint
# Select name in UserPoint and creation_ts and id in emails linked to the UserPoint
SELECT { name emails { creation_ts id } } FROM UserPoint{<OBJECT> @filter(clause: "<FIELD_NAME> == \"<FIELD_VALUE>\"",
filter_empty: <BOOLEAN>) {<FIELD_NAME_1> <FIELD_NAME_2>}@filter(clause: "category == \"CAT_1\" OR referrer == \"REF\"")@filter(clause: "category == \"CAT_1\" OR category == \"CAT_2\"")@filter(clause: "category != \"CAT_1\" AND category != \"CAT_2\"")@filter(clause: "(category == \"CAT_1\" OR category == \"CAT_2\") AND
referrer == \"REF\"")@filter(clause: "events { category == \"CAT_1\" } ")select { id { activities { id events { name score } } } }
from UserPoint
where { activities { events { name == "display" } } }[
{
"id": "up1",
"activities": [
{
"id": "a1",
"events": [
{ "name": "display", "score": 123 },
{ "name": "click"}
]
},
{
"id": "a2",
"events": [ { "name": "display" } ]
}
]
},
{
"id": "up2",
"activities": [
{
"id": "a3",
"events": [ { "name": "click" } ]
},
{
"id": "a4",
"events": [ { "name": "display" } ]
}
]
}
]select { id { activities { id events @filter(clause: "name == \"display\"") { name score } } } }
from UserPoint
where { activities { events { name == "display" } } } [
{
"id": "up1",
"activities": [
{
"id": "a1",
"events": [
{ "name": "display", "score": 123 }
]
},
{
"id": "a2",
"events": [ { "name": "display" } ]
}
]
},
{
"id": "up2",
"activities": [
{
"id": "a3",
"events": []
},
{
"id": "a4",
"events": [ { "name": "display" } ]
}
]
}
]select { { activities { events @filter(clause: "name == \"display\"") { score } } } }
from UserPoint
where { activities { events { name == "display" } } }[
{
"activities": [
{ "events": [ { "score": 123 } ] },
{ "events": [ ] }
]
},
{
"activities": [
{ "events": [] },
{ "events": [] }
]
}
]select { { activities {
events @filter(clause: "name == \"display\"", filter_empty: false) { score } } } }
from UserPoint
where { activities { events { name == "display" } }}
//result
[
{
"activities": [
{ "events": [ { "score": 123 } ] },
{ "events": [ {} ] }
]
},
{
"activities": [
{ "events": [] },
{ "events": [ {} ] }
]
}
]select @filter { { activities {
events @filter(clause: "name == \"display\"") { score } } } }
from UserPoint
where { activities { events { name == "display" } }}[
{
"activities": [ { "events": [ { "score": 123 } ] } ]
}
]SELECT { activities @filter(clause: "events {is_defined(event_name) AND event_name == \"display\"}")
{ events { event_name } } }
FROM UserPoint
where { activities { events { name == "display" }}}# Counts the number of UserPoint
SELECT @count {} FROM UserPoint
# Counts number of new users in the past 7 days
SELECT @count{} FROM UserPoint WHERE creation_date >= "now-7d/d"# Average basket amount between two specific dates
SELECT {basket {amount @avg}} FROM UserEvent
WHERE {date >= "2020-12-01" AND date <= "2020-12-31" }# Minimum basket amount between two specific dates
SELECT {basket {amount @min}} FROM UserEvent
WHERE { date >= "2020-06-20" AND date <= "2020-06-25” }# Maximum basket amount between two specific dates
SELECT {basket {amount @max}} FROM UserEvent
WHERE { date >= "2020-06-20" AND date <= "2020-06-25”}# Sum of basket amounts between two specific dates
SELECT {order{amount @sum }} FROM ActivityEvent
WHERE {date >= "2020-06-20" AND date <= "2020-06-25”}# Number of channels in a datamart
SELECT {channel_id @cardinality} FROM ActivityEvent
# Number of cookies associated with UserPoint in a specific segment
SELECT {agents{id @cardinality}} FROM UserPoint
WHERE segments {id=”XXXX”}SELECT { channel_id @map { # map the values of channel id in several buckets
session_duration @avg # The average duration
}
} FROM UserActivity
# Data
# channel ID : 1234, count : 654987987987, session_duration: 100
# channel ID : 1235, count : 987987965465, session_duration: 1500SELECT { order { amount @histogram(interval:50)}}
FROM UserEvent WHERE date >= "now-7d"
# Data
# Key: 0, count: 97681
# Key: 50, count: 50324
# Key: 100, count: 33164
# Key: 150, count: 36528# Mere use of @date_histogram directive: selecting all page_view events
# in the last 30 days
SELECT { date @date_histogram(interval:"1d") }
FROM UserEvent
WHERE name = "page_view" and date >= "now-30d/d"
# @date_histogram used together with @map directive with default interval (days)
SELECT { channel_id @map {date @date_histogram }}
FROM UserEvent
WHERE name = "$transaction_confirmed"
# Data
# Key: 2416, count: 27563351
# 2018-01-16T00:00:00.000Z 330
# 2018-01-17T00:00:00.000Z 331
# 2018-01-18T00:00:00.000Z 3332
# ...
# Key: 2417, count: 65498798
# ...
# Force an interval of one month
SELECT { channel_id @map {date @date_histogram(interval: "1M") } }
FROM UserEvent
WHERE name = "$transaction_confirmed"SELECT {
numberOfChannels: channel_id @cardinality # The approximate number of distinc values
averageDuration: duration @avg # The average duration
mininumDuration: duration @min # map the values of channel id in several buckets
} FROM UserEvent{
"status": "ok",
"data":
{
"id": "50409", // ID of the query to retrieve for the next steps
"datamart_id": "1509",
"query_language": "OTQL",
"minor_version": null,
"major_version": null,
"query_text": "SELECT {id} FROM UserPoint",
"favorite": false
}
}{
"status": "error",
"error": "cannot save invalid query, cause: Syntax error while parsing document \"nawak\". Invalid input 'n', expected Comments or select (line 1, column 1):\nnawak\n^",
"error_code": "BAD_REQUEST_DATA",
"error_id": "ef292c4e-1eab-4a7f-8fb2-77d797139be9"
}// Creating a query payload
{
"query_text": "SELECT {id} FROM UserPoint", // Your query
"datamart_id": "<ASSOCIATED_DATAMART_ID>",
"query_language": "OTQL"
}// If valid
{
"status": "ok",
"data": {
"type": "VALID",
"validation": {
"parameters": []
},
"status": "ok"
}
}
// If invalid
{
"status": "ok",
"data": {
"type": "PARSING_ERROR",
"error": {
"message": "Syntax error while parsing document \"nawak\". Invalid input 'n', expected Comments or select (line 1, column 1):\nnawak\n^",
"position": {
"row": 1,
"col": 1
},
"error_type": "PARSING"
},
"status": "error"
}// Checking a query payload
{
"query": "SELECT {id} FROM UserPoint" // Your query
}{
"status": "ok",
"data": {
"took": 112015,
"timed_out": false,
"offset": null,
"limit": null,
"result_type": "COUNT",
"precision": "FULL_PRECISION",
"sampling_ratio": null,
"rows": [
{
"count": 80975924
}
],
"cache_hit": true
}
}{
"status": "error",
"error": "Service Unavailable",
"error_code": "SERVICE_UNAVAILABLE",
"error_id": "482416e1-2d93-484a-948b-615b639b5e4f"
}# Select UserPoint having spent at 1000 in one event
SELECT (...) FROM UserPoint
WHERE activity {
events @ScoreField(name:"amount") @ScoreSum(min : 1000) {
name = "$transaction_confirmed"
}
}
# Select UserPoint having spent at 1000 in one activity
SELECT (...) FROM UserPoint
WHERE activity @ScoreSum(min : 1000) {
events @ScoreField(name:"amount") {
name = "$transaction_confirmed"
}
}
