Personalization Class

Get, create, update, and delete personalization audiences and targets.

Namespace

ConnectApi

Personalization Methods

The following are methods for Personalization. All methods are static.

createAudience(communityId, audience)

Create an audience.

API Version

48.0

Requires Chatter

No

Signature

public static ConnectApi.Audience createAudience(String communityId, ConnectApi.AudienceInput audience)

Parameters

communityId
Type: String
ID of the community.
audience
Type: ConnectApi.AudienceInput
A ConnectApi.AudienceInput object that defines the audience.

Return Value

Type: ConnectApi.Audience

createTargets(communityId, target)

Create targets.

API Version

48.0

Requires Chatter

No

Signature

public static ConnectApi.TargetCollection createTargets(String communityId, ConnectApi.TargetCollectionInput target)

Parameters

communityId
Type: String
ID of the community.
target
Type: ConnectApi.TargetCollectionInput
A ConnectApi.TargetCollectionInput object that defines the targets.

Return Value

Type: ConnectApi.TargetCollection

deleteAudience(communityId, audienceId)

Delete an audience.

API Version

48.0

Requires Chatter

No

Signature

public static Void deleteAudience(String communityId, String audienceId)

Parameters

communityId
Type: String
ID of the community.
audienceId
Type: String
ID of the audience.

Return Value

Type: Void

deleteTarget(communityId, targetId)

Delete a target.

API Version

48.0

Requires Chatter

No

Signature

public static Void deleteTarget(String communityId, String targetId)

Parameters

communityId
Type: String
ID of the community.
targetId
Type: String
ID of the target.

Return Value

Type: Void

getAudience(communityId, audienceId, includeAudienceCriteria)

Get an audience.

API Version

48.0

Available to Guest Users

48.0

Requires Chatter

No

Signature

public static ConnectApi.Audience getAudience(String communityId, String audienceId, Boolean includeAudienceCriteria)

Parameters

communityId
Type: String
ID of the community.
audienceId
Type: String
ID of the audience.
includeAudienceCriteria
Type: Boolean
Specifies whether to include audience criteria (true) or not (false). If unspecified, defaults to false.

Return Value

Type: ConnectApi.Audience

getAudienceBatch(communityId, audienceIds)

Get audience information for a comma-separated list of audience IDs.

API Version

48.0

Available to Guest Users

48.0

Requires Chatter

No

Signature

public static ConnectApi.BatchResult[] getAudienceBatch(String communityId, List<String> audienceIds)

Parameters

communityId
Type: String
ID of the community.
audienceIds
Type: List<String>
Comma-separated list of audience IDs.

Return Value

Type: ConnectApi.BatchResult[]

The ConnectApi.BatchResult.getResult() method returns a ConnectApi.Audience object and errors for audiences that didn’t load.

getAudiences(communityId, ipAddress, domain, userId, publishStatus, includeAudienceCriteria, targetTypes)

Get a list of audiences that include a user.

API Version

48.0

Available to Guest Users

48.0

Requires Chatter

No

Signature

public static ConnectApi.AudienceCollection getAudiences(String communityId, String ipAddress, String domain, String userId, ConnectApi.PublishStatus publishStatus, Boolean includeAudienceCriteria, List<String> targetTypes)

Parameters

communityId
Type: String
ID of the community.
ipAddress
Type: String
IP address of the user. If null, no audiences with location criteria are returned.
domain
Type: String
Name of the user’s Salesforce custom domain. If null, no audiences with domain criteria are returned.
userId
Type: String
ID of the user. If null, defaults to the ID of the context user.
publishStatus
Type: ConnectApi.PublishStatus
Publish status of the audience. Values are:
  • Draft
  • Live
