Creating the customer session attribute
Let's create the custom attribute:
- Click Account in the left-most menu.
- Click Dev tools > Attributes.
- Click Create attribute at the top-right of the page.
- In Associated entity, choose the entity that will own the attribute. In our case,
- In Attribute type, choose the type of value assigned to the attribute:
- In API name (internal), type the name of the attribute as you will use it in the
integration layer. Let's use
- In Title (visible), type the name of the attribute. It will appear in the palette.
- In Description, type a description of what the attribute represents, such as
Customer session shipping city
- In Suggestions, type down some potential values, such as
- In Available in Applications, you can select the Applications where you want to use the attribute. We choose none, so the attribute will be available everywhere.
- Click Create attribute.
Setting the value of the attribute
The attribute is ready to be used by the integration layer. Since we have created a customer session attribute, its value is set programmatically using the customer session endpoint.
For example, we can set
Berlin with the following payload:
Issuing a discount on the session total
Let's build the rule for customers who choose Berlin as their shipping city to receive a discount:
- Click Rule Builder in the left-side menu of our campaign.
- Click Add Rule.
- Type a name for your rule. For example,
Discount on session total when shipping to Berlin.
- In Conditions, click Add condition.
- Click Validate attribute value.
- Select Shipping city (current session) in the palette.
- In the drop-down menu, choose is equal to.
- Select a city in the drop-down menu with all our suggestions or type the name of
another city. In our example, we choose
Berlin, which appears on the list.
- Click Done.
- In Effects, click Add effect.
- Click Discount session total.
- In Discount name, type a suitable name, such as
Berlin 10% off.
- Set Discount value to
- Click Done.
- Click Save at the top right of the page.
Now, when a customer with Berlin as their current shipping city adds items to their cart, they will see a 10% discount applied to it.