# Rehook Destination

## Destination Info

* Accepts [Page](/docs/segment/connections/spec/page), [Alias](/docs/segment/connections/spec/alias), [Group](/docs/segment/connections/spec/group), [Identify](/docs/segment/connections/spec/identify), [Track](/docs/segment/connections/spec/track) calls.
* Refer to it as **Rehook** in the [Integrations object.](/docs/segment/guides/filtering-data/#filtering-with-the-integrations-object)
* This integration is **partner owned.** Please reach out to the partner's support for any issues.
* This destination is **Beta.**

[Rehook](https://rehook.ai/) is a powerful and dedicated user-incentivization solution that enables businesses to reward and engage users without depending on tech teams. With an elegant and easy-to-use interface, Rehook is designed to help you run user-promotion campaigns that are flexible, customizable and scalable.

This destination is maintained by Rehook. For any issues with the destination, [contact the Rehook Support team](mailto:services@rehook.ai).

## Getting started

1. From the Destinations catalog page in the Segment App, click **Add Destination**.
2. Search for **Rehook** in the Destinations Catalog, and select the **Rehook** destination.
3. Select which Source should send data to the Rehook destination.
4. Open the [Rehook Dashboard](https://dashboard.rehook.ai/) and navigate to **Settings > API Keys & Secret Key**. Copy your key.
5. Open the Segment app and paste the **API Key & Secret Key** in the Rehook destination settings page.

## Supported methods

Rehook's destination is designed to support the following [Segment Spec](/docs/segment/connections/spec) methods. Because this is an Actions Destination, you can also map other Segment methods.

### Identify

If you're not familiar with the Segment Spec, take a moment to understand what the [Identify method](/docs/segment/connections/spec/identify/) does.
An example call looks like this:

#### Example 1:

```js
analytics.identify('userId12345', {
  firstName: 'Bob',
  lastName: 'Dole',
  email: 'bob.dole@example.com',
  company: 'Initech',
  employees: 234
});
```

#### Example 2:

```js
analytics.identify('userId12345', {
  firstName: 'Bob',
  lastName: 'Dole',
  email: 'bob.dole@example.com',
  company: 'Initech',
  employees: 234,
  referral_code: "ERTYUS"
});
```

Every time you make an Identify call with an included `userId`:

1. Rehook verifies that the `userId` exists.
2. If the `userId` does not exist, Rehook adds the user as a Customer to the Rehook database and matches user properties with the Segment `traits` sent in the Identify call payload.
3. If the `userId` exists, Rehook updates the user properties for the Customer against the Segment `traits` sent in the Identify call payload.
4. If `referral_code` is unique, Rehook updates the user properties in its database.

All of the [traits](/docs/segment/connections/spec/identify#traits) recognized by Segment are translated and matched with the Rehook Customer user properties. These fields are automatically created or mapped for a Customer in Rehook and are available for personalization and advanced segmentation.

> \[!NOTE]
>
> * The `userId` field is required. Rehook drops Identify calls without a userId.
> * If a call is made with `anonymousID`, Rehook drops the Identify call.
> * If `referral_code` matches with another `userId`, Rehook drops the Identify call.

### Track

If you're not familiar with the Segment Spec, take a moment to understand what the [Track method](/docs/segment/connections/spec/track/) does.

An example call looks like this:

#### Example 1:

```js
analytics.track('Product Viewed', {
  userId: "userId12345",
  product_id: '507f1f779439011',
  name: 'Monopoly: 3rd Edition',
  price: 18.99,
  url: 'https://www.example.com/product/path',
  image_url: 'https://www.example.com/product/path.jpg'
});
```

#### Example 2:

```js
analytics.track('signup', {
  userId: "userId12345",
  referral_code: 'ERTYUS'
});
```

Segment sends Track calls to Rehook as a Custom Event. When you make a Track call, Segment sends the event to Rehook with the event name and all properties that you specified.

> \[!NOTE]
>
> * The `userId` field is required. Rehook drops Track calls without a `userId`.
> * If a call is made with `anonymousId`, Rehook drops the Track call.
> * The `referral_code` field is required if event name is set as a conversion event in Rehook.

## Destination Settings

| Field      | Description            | Required | Type     |
| ---------- | ---------------------- | -------- | -------- |
| Api Key    | Your Rehook API Key    | Yes      | password |
| Api Secret | Your Rehook API Secret | Yes      | password |

## Available Actions

Build your own Mappings. Combine supported [triggers](/docs/segment/connections/destinations/actions/#components-of-a-destination-action) with the following Rehook-supported actions:

> \[!NOTE]
>
> Individual destination instances have support a maximum of 50 mappings.

* [Identify User](#identify-user-9)
* [Track Event](#track-event-12)

### Identify User

Send the identify event to create or update the customer in rehook.

Identify User is a **Cloud** action. The default Trigger is `type = "identify"`

| Field         | Description                           | Required | Type   |
| ------------- | ------------------------------------- | -------- | ------ |
| Source ID     | The unique user identifier set by you | Yes      | STRING |
| User Metadata | Properties to set on the user profile | No       | OBJECT |
| Referral Code | The referral code of the user         | No       | STRING |

### Track Event

Send the Track event to rehook.

Track Event is a **Cloud** action. The default Trigger is `type = "track"`

| Field            | Description                                                                                   | Required | Type   |
| ---------------- | --------------------------------------------------------------------------------------------- | -------- | ------ |
| Event Name       | The name of the event being performed.                                                        | Yes      | STRING |
| Source ID        | The unique user identifier set by you                                                         | Yes      | STRING |
| Event Properties | An object of key-value pairs that represent event properties to be sent along with the event. | No       | OBJECT |

## Engage

You can send computed traits and audiences generated using [Engage](/docs/segment/engage) to this destination as a **user property**. To learn more about Engage, schedule a [demo](https://segment.com/contact/demo).

For user-property destinations, an [identify](/docs/segment/connections/spec/identify/) call is sent to the destination for each user being added and removed. The property name is the snake\_cased version of the audience name, with a true/false value to indicate membership. For example, when a user first completes an order in the last 30 days, Engage sends an Identify call with the property `order_completed_last_30days: true`. When the user no longer satisfies this condition (for example, it's been more than 30 days since their last order), Engage sets that value to `false`.

When you first create an audience, Engage sends an Identify call for every user in that audience. Later audience syncs only send updates for users whose membership has changed since the last sync.

> \[!NOTE]
>
> Real-time audience syncs to Rehook  may take six or more hours for the initial sync to complete. Upon completion, a sync frequency of two to three hours is expected.

## Settings

Segment lets you change these destination settings from the Segment app without having to touch any code.

| Field      | Description            | Required | Type     |
| ---------- | ---------------------- | -------- | -------- |
| Api Key    | Your Rehook API Key    | Yes      | password |
| Api Secret | Your Rehook API Secret | Yes      | password |
