Using Session Custom Attributes

Using session custom attributes, you can customize unique session information to identify customers for a customer group. To do this you must configure customized session custom attributes in Business Manager and in your application.

Note: For all API responses with session custom attributes, the default attribute name 'Session Custom Attribute' is used.

Setting Session Custom Attributes

First, you must define a customer group to use session custom attributes. See Creating a Dynamic Customer Group.

Then, you must set a custom session attribute using "session.custom.<attributename> =" in your application.

For example: session.custom.firstname = "Suri"; _firstName = session.custom.firstname

These attributes are defined implicitly when they are set and are stored in the session.

Parsing Session Custom Attributes

Salesforce B2C Commerce doesn't have metadata about session custom attributes and hence doesn't know the actual attribute type. It can only evaluate session custom attribute conditions in a meaningful way if the condition is applicable for the actual type of the session custom attribute. It tries to determine the intended session type when creating a condition rather than determining it during rule evaluation.

If the selected operator used is... B2C Commerce assumes
'exists', 'don't exist' String
'is greater than', 'is less than', 'is greater than or equals', 'is less than or equals', 'is in range' Number
'is true', 'is false' Boolean
'starts with', 'ends with', 'contains', 'doesn't contain' String
'is equal', 'is not equal' If the value string representation is "true" or "false", we assume Boolean
  If the value string starts with a number, we assume Number
  Else, we assume String

If a condition isn't applicable for the actual type of the session custom attribute, the condition doesn't match. For example, if during rule evaluation, the session custom attribute evaluates to a number from the customer's session, but the actual type is Boolean, the condition evaluates to false.

Using "Is Equal" with Session Custom Attributes

Conditions on string values are converted into conditions on numeric or Boolean values, with these specific conditions, all of which must apply:

If it isn't a session custom attribute, or the operator isn't is equal, or at least one condition value isn't numeric or boolean, Business Manager treats it as a string. Previously, the assignment to a session-based customer group did not work when the membership rule had the previous conditions.

For example, with customers with the session custom attribute 'solvencyScore' = '4', where the session attribute is a number, that is, Double(4.0), the conditions were stored and evaluated like conditions on strings. The number was converted into a string "4.0", and compared with the condition value "4", which did not match.

In Business Manager, when you define the values for session custom attributes:

Rule Evaluation

Numeric conditions on session custom attributes now match if the value of the session custom attribute is a string. Previously, a numeric condition did not match in this situation.

Numeric condition on a string attribute

For example, this rule with a numeric condition applies on a session custom attribute with a string value: "session.custom.myAttribute = 4.0"

Value of myAttribute Rule matched previously Rule matched now
"foobar" No No
"4" No Yes
"4.0" No Yes
"4.5" No No

String condition on numeric attribute

We did not change the way B2C Commerce processes a rule with a string condition on a session custom attribute with a numeric value. For example "session.custom.myAttribute is equal [4,4.1 beta]" applies as follows:

Value of myAttribute Rule matched previously
4 Yes
Decimal("4") Yes
BigInteger("4") Yes
4.0 No
4.5 No
Number("4") No
Number("4.5") No
Decimal("4.5") No
Tip: If you like the way this rule works, use "session.custom.myAttribute is equal [4,4.0]".

Related Links

Dynamic Customer Group Rules

Creating a Dynamic Customer Group

Customer Groups Object Import Export

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.