Manage Segments (JS SDK)

Adding to a segment

Method Objective

The method allows adding the current user to a segment.

Syntax and parameters

personaclick("segment", "add", params);

NameTypeRequirementDescription
paramsObjectrequiredObject with request parameters.

Request parameters

NameTypeRequirementDescription
segment_idnumber/stringrequiredSegment ID. It's available in the PersonaClick account: CRM > Segments.
emailstringoptionallyThe current user's Email.
phonestringoptionally

The current user's phone in full international format.

A phone number in full international format may begin with a plus sign (+) followed by the country code, city (area) code, and phone number.

Examples of use

personaclick("segment", "add", {
    "segment_id": 100500,
    "email": "john.doe@examplestore.com",
    "phone": "+10000000000"
});

personaclick("segment", "add", {
    "segment_id": 100500,
    "email": "john.doe@examplestore.com"
});

personaclick("segment", "add", {
    "segment_id": 100500,
    "phone": "+10000000000"
});

personaclick("segment", "add", {"segment_id": 100500});

Removing from a segment

Method Objective

The method allows excluding the current user from a segment.

Syntax and parameters

personaclick("segment", "remove", params);

NameTypeRequirementDescription
paramsObjectrequiredObject with request parameters.

Request parameters

NameTypeRequirementDescription
segment_idnumber/stringrequiredSegment ID. It's available in the PersonaClick account: CRM > Segments.
emailstringoptionallyThe current user's Email.
phonestringoptionally

The current user's phone in full international format.

A phone number in full international format may begin with a plus sign (+) followed by the country code, city (area) code, and phone number.

Examples of use

personaclick("segment", "remove", {
    "segment_id": 100500,
    "email": "john.doe@examplestore.com",
    "phone": "+10000000000"
});
personaclick("segment", "remove", {
    "segment_id": 100500,
    "email": "john.doe@examplestore.com"
});
personaclick("segment", "remove", {
    "segment_id": 100500,
    "phone": "+10000000000"
});
personaclick("segment", "remove", {"segment_id": 100500});

Getting the segment list

Method Objective

The method allows getting a list of segments that include the current user.

Syntax and parameters

personaclick("segment", "get", callback);

NameTypeRequirementDescription
callbackFunctionrequiredThe callback function that takes the API response. The API response type is an object.

API response

TypeDescription
Object array

Object array, each will have the following properties:

  • id (number) - the Segment ID.
  • type (string) - the Segment Type. It can have the following values: static, dynamic, rfm.

Example of use

personaclick("segment", "get", function(segments) {
    segments.forEach(function(segment) {
        console.log(segment.id);
        console.log(segment.type);
    });
});

Copyright 2018-2024 PersonaClick