API Reference / API Methods / Personalization / Add strategy

Add Strategy

Required API Key: any key with the editSettings ACL
Method signature
$client->setPersonalizationStrategy(array strategy)

About this method

You are currently reading the documentation of the JavaScript API Client v4. Read our migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.

Set a personalization strategy.

Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$recommendation->setPersonalizationStrategy([
    'eventsScoring' => [
        [
            'eventName' => 'Add to cart',
            'eventType' => 'conversion',
            'score' => 50,
        ],
        [
            'eventName' => 'Purchase',
            'eventType' => 'conversion',
            'score' => 100,
        ],
    ],
    'facetsScoring' => [
        ['facetName' => 'brand', 'score' => 100],
        ['facetName' => 'categories', 'score' => 10],
    ],
    'personalizationImpact' => 50,
]);

Parameters

strategy
type: object
Required

A strategy object.

{
  "eventScoring": eventsScoring,
  "facetsScoring": facetsScoring
}

strategy

eventsScoring
type: object
Required

Associate a score to an event

1
2
3
4
5
6
{
  "${eventName}": {
    "score": int // mandatory
    "type": string // mandatory
  }
}
facetsScoring
type: object
Required

Associate a score to a facet.

1
2
3
4
5
  {
    "${facetName}": {
      "score": int // mandatory
    }
  }
requestOptions
type: key/value mapping
default: No request options
Optional

A mapping of request options to send along with the request.

Response

No response

Did you find this page helpful?