User activities import

Bulk import user activities to insert user activities that happened outside of real-time tracking. Those activities usually are offline activities, like store visits or store purchases, but you can adapt it to your use cases.

How-to

Use the bulk import endpoints to create a document import with theUSER_ACTIVITYdocument type and APPLICATION_X_NDJSON mime type. Only ndjson data is supported for user activities.

Then, create an execution with your user activities formatted in ndjson .

Example

# 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":{}}]}'

Last updated

Was this helpful?