Pick Up Where You Left Off
Business Goal: I want to enable my customers to continue their session between devices. This way when they return on their mobile app from a desktop session, we can make it easy for them to return to their search.
Personalization
We will aggregate on loginId
and deviceType
to manage the hand-off from desktop to mobile.
Sample Query
This query relies on 3 factors:
-
The
loginId
. The exact syntax to filter down to the session ID is:"matchExact":{"and":[{"visit":{"customerData":{"loginId":"<current session ID>"}}}]}
-
The deviceType: the front end will need to check that the current device type is different from historical ones. We can check what device types were used by looking at:
{"matchExact":{"and":[{"visit":{"generated":{"deviceType":"desktop"}}}]}}
-
The window of how far back we want to look (this can be
day
,week
, ormonth
) - this example usesday
to put this together, we’ll fetch the queries that have the list of events for this user on Desktop in the last day:
curl -H "Authorization: --clientKey--" -XPOST \
"https://--customerId--.groupbycloud.com/wisdom/v2/events/search" \
-d '{"window":"day","matchExact":{"and":[{"visit":{"generated":{"deviceType":"desktop"}}}, {"visit":{"customerData":{"sessionId":"<current session ID>"}}}]}}'
(Note that in the above example, you’ll need to check with a specific login ID to see sample recall.)
Response
In the response you can grab the .result.recent[].search.query
fields, which will contain all the searches done within the filtered session.
The format of the response is:
{
"status": {
"code": 200,
"message": "OK",
"additionalInfo": null
},
"result": {
"window": "day",
"count": 2,
"recent": [
{
"search": {
/* the complete search event */
"id": "11122223-4d9a-4e8f-a45f-02bb8ceb5946",
"query": "cought medicine",
},
"origin": {
"sayt": false,
"dym": false,
"search": false,
"recommendations": false,
"autosearch": false,
"navigation": false,
"collectionSwitcher": false
}
},
"responseId": "5da72e23-4d9a-4e8f-a45f-02bb8ceb5946",
/* the complete beacon event */
"visit": {
/* rest of the response */
},
"metadata": [
],
"id": "14973022242_45f93299434eabed22f7c67227a72a33b67fe17b"
}
]
},
"serverTimestamp": "2017-01-12T23:01:34+00:00"
}
count
returns the number of events that this customer had with these parameters.
This example only shows the first object in the array that would contain 2 response objects.