Cookies trait configuration
As of version 2.1.0, the Personalization module provides two implementations of cookie traits:
- 
New cookie trait implementation in the magnolia-personalization-traitssubmodule.
- 
Older (deprecated) implementation in the magnolia-personalization-compatibilitysubmodule.
Even though in both implementations you can create and use multiple cookies, we recommend using the new implementation since a cookie trait is easily configurable there using the @TraitType annotation.
Cookie trait definition properties
| Property | Description | ||
|---|---|---|---|
| 
 | required Trait name. The property can be omitted if the definition is done using a YAML configuration file. The value is taken from the name of the file. | ||
| 
 | required (module version 2.1.x and higher) Since you are configuring a cookie trait, use  The  
 
 | ||
| 
 | required Field used to define permitted values for the trait. The options display in the Choose audience dialog. See also Configuring the rule field. | ||
| 
 | required Field used to set permitted values for personalized content delivery. The options displayed in the Preview app. See also Configuring the value field. | ||
| 
 | required (module version 2.0.x and earlier) Cookie parameter converter (info.magnolia.personalization.cookie.CookieParameterConverter). | ||
| 
 | optional, default is  Displays all cookie trait options in the Preview app by default when set to  | ||
| 
 | optional, default is  Indicates whether the trait should be pre-set in the Choose audience dialog. | ||
| 
 | optional (module version 2.1.1 and higher) Disables the respective trait in the Choose audience dialog when set to  | ||
| 
 | required (module version 2.0.x and earlier) Specifies the cookie trait class (info.magnolia.personalization.cookie.Cookies). | ||
| 
 | required (module version 2.0.x and earlier) Matches the cookie name to the cookie value (info.magnolia.personalization.cookie.CookieVoter). See also Voters. | 
Configuration examples
New implementation
$type: cookieTrait
ruleField:
  $type: comboBoxField
  name: value
  label: Gender
  datasource: &datasource
    $type: optionListDatasource
    options:
      - name: male
        value: male
      - name: female
        value: female
      - name: other
        value: other
valueField:
  $type: comboBoxField
  label: Gender
  datasource: *datasource| 
 | 
Deprecated implementation
cookies:
  converterClass: info.magnolia.personalization.cookie.CookieParameterConverter
  defaultPreviewTrait: false
  defaultRuleTrait: false
  traitClass: info.magnolia.personalization.cookie.Cookies
  voterClass: info.magnolia.personalization.cookie.CookieVoter
  ruleField:
    class: info.magnolia.ui.form.field.definition.SwitchableFieldDefinition
    transformerClass: info.magnolia.personalization.cookie.CookieFieldTransformer
    options:
      weatherLocality:
        value: weatherLocality
      tourType:
        value: tourType
    fields:
      weatherLocality:
        class: info.magnolia.ui.form.field.definition.SelectFieldDefinition
        defaultValue: any
        options:
          any:
            label: cookies.anyValue
            value: any
          london:
            value: London
          basel:
            value: Basel
      tourType:
        class: info.magnolia.ui.form.field.definition.SelectFieldDefinition
        defaultValue: none
        options:
          any:
            label: cookies.anyValue
            value: any
          none:
            label: cookies.noValue
            value: none
  valueField:
    class: info.magnolia.ui.form.field.definition.OptionGroupFieldDefinition
    multiselect: true
    options:
      weatherLocalityLondon:
        value: weatherLocality=London
      weatherLocalityBasel:
        value: weatherLocality=Basel
      tourTypeAny:
        value: tourType=any