Talking to the Unomi events API

Otávio Machado
Nov 12, 2018 · 3 min read
/context.js, /context.json
curl -X POST \
'http://localhost:8181/context.js?sessionId=321839218' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: de6d8d95-fe69-438f-865a-214843956db6' \
-d '{
"source":{
"itemType":"pageView",
"scope":"the-coolest-website",
"itemId":"pageView",
},
"events":[
{
"eventType":"myAwesomeUserEvent",
"scope":"the-coolest-website",
"source":{
"itemType":"pageView",
"scope":"the-coolest-website",
"itemId":"pageView",
"properties":{
"myProperty":"myValue"
}
}
}
],
"requiredProfileProperties":[
"myProperty"
],
"requireSegments": true
}'
{
"profileId": "2efca8c0-2c73-4da1-88ae-0d4d13e8ec2d",
"sessionId": "321839218",
"profileProperties": {},
"sessionProperties": null,
"profileSegments": [
"returningProductUser"
],
"filteringResults": null,
"personalizations": null,
"trackedConditions": [],
"anonymousBrowsing": false,
"consents": {}
}
window.digitalData = window.digitalData || {};
var cxs = {"profileId":"2efca8c0-2c73-4da1-88ae-0d4d13e8ec2d","sessionId":"321839218","profileProperties":{},"sessionProperties":null,"profileSegments":["returningProductUser"],"filteringResults":null,"personalizations":null,"trackedConditions":[],"anonymousBrowsing":false,"consents":{}};
/eventcollector
curl -X POST \
http://localhost:8181/eventcollector \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"sessionId": "392183982139812",
"events":[
{
"eventType":"myAwesomeUserEvent",
"scope":"the-coolest-website",
"source":{
"itemType":"pageView",
"scope":"the-coolest-website",
"itemId":"pageView",
"properties":{
"myProperty":"myValue"
}
}
}
]
}
{
"updated": 0
}
/client/myprofile (.json/.csv/.text/.yaml)
{
"nbOfVisits": 1,
"productVisitedSite": [],
"productVisitedSiteNb": 0,
"lastVisit": "2018-11-09T12:46:55Z",
"firstVisit": "2018-11-09T12:46:55Z"
}

Otávio Machado

Written by

Eternal learner, Software Developer, Team Enabler and occasional Pokémon Master. I play with words and with code — and I want to make the world a better place.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade