# Discount a session based on purchase location

> Let's create a customer session custom attribute referring to the customer's shipping city and use it in a promotion rule to discount the session total.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

## Store the shipping city

Let's start by storing the customer's shipping city so we can use it in the Rule Builder.
To do this, we [create a custom attribute](/docs/product/account/dev-tools/manage-attributes.md#create-a-custom-attribute).

- Associated entity: `customer session`
- Attribute type: `string`
- API name: `ShippingCity`
- Rule Builder name: `Shipping city`
- Rule Builder description: `Customer session shipping city`
- Picklist values: `Berlin`, `Paris`, `London`, `Madrid`, `Helsinki`, `Dublin` and `Lisbon`
- Available in our Application

## Set 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 [Update customer session](/integration-api#tag/Customer-sessions/operation/updateCustomerSessionV2) endpoint.

For example, we can set `ShippingCity` to `Berlin` with the following payload:

```json {14-16}
{
    "customerSession": {
        "profileId": "DE29HDG94NV",
        "state": "open",
        "cartItems": [
            {
                "name": "Camera",
                "sku": 483092756,
                "quantity": 2,
                "price": 159.99
            }
        ],
        "attributes": {
            "ShippingCity": "Berlin"
        }
    },
    "responseContent": [
        "customerSession",
        "customerProfile"
    ]
}
```

## Issue a discount on the session total

In a [standard campaign](/docs/product/campaigns/overview#standard-campaigns), let's
build a rule for customers who choose Berlin as their shipping city to receive a discount.
We can name it `Discount on session total when shipping to Berlin`, and it has 1
condition and one effect.

### Condition

**Check attribute value**:

- Attribute is **Shipping city (current session)**.
- **Is equal to** `Berlin`.

### Effect

**Discount session total**: **Name** is `Berlin 10% off` and **Discount value** is `[Session.Total]*10%`.

## Related pages

- [Create templates](/docs/product/campaigns/templates/create-templates.md)
- [Create a discount using cart item filters](/docs/product/tutorials/coupons/cart-item-filters-discount.md)
- [Create a channel-specific coupon campaign](/docs/product/tutorials/coupons/segmentation-coupon-campaign.md)