If null, defaults to Live.
includeAudienceCriteria
Type: Boolean
Specifies whether to include audience criteria (true) or not (false). If unspecified, defaults to false.
targetTypes
Type: List<String>
Comma-separated list of target types to filter the results. Supported values include:
  • ExperienceVariation (version 48.0 and later)
  • Custom object API names, such as CustomObjectName__c (version 48.0 and later)
  • NavigationLinkSet (version 49.0 and later)
  • Topic (version 49.0 and later)
  • CollaborationGroup (version 49.0 and later)
  • KnowledgeArticle (version 49.0 and later)
  • ContentDocument (version 49.0 and later)
  • ManagedContent (version 49.0 and later)
  • Report (version 49.0 and later)
  • Dashboard (version 49.0 and later)
If null, all target types are returned.

Return Value

Type: ConnectApi.AudienceCollection

getTarget(communityId, targetId)

Get a target.

API Version

48.0

Available to Guest Users

48.0

Requires Chatter

No

Signature

public static ConnectApi.Target getTarget(String communityId, String targetId)

Parameters

communityId
Type: String
ID of the community.
targetId
Type: String
ID of the target.

Return Value

Type: ConnectApi.Target

getTargets(communityId, ipAddress, domain, userId, publishStatus, recordId, targetTypes, includeAudience, includeAllMatchingTargetsWithinGroup, groupNames)

Get a list of targets that match the context user, based on the audiences that include the user.

API Version

48.0

Available to Guest Users

48.0

Requires Chatter

No

Signature

public static ConnectApi.TargetCollection getTargets(String communityId, String ipAddress, String domain, String userId, ConnectApi.PublishStatus publishStatus, String recordId, List<String> targetTypes, Boolean includeAudience, Boolean includeAllMatchingTargetsWithinGroup, List<String> groupNames)

Parameters

communityId
Type: String
ID of the community.
ipAddress
Type: String
IP address of the user. If null, no audiences with location criteria are returned.
domain
Type: String
Name of the user’s Salesforce custom domain. If null, no audiences with domain criteria are returned.
userId
Type: String
ID of the user. If null, the default is the ID of the context user.
publishStatus
Type: ConnectApi.PublishStatus
Publish status of the target. Values are:
  • Draft
  • Live
recordId
Type: String
ID of the record, if you want to specify field based criteria in audiences.
targetTypes
Type: List<String>
Comma-separated list of target types to filter the results. Supported values include:
  • ExperienceVariation (version 48.0 and later)
  • Custom object API names, such as CustomObjectName__c (version 48.0 and later)
  • NavigationLinkSet (version 49.0 and later)
  • Topic (version 49.0 and later)
  • CollaborationGroup (version 49.0 and later)
  • KnowledgeArticle (version 49.0 and later)
  • ContentDocument (version 49.0 and later)
  • ManagedContent (version 49.0 and later)
  • Report (version 49.0 and later)
  • Dashboard (version 49.0 and later)
If null, all target types are returned.
includeAudience
Type: Boolean
Specifies whether to include the matching audience (true) or not (false). If null, the default is false.
includeAllMatchingTargetsWithinGroup
Type: Boolean
Specifies whether to include all the matching targets within a target group (true) or not (false). If null, the default is false. If false, the first matching target within each group, based on priority within the group, is returned.
groupNames
Type: List<String>
A comma-separated list of group names. Groups bundle related target and audience pairs.

Return Value

Type: ConnectApi.TargetCollection

updateAudience(communityId, audienceId, audience)

Update an audience.

API Version

48.0

Requires Chatter

No

Signature

public static ConnectApi.Audience updateAudience(String communityId, String audienceId, ConnectApi.AudienceInput audience)

Parameters

communityId
Type: String
ID of the community.
audienceId
Type: String
ID of the audience.
audience
Type: ConnectApi.AudienceInput
A ConnectApi.AudienceInput object that defines the updates to the audience.

Return Value

Type: ConnectApi.Audience

updateTargets(communityId, target)

Update targets.

API Version

48.0

Requires Chatter

No

Signature

public static ConnectApi.TargetCollection updateTargets(String communityId, ConnectApi.TargetCollectionUpdateInput target)

Parameters

communityId
Type: String
ID of the community.
target
Type: ConnectApi.TargetCollectionUpdateInput
A ConnectApi.TargetCollectionUpdateInput object that defines the updates for the targets.

Return Value

Type: ConnectApi.TargetCollection