# Customer.io

## Why combine Customer.io and Purchasely?

### Pre-requisites

The minimal version of the Purchasely SDK supporting this integration is //TODO: Kevin. If the Purchasely SDK integrated in your app is under the minimal version, please update it.

The Customer.io SDK also needs to be integrated inside the app.

### Subscription events

### General overview

[Customer.io](https://github.com/Purchasely/gitbook/blob/main/integrations/$%7Bintegration_website_url%7D/README.md) is a leading is an automated messaging platform for tech-savvy marketers who want more control and flexibility to craft and send data-driven emails, push notifications, in-app messages, and SMS.

This integration will allow you to get all the available Purchasely events to Customer.io and get a better and deeper understanding of your subscription business and customer behavior.

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 Customer.io.

![](https://1658765766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGgUdOzhqa07uh7nB2iZA%2Fuploads%2FIGbKOcnjyMtg3BD1xWwD%2Fimage.png?alt=media\&token=bfe861aa-ee54-4bbf-8e89-c12b1e89fb27)

Subscription events generated by Purchasely will be sent to Customer.io using a server-to-server integration. As a result, you will be able to see all the subscription events in your Customer.io Dashboard and map them with your acquisition campaigns.

#### Events

The following events are the main ones that can be sent to Customer.io by Purchasely. See the full list [here](https://purchasely.gitbook.io/purchasely/3.4/onesignal#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 Customer.io can be overriden when setting up the integration.

## **Integrating Purchasely with Customer.io**

The integration requires ${integration\_setup\_steps\_count} steps:

1. Associate the user to events by providing the `${integration_sdk_property}` to the Purchasely SDK
2. Activate the Customer.io integration in the Purchasely Console

### 1. Associating users to events

See the [Customer.io Documentation](https://github.com/Purchasely/gitbook/blob/main/integrations/$%7Bintegration_documentation_url%7D/README.md) for more information

***

### 2. Activating the Customer.io integration

The activation requires 3 steps:

1. Retrieving your Customer.io Tracking API Key and Site ID from Customer.io's dashboard
2. Retrieving your Customer.io Reigon from Customer.io's dashboard
3. Enabling the Customer.io integration in the Purchasely Console

#### a. Retrieve your Customer.io Tracking API Key from Customer.io's dashboard

1. Access [the Customer.io API Credentials Management dashboard](https://fly.customer.io/settings/api_credentials)
2. If necessary, create a new Tracking API key for your app
3. Write down your API Key and Site ID

#### b. Retrieve your Customer.io Region from Customer.io's dashboard

1. Follow [the Customer.io documentation](https://customer.io/docs/data-centers/#how-do-i-know-what-region-my-data-is-in)
2. Write down your Region

#### d. Enabling the Customer.io integration in the Purchasely Console

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

![](https://1658765766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGgUdOzhqa07uh7nB2iZA%2Fuploads%2Fgit-blob-a5f9ad5760fd121d92d0cc99348e6a32f91529a6%2FScreenshot%202022-11-06%20at%2019.48.13.png?alt=media)

2\. Enable the integration

3\. Set your Customer.io API Key

4\. Set your Customer.io Site ID

5\. Set your Customer.io Region

![](https://1658765766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGgUdOzhqa07uh7nB2iZA%2Fuploads%2Fgit-blob-ee1e4406bd24cae9ec99b0f86f5891453585e68e%2FScreenshot%202022-11-06%20at%2019.48.53.png?alt=media)

6\. Enable the events you want to be sent to Customer.io

7\. (Optional) Override the names of the events that will be sent to Customer.io

![](https://1658765766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGgUdOzhqa07uh7nB2iZA%2Fuploads%2Fgit-blob-3623ddceec5852fe112e4b80932c5a020b4a7883%2FScreenshot%202022-11-06%20at%2019.49.07.png?alt=media)

8\. Enable the user properties you want to be updated in Customer.io

9\. (Optional) Override the names of the events that will be sent to Customer.io

![](https://1658765766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGgUdOzhqa07uh7nB2iZA%2Fuploads%2Fgit-blob-bbcf4335806a77e113a9c685a9a8484ef94bf0ae%2FScreenshot%202022-11-06%20at%2019.49.28.png?alt=media)

10\. 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 Customer.io dashboard [${integration\_dashboard\_signin\_url}](https://github.com/Purchasely/gitbook/blob/main/integrations/integration_dashboard_signin_url/README.md).

{% hint style="info" %}
Please bear in mind that Customer.io's free plan doesn't offer API access.
{% endhint %}
