# Use geolocation

> You can create campaigns that only trigger if your customer is in a specific location. This is also known as geofencing.

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

To do this:

1. Define a [custom attribute](/docs/dev/concepts/attributes.md#custom-attributes) on
   the session entity.
1. Set its value in the session with the [Update customer session][upsession] endpoint.
1. Check the location in a rule.

## Create the location attribute

This attribute will be used to store the session's location in Talon.One.
For more information on creating custom attributes, see [Attributes][attr].

1. Create a custom attribute with the following information:
   - Associated entity: **session**
   - Attribute type: **location**
1. Choose and remember its **API name**. We will use it in the
   `Update customer session` requests.

## Pass location data via the Integration API

Attributes of type `location` can be set via the
[Update customer session][upsession] endpoint inside the `attributes` property.

For location attributes, we can use the following data formats:

- `GeoJson`
- `GeoJsonBase64`
- `Point`

:::important
All coordinate values are represented as `[longitude, latitude]` where:

- longitude: distance east or west of the prime meridian.
- latitude: distance north or south of the equator.

:::

For example, the `Point` format consists of a single string
that contains the coordinates, in a comma-separated string, such as:

```javascript
"my_location_attribute_internal_name": {
  "format": "point",
  "object": "13.391799, 52.498605"
}
```

:::note Example
When used inside a [Update customer session][upsession] endpoint request:

```json
curl https://example.talon.one/v2/customer_sessions/C156904 \
-X PUT \
-d '{
  "profileId": "35",
  "attributes": {
    "my_location_attribute_internal_name": {
      "format": "point",
      "object": "13.391799, 52.498605"
    }
  }
}'
```

:::

## Evaluate the position in a Rule

Any [standard campaign](/docs/product/campaigns/overview#standard-campaigns) with
access to the attribute can now evaluate the location data using the **Check attribute value**
condition:

## Related pages

- [Product docs tutorial on creating a channel-specific coupon campaign for segmentation purposes](/docs/product/tutorials/coupons/segmentation-coupon-campaign.md)
- [Attributes][attr]

[upsession]: /integration-api#tag/Customer-sessions/operation/updateCustomerSessionV2
[attr]: /docs/dev/concepts/attributes.md
