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

/profile/user/external/update

Lets the client upload information which will be associated with a given user. This information can later be retrieved, used as a factor in statistical analyses, ad matching or other purposes.

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

Request

The request object has the following fields:

Name

Type

Required

Description

id

String

Yes

The cusomter-defined identifier for the user.

type

String

Yes

The customer-specific identifier type as registered with Cxense, i.e. a

customer prefix

.

profile

Array of profile objects

Yes

The key-values which will be associated with the identified user. The pre-exisiting information will be overwritten. The array may hold maximally 40 profile objects.

cxid

String

No

The Cxense-specific user 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.

The profile array lets the client associate key-value pairs for a given user. A key-value unit is defined as a Profile object, as described below. For each update, the existing information stored for the user will be overwritten. Hence, if the intention is to add a new key-value to the user without erasing the existing information, the client should first read (/profile/user/external/read) the currently stored data, add the new data to the already stored data, and upload the new profile consisting of both the previously stored information, and the new information.

Note that the group names are not required to be unique. This means that the client may associate multiple items with one single group name. This is equivalent to associating a group name with an array of items.

The cxid parameter is optional, and is meant to only be used to replace a subsequent call to /profile/user/external/link/update. Updating a profile and linking a user using two different requests could lead to inconsistent data for the user. Performing both update and link in the same request eliminates this possibility. It's not needed if linking and profile update are independent and happens at different times.

The following syntax restrictions apply:

  • Maximally 40 profile objects can be associated with a user.

Profile object

A profile object represents a single key-value unit which is associated with the user.

Name

Type

Required

Description

group

String

Yes

The group name. It is required to begin with a

customer prefix

('type'), followed by dash and finalized with a group name using this subset [a-zA-Z0-9_:/#$-] (e.g. xyz-groupname).

item

Integer/String/TypedItem

Yes

The item which is to be associated with the group name.

A TypedItem item is a key-value unit which specifies the type of the item, and the value of that item.

Name

Type

Required

Description

type

String

Yes

This string should be one of the following ("string", "number", "time", "decimal")

value

String

Yes

The string value of item of the specified type which is to be associated with the group name ("green", "123", "2019-10-17", "0.85")

Valid type, and value for the TypedItem should follow this format:

type

Description of value

string

Any string ("paul")

number

Any non-negative integer as a string ("1200000000")

time

Datetime string that follows the ISO8601 format, for dates after 1 January 1970, with minimum length of 8 characters ("1994-06-18")

decimal

Numbers with 2 decimal points as a string, with values from 0, and up to 21474836.47 ("25.99").

The following syntax restrictions apply:

  • Group name MUST start with the customer prefix, aka the 'type' in the request, followed by a dash. The client can define group names freely, but the group names may only contain letters, digits and dash (commonly used as delimiter in group name).

  • There are some reserved group names where the syntax is more constrained. These groups are intended for demographic data on the user, allowing only a set of valid values. Currently, the groups "gender" and "byear" are reserved keys with a constrained set of valid values, as defined below in the section below.

  • Maximum allowed length for a group name is 30 characters, while the item names have an upper limit of 100 characters.

Group names and items will be normalized using the following sanitization rules:

  • Canonicalize unicode, i.e., map {"a", "´"} to "á"

  • Normalize case, i.e., map "somETHing" to "something"

  • Trim edges, i.e., map " dog " to "dog"

  • Reduce multiple consecutive internal whitespace characters to a single space, i.e., map "foo bar" to "foo bar"?

Reserved group names

Name

Type

Required

Description

<type>-gender

String

No

The reserved group name<type>-gender will only accept the values male, female and unknown, used for annotating the gender of a user.

<type>-byear

String

No

The reserved group name <type>-byear will only accept numbers between 1850 and next year, used for annotating the birth year of a user.

The pre-defined group names will only accept a set of valid items. The client may of course represent this demographic information in ways which does not conform to this constrained input, but must then use other group names than those which have been pre-defined for this purpose.

Response

For a valid /profile/content/external/update query, an empty response will be returned.

Examples

Bash
$ python cx.py /profile/user/external/update '{"id":"subscriber14","type":"xyz","profile":[{"group":"xyz-gender","item":"male"},{"group":"xyz-interests","item":"cooking"},{"group":"xyz-interests","item":"motorcycling"}, {"group":"xyz-networth", 1200000000}]}'
{}

$ python cx.py /profile/user/external/update '{"id":"subscriber14","type":"xyz","profile":[{"group":"xyz-gender","item":"male"},{"group":"xyz-interests","item":"cooking"},{"group":"xyz-interests","item":"motorcycling"},{"group":"xyz-birthdate","item": {"type": "time", "value", "1994-06-18"}}, {"group":"xyz-subscription-price","item": {"type": "decimal", "value", "30.95"}}, {"group":"xyz-networth", 1200000000}]}'
{}


$ python cx.py /profile/user/external/update '[{"id":"subscriber14","type":"xyz","profile":[{"group":"xyz-gender","item":"male"},{"group":"xyz-interests","item":"cooking"},{"group":"xyz-interests","item":"motorcycling"}]},{"id":"5678","type":"xyz","profile":[{"group":"xyz-gender","item":"female"},{"group":"xyz-interests","item":"swiming"},{"group":"xyz-interests","item":"baseball"}]}]'
[
 {},
 {}
]

Last updated: