# Iterable

## Why combine Iterable and Purchasely?

### Pre-requisites

The minimal version of the Purchasely SDK supporting this integration is v3.3.0. If the Purchasely SDK integrated in your app is under the minimal version, please update it.

The Iterable SDK also needs to be integrated inside the app.

### Subscription events

### General overview

[Iterable](https://iterable.com) is a cross-channel marketing platform that powers unified customer experiences and empowers you to create, optimize and measure every interaction across the entire customer journey.

This integration will allow you to get all Purchasely [subscription events](#subscription-events) to Iterable making you able to trigger automated communication based on those events, messages that could be linked to a Purchasely powered paywall to engage, upsell, retain customers.

Purchasely provides a unified dataset to track the subscription events for all stores. These events are generated by the Purchasely Backend and can be sent to Iterable.

![](https://2145676854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKuAJGBnHJWZbqzA4g8yO%2Fuploads%2Fgit-blob-45df9d75ce2a49b2f164156124fd5c2800074df7%2Fimage%20\(150\)%20\(1\).png?alt=media)

Subscription events generated by Purchasely will be sent to Iterable using a server-to-server integration.

#### Events

The following events are the main ones that can be sent to Iterable by Purchasely. See the full list [here](https://purchasely.gitbook.io/purchasely/analytics/events/webhook-events/subscription-events).

| Event                           | Description                                                                                                              |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| SUBSCRIPTION\_STARTED           | Sent when the user purchased a product wether it is the start of a trial or a regular purchase of a consumable product.  |
| SUBSCRIPTION\_RENEWED           | Sent when a subscription renews                                                                                          |
| SUBSCRIPTION\_EXPIRED           | Sent when the subscription actually ends                                                                                 |
| SUBSCRIPTION\_REACTIVATED       | Sent when an expired subscription is reactivated. This event is particularly useful for win-back & retargeting campaigns |
| SUBSCRIPTION\_REFUNDED\_REVOKED | Sent when the subscription actually ends                                                                                 |
| RENEWAL\_DISABLED               | Sent when the user deactivates the renewal of a subscription wether it is in trial period or not.                        |
| RENEWAL\_ENABLED                | Sent when the user reactivates                                                                                           |
| TRIAL\_STARTED                  | Sent when a trial starts                                                                                                 |
| TRIAL\_CONVERTED                | Sent when a user converts from a free trial to a normal paid-period                                                      |
| TRIAL\_NOT\_CONVERTED           | Sent when a user finishes it's trial period without renewing to a paid-period                                            |

The names of events sent to Iterable can be overriden when setting up the integration.

## **Integrating Purchasely with Iterable**

The integration requires 2 steps:

1. Associate the user to events by providing the `Iterable User ID` or your user's email (depending on which you use with Iterable) to the Purchasely SDK
2. Activate the Iterable integration in the Purchasely Console

### 1. Associating users to events

See the [Iterable Documentation](https://support.iterable.com/hc/en-us/articles/360035402531-Identifying-the-User-#identifying-the-user-by-user-id) for more information

{% tabs %}
{% tab title="Swift" %}

```swift
Purchasely.setAttribute(.iterableUserId, value: "userId")
//or use email
Purchasely.setAttribute(.iterableUserEmail, value: "mail@company.com")
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Purchasely.setAttribute(Attribute.ITERABLE_USER_ID, "userId")
//or use email
Purchasely.setAttribute(Attribute.ITERABLE_USER_EMAIL, "mail@company.com")
```

{% endtab %}

{% tab title="Java" %}

```java
Purchasely.setAttribute(Attribute.ITERABLE_USER_ID, "userId");
//or use email
Purchasely.setAttribute(Attribute.ITERABLE_USER_EMAIL, "mail@company.com");
```

{% endtab %}

{% tab title="React Native" %}

```jsx
Purchasely.setAttribute(Attributes.ITERABLE_USER_ID,  "userId");
//or use email
Purchasely.setAttribute(Attributes.ITERABLE_USER_EMAIL,  "mail@company.com");
```

{% endtab %}
{% endtabs %}

### 2. Activating the Iterable integration

The activation requires 2 steps:

1. Setting up a new ServerSide Integration API Key in the Iterable Dashboard
2. Enabling the Iterable integration in the Purchasely Console

#### a. Retrieve your Iterable API Key from the Iterable Dashboard

1. Follow [the Iterable documentation](https://support.iterable.com/hc/en-us/articles/360043464871-API-Keys-#creating-api-keys)
2. Write down your API Key

#### b. Enabling the Iterable integration in the Purchasely Console

1. Go in the "External integrations" section, and open the edition form for Iterable:

&#x20;![](https://2145676854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKuAJGBnHJWZbqzA4g8yO%2Fuploads%2Fgit-blob-2a0124de182f9469878b194a53d8e7d4ece23ce1%2FScreenshot%202022-07-08%20at%2000.10.34.png?alt=media)

2\. Enable the integration

3\. Set your Iterable API Key’

&#x20;![](https://2145676854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKuAJGBnHJWZbqzA4g8yO%2Fuploads%2Fgit-blob-ac6788d6dd77e61b416f36062a625c905d9f6a09%2FScreenshot%202022-07-08%20at%2000.11.06.png?alt=media)

4\. Enable the events you want to be sent to Iterable

5\. (Optional) Override the names of the events that will be sent to Iterable

&#x20;![](https://2145676854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKuAJGBnHJWZbqzA4g8yO%2Fuploads%2Fgit-blob-e3368d2b341f064881cb31e7a96d697d67261325%2FScreenshot%202022-07-08%20at%2000.11.39.png?alt=media)

6\. Save

### Testing your integration

To test your integration, you can perform a set of in-app purchases in a Sandbox environment (eg: TestFlight for the App Store) and verify your events are received in the Iterable dashboard <https://app.iterable.com/login>.

{% hint style="info" %}
If your events do not appear, check in your Iterable Projects Settings (<https://app.iterable.com/settings/project>) that your event is listed under `Existing custom events` *or* that `Allow new custom events into the system` is enabled.
{% endhint %}
