# Templated Webhooks

_Templated Webhooks_ or _Incoming Webhooks_ is a generic integration for collecting data.

## How It Works

Kevel Audience supports receiving event data in real time from incoming webhooks. This integration is available for a limited number of third party integrations, but we do integrate with new services according to client request.

A specific URL is available for each specific integration. Please make sure you adjust this URL to match your Kevel Audience domain. The URL can be used to configure the webhook integration with the third party.

- Mailgun – `https://tr.cdp.domain.com/events/templated/mailgun`
- Postmark – `https://tr.cdp.domain.com/events/templated/postmark`
- Sendinblue – `https://tr.cdp.domain.com/events/templated/sendinblue`
- [Segment](https://docs.audience.kevel.com/collect/templated-webhooks#segment) – `https://webhooks.cdp.domain.com/sources/segment`

## Segment

Kevel Audience supports receiving events from Segment as a webhook destination.

To get started feel free to follow the [Segment documentation](https://segment.com/docs/connections/destinations/catalog/webhooks/#getting-started) on how to setup a webhook destination and make sure to specify and adapt the webhook endpoint `https://webhooks.cdp.domain.com/sources/segment` for your domain.

Supported events are listed below.

### Supported Events

Kevel Audience currently supports both [Segment Identify](https://segment.com/docs/connections/spec/identify/) and [Segment Track](https://segment.com/docs/connections/spec/track/) event types. Additionally, user attributes are derived from the event's [context](https://segment.com/docs/connections/spec/common/#context) and [traits](https://segment.com/docs/connections/spec/identify/#traits) fields.

#### Track

Kevel Audience uses the types defined by [Semantic Event Spec](https://segment.com/docs/connections/spec/semantic/) to map incoming events. Furthermore, the geolocation is extracted as-is from the event's context. This information is derived from the user's IP only if the geolocation is unavailable. All the events supported by Kevel Audience are documented below alongside their mapping. Events not listed are translated to a [`custom`](https://docs.audience.kevel.com/collect/events/custom) event type with the `customType` set to `Segment {event name}`.

**Email**  
- `Email Bounced` => [`emailBounce`](https://docs.audience.kevel.com/collect/events/emailBounce)  
- `Email Delivered` => [`emailDelivery`](https://docs.audience.kevel.com/collect/events/emailDelivery)  
- `Email Link Clicked` => [`emailClick`](https://docs.audience.kevel.com/collect/events/emailClick)  
- `Email Opened` => [`emailView`](https://docs.audience.kevel.com/collect/events/emailView)  
- `Unsubscribed` => [`emailUnsubscribe`](https://docs.audience.kevel.com/collect/events/emailUnsubscribe)

**E-Commerce**  
- `Product Added to Wishlist` => [`addToWishlist`](https://docs.audience.kevel.com/collect/events/addToWishlist)  
- `Product List Filtered` => [`productImpression`](https://docs.audience.kevel.com/collect/events/productImpression)  
- `Product List Viewed` => [`productImpression`](https://docs.audience.kevel.com/collect/events/productImpression)  
- `Checkout Step Completed` => [`checkoutStep`](https://docs.audience.kevel.com/collect/events/checkoutStep)  
- `Product Reviewed` => [`productFeedback`](https://docs.audience.kevel.com/collect/events/productFeedback)  
- `Product Clicked` => [`productClick`](https://docs.audience.kevel.com/collect/events/productClick)  
- `Product Viewed` => [`productView`](https://docs.audience.kevel.com/collect/events/productView)  
- `Order Cancelled` => [`orderPlace`](https://docs.audience.kevel.com/collect/events/orderPlace)  
- `Order Completed` => [`orderPlace`](https://docs.audience.kevel.com/collect/events/orderPlace)  
- `Order Refunded` => [`orderPlace`](https://docs.audience.kevel.com/collect/events/orderPlace)  
- `Order Updated` => [`orderPlace`](https://docs.audience.kevel.com/collect/events/orderPlace)  
- `Products Searched` => [`search`](https://docs.audience.kevel.com/collect/events/search)  
- `Cart Viewed` => [`cartView`](https://docs.audience.kevel.com/collect/events/cartView)  
- `Product Added` => [`addToCart`](https://docs.audience.kevel.com/collect/events/addToCart)  
- `Product Removed` => [`removeFromCart`](https://docs.audience.kevel.com/collect/events/removeFromCart)  
- `Wishlist Product Added to Cart` => [`addToCart`](https://docs.audience.kevel.com/collect/events/addToCart)

#### Identify

Matching [User IDs](https://docs.audience.kevel.com/collect/user-ids) is supported via the [Identify](https://segment.com/docs/connections/spec/identify/) event type. The list of IDs extracted are:

- `email` as [Plaintext Email](https://docs.audience.kevel.com/collect/user-ids#email)  
- `phone` in the [E.123](https://en.wikipedia.org/wiki/E.123) format and converted to [Phone Number SHA256](https://docs.audience.kevel.com/collect/user-ids#phone-number-e164-sha256)

In addition, the following user-related attributes are extracted from the event's [context](https://segment.com/docs/connections/spec/common/#context) and [traits](https://segment.com/docs/connections/spec/identify/#traits) fields.

- `geo.latlong.latest`  
- `geo.latlong.list`  
- `geo.country.latest`  
- `geo.country.list`  
- `geo.city.latest`  
- `geo.city.list`  
- `devices.family.latest`  
- `devices.family.list`  
- `devices.os.latest`  
- `devices.os.list`  
- `devices.type.latest`  
- `devices.type.list`

### Authorization / Authentication (Optional)

Segment allows defining a shared secret to validate the incoming events. To use this authentication method, start by setting up the shared secret on the Segment's webhook destination and then communicate it with your Customer Success Manager.

For more information feel free to visit the [Segment documentation](https://segment.com/docs/connections/destinations/catalog/webhooks/#getting-started).
