We’ve migrated our documentation to a new site, which means some URLs have changed.
Audience

/profile/user/segment

Retrieves a list of all segments where the user is a member.

For using this method as part of a Javascript integration, see the ready integration guide at DMP segments helper function - getUserSegmentIds() .

The user must be authenticated and have read permissions to the specified site group.

Request

The request object has the following fields:

Name

Type

Required

Description

siteGroupIds

Array of Strings

Yes

The list of site groups to retrieve segments for.

id

String

No

Identifies the user whose segment memberships should be returned.

type

String

No

The type of user identifier, i.e., tells us how to interpret id. The value 'cx' indicates a Cxense-specific identifier, either an internal cross-site user id returned from an API such as

/traffic/data

, or a site-specific id obtained from cX.getUserId() function call from cx.js. Customer-specific identifiers via a customer-assigned prefix are also possible.

identities

Array of Objects

No

A list of user identifiers to consult if multiple identities are available.

candidateSegmentIds

Array of String

No

Deprecated Please use candidateSegments instead. A list of candidate segment identifiers to consider. The response segment identifiers will be a subset of these candidates. Providing candidates can significantly improve the latency of the API request.

candidateSegments

Array of Object

No

Recommended together with cx_typed response format A list of candidate segments to consider. The response segment matches will be a subset of these candidates. Providing candidates can significantly improve the latency of the API request.

format

String

Defaults to cx

The response format, and must be either cx (the default, deprecated), cx_typed (recommended, future default) or rtc. cx_typed format includes all segment types, including "lookalike", and returns "typed" segment matches rather than just identifiers, see segments field in the response for more information. rtc uses

Real Time Config (RTC)

response format.

segmentFormat

String

Defaults to standard

The segment format, one of standard (the standard segment ID format that can be found in the platform) or short_ids (a specially generated shortened version of the segment identifier compatible with some Ad servers).

Either a single identifier and type, or a list of objects must be specified.

The identities objects have the following fields:

Name

Type

Required

Description

id

String

Yes

The identifier for the user. See the 'id' description above.

type

String

Yes

The customer identifier type. See the 'type' description above.

Each candidateSegments object has the following fields:

Name

Type

Required

Description

id

String

Yes

The segment identifier.

type

String

Yes

The segment type. One of 'traffic', 'external' or 'lookalike'.

Response

The cx-formatted response object has the following fields:

Name

Type

Description

segments

Array of Strings

List of segment identifiers where the user is a member.

The cx_typed-formatted response object has the following fields:

Name

Type

Description

segments

Array of Objects

List of segments where the user is a member.

Each segments object has the following fields:

Name

Type

Description

id

String

The segment identifier.

shortId

String

The shortened segment identifier.

type

String

The segment type. One of 'traffic', 'external' or 'lookalike'.

The rtc-formatted response object has the following fields:

Name

Type

Description

targeting

Object

An object contains the field CxSegments - list of segment identifiers where the user is a member.

Examples

Bash
# Single lookup
$ python cx.py /profile/user/segment '{"id":"hvfufdee4dai1giaud", "type":"cx", "siteGroupIds":["92028378393"]}'
{
 "segments": [
 "8pbc50ol8ryj",
 "83rpijvh8u7d"
 ]
}

# Provide candidate when checking whether a user is a member of a specific segment
$ python cx.py /profile/user/segment '{"id":"hvfufdee4dai1giaud", "type":"cx", "siteGroupIds":["92028378393"], "candidateSegmentIds":["8pbc50ol8ryj","123"]}'
{
 "segments": [
 "8pbc50ol8ryj"
 ]
}

# Lookup using multiple identifiers for a single user
$ python cx.py /profile/user/segment '{"siteGroupIds":["92028378393"], "identities":[{"type":"xyz", "id":"subscriber14"},{"type":"cx","id":"hvfufdee4dai1giaud"}]}'{
 "segments": [
 "8pbc50ol8ryj",
 "83rpijvh8u7d"
 ]
}

# Single lookup when rtc enabled
$ python cx.py /profile/user/segment '{"id":"hvfufdee4dai1giaud", "type":"cx", "siteGroupIds":["92028378393"], "format": "rtc"}'
{
 "targeting":{
 "CxSegments": [
 "8pbc50ol8ryj",
 "83rpijvh8u7d"
 ]
 }
}

# New extended format for segment matches
$ python cx.py /profile/user/segment '{"id":"hvfufdee4dai1giaud", "type":"cx", "siteGroupIds":["92028378393"], "candidateSegments":[{"type": "traffic", "id": "8pbc50ol8ryj"},{"type": "external", "id": "123"}]}, "format": "cx_typed"'
{
 "segments": [{
 "type": "traffic", "id": "8pbc50ol8ryj", "shortId": "0" 
 }]
}

Last updated: