The SegmentLookupHandler class retrieves a list of segments for both specified user identifiers, and context for site groups provided in the request. It handles validation of user and context information, resolves identities for each site group, and performs segment lookups based on provided criteria.
For using this method as part of a Javascript integration, see the ready integration guide at Piano Audience segments helper function - getSegments() .
The user must be authenticated and have read permissions to the specified site group.
Request Parameters
The SegmentLookupRequest object accepts the following parameters:
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
Array of Strings |
Yes |
List of site group IDs to retrieve segments for. |
|
|
Object |
No |
Object of |
|
|
Array of Objects |
No |
List of |
|
|
Array of segment IDs |
No |
List of candidate segment IDs to consider for the lookup. |
|
|
Enum |
No |
Format of the response ( |
|
|
boolean |
No |
If set the short ids will be included |
|
|
Object |
No |
See |
Identity Object Fields
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
String |
Yes |
The user identifier. |
|
|
String |
Yes |
The type of the user identifier. |
Context Object Fields
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
String |
Yes |
The url of the page to look up. |
|
|
String |
Yes |
The site id for the url. |
Response Structure
cx Format
|
Name |
Type |
Description |
|---|---|---|
|
|
Array of Objects |
List of segments where the user is a member. Each object contains |
rtc Format
|
Name |
Type |
Description |
|---|---|---|
|
|
Object |
Contains the field |
Examples
# Single lookup
$ python cx.py /segment/lookup '{"identity": {"id":"hvfufdee4dai1giaud", "type":"cx"}, "siteGroupIds":["92028378393"], "context":{"siteId": "site64", "url": "http://url.com"}}'
{
"segments": [{
"type": "traffic", "id": "8pbc50ol8ryj"
}, {
"type": "contextual", "id": "8ctx50ual"
}]
}
# Provide candidate when checking whether a user is a member of a specific segment
$ python cx.py /segment/lookup '{"identity": {"id":"hvfufdee4dai1giaud", "type":"cx"}, "siteGroupIds":["92028378393"], "candidateSegmentIds":["8pbc50ol8ryj","123"]}'
{
"segments": [{
"type": "traffic", "id": "8pbc50ol8ryj"
}]
}
# Single lookup when rtc enabled
$ python cx.py /segment/lookup '{"identity": {"id":"hvfufdee4dai1giaud", "type":"cx"}, "siteGroupIds":["92028378393"], "format": "rtc"}'
{
"targeting":{
"CxSegments": [
"8pbc50ol8ryj",
"8ctx50ualryj"
]
}
}
$ python cx.py /segment/lookup '{"identity": {"id":"hvfufdee4dai1giaud", "type":"cx"}, "shortIds":true, "siteGroupIds":["92028378393"], "candidateSegmentIds":["8pbc50ol8ryj","123"]}'
{
"segments": [{
"type": "traffic", "id": "8pbc50ol8ryj", "shortId": "0"
}]
}