> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rxscale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Customer.io Integration

> Send prescription and pharmacy order events from a shop to your Customer.io workspace

# Customer.io Integration

RxScale can send events about your patients' prescriptions and pharmacy orders to your own [Customer.io](https://customer.io) workspace. Use them to trigger campaigns and transactional messages, for example "Your prescription has been signed" or "Your order is on its way".

The integration is configured **per shop**. Each shop can send to its own Customer.io workspace, and shops without an integration send nothing.

## What you need

* A Customer.io workspace and its **Site ID** and **Tracking API key**. In Customer.io, open **Workspace Settings → API and Webhook Credentials → Tracking API Keys**.
* The region your Customer.io account is hosted in: **EU** (`track-eu.customer.io`) or **US** (`track.customer.io`).
* A workspace that **identifies people by email**. RxScale identifies each patient by the email address of their order. In Customer.io, check **Workspace Settings → Workspace → Identifiers** and allow identification by email ("Email or ID").

> [!WARNING]
>
> If the credentials or the region are wrong, Customer.io rejects the request and the event is not sent. Events are not stored for a later retry, so check the integration with a test order after setting it up.

## Setup in the Admin Tool

1. Open **Settings → Shops**.
2. In the row of the shop, click the **Marketing Integration** action (megaphone icon).
3. Choose the **Region**, then enter the **Site ID** and the **Tracking API key**.
4. Keep **Send events to Customer.io** enabled and save.

The API key is stored encrypted and is never shown again. To change the region or Site ID, open the dialog again and leave the API key field empty to keep the stored key. Enter a new key only to replace it.

To pause the integration, uncheck **Send events to Customer.io**: the credentials stay stored, but no events are sent. To delete the credentials, use **Remove Customer.io** in the shop's action menu.

## How events are sent

For every event, RxScale makes two calls to the Customer.io Track API with your Site ID and API key:

1. It **identifies** the patient by email, so the person exists in your workspace even if Customer.io has not seen them before.
2. It **tracks the event** on that person.

Events are sent only if the order belongs to the shop with an active integration and has a valid patient email address.

If Customer.io is temporarily unavailable, RxScale retries the delivery automatically.

## Events

Events contain identifiers and status information only. They contain no addresses, products, or medical information.

### `prescription_signed`

Sent when a doctor signs a prescription for an order of the shop.

```json theme={null}
{
  "name": "prescription_signed",
  "data": {
    "prescription_uid": "8b1f6c1e-2d4a-4c55-9a0e-3f7d2b9c4e11",
    "order_uid": "c3a9e5d2-7b8f-4e61-a2c4-91d0f6b3e7a8",
    "shop_order_name": "#1001",
    "status": "signed",
    "prescription_type": "digital"
  }
}
```

### `prescription_printed_for_patient`

Sent when a digital prescription has been issued to the pharmacy. Physical (paper) prescriptions do not trigger this event.

```json theme={null}
{
  "name": "prescription_printed_for_patient",
  "data": {
    "prescription_uid": "8b1f6c1e-2d4a-4c55-9a0e-3f7d2b9c4e11",
    "order_uid": "c3a9e5d2-7b8f-4e61-a2c4-91d0f6b3e7a8",
    "shop_order_name": "#1001",
    "pharmacy_name": "Apotheke am Markt"
  }
}
```

### `pharmacy_order_updated`

Sent every time the status of a pharmacy order changes, for example when the pharmacy starts processing or ships the order.

```json theme={null}
{
  "name": "pharmacy_order_updated",
  "data": {
    "pharmacy_order_uid": "5e2d8a7c-1f4b-4b93-8c6e-0a9d3f2b7c15",
    "order_uid": "c3a9e5d2-7b8f-4e61-a2c4-91d0f6b3e7a8",
    "shop_order_name": "#1001",
    "status": "in_progress",
    "pharmacy_name": "Apotheke am Markt"
  }
}
```

### Fields

| Field | Type | Description |
| - | - | - |
| `prescription_uid` | string | RxScale ID of the prescription |
| `pharmacy_order_uid` | string | RxScale ID of the pharmacy order |
| `order_uid` | string | RxScale ID of the order |
| `shop_order_name` | string or `null` | Your shop's own order name, for example the Shopify order number `#1001` |
| `status` | string | `signed` for `prescription_signed`; the pharmacy order status for `pharmacy_order_updated` |
| `prescription_type` | string or `null` | `digital` or `physical` |
| `pharmacy_name` | string or `null` | Display name of the pharmacy; `null` when no pharmacy is known |

## Using the events in Customer.io

In Customer.io, create a campaign with the trigger **"Person performs event"** and enter the event name, for example `pharmacy_order_updated`. Use `event.status` or `event.shop_order_name` in filters and message templates.

> [!NOTE]
>
> Klaviyo is configured separately. If your organisation already sends events to Klaviyo, those events are unchanged.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.