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

# Purchasely

> Sync custom audiences to Purchasely to personalize paywalls and subscription offers

## Supported syncing

| Sync type | Description | Supported sync modes | API reference |
| - | - | - | - |
| [**Custom audiences**](#custom-audiences) | Add or remove users from a Purchasely custom audience | Add, Remove | [Sync user custom audiences](https://docs.purchasely.com/docs/custom-audiences-api) |

For more information about sync modes, refer to the [sync modes](https://docs.hightouch.com/syncs/types-and-modes.md#sync-modes) docs.

## Connect to Purchasely

Go to the [Destinations overview](https://app.hightouch.com/destinations?from=docs) page and select **Add destination**. Select **Purchasely** from the destination catalog and select **Continue**. Then enter the following:

* **Application ID**: the ID of the Purchasely application you want to sync audiences to, found in the Purchasely Console.
* **API key**: a Client API key, created in the Purchasely Console under **Settings → Client API Keys**.

Select **Test connection** to verify your credentials.

> [!WARNING]
>
> The Custom Audiences API is a gated Purchasely feature. If the connection test
> fails with a message about the feature not being enabled, contact your
> Purchasely account manager to enable custom audiences for your account.

## Sync configuration

Once you've connected your Purchasely destination and have a [model](https://docs.hightouch.com/getting-started/concepts.md#models) to pull data from, you can set up your sync configuration. Go to the [Syncs overview](https://app.hightouch.com/syncs?from=docs) page and select **Add sync**. Then select the relevant model and your Purchasely destination.

### Custom audiences

You can sync to an existing Purchasely custom audience or have Hightouch create a new one:

* **Use an existing audience**: select from the custom audiences already in your Purchasely application.
* **Create a new audience**: Hightouch creates the audience on the first sync run, deriving its Purchasely audience ID from the name you enter.

#### User identifiers

Purchasely matches audience members by one of two identifier types:

* **User ID**: your own user identifier, as passed to the Purchasely SDK.
* **Anonymous ID**: the anonymous identifier generated by the Purchasely SDK.

Select the identifier type and map the model column that contains it. Each Purchasely audience is fixed to a single identifier type: new audiences are created with the type you select, and for existing audiences you should select the type the audience was created with.

#### Removing users

When rows leave your model's query results, Hightouch can remove those users from the audience or leave the audience unchanged. Choose the behavior you want in the sync configuration.

#### How syncing works

Purchasely applies audience changes asynchronously and processes one change per audience at a time. Hightouch sends membership changes in batches, waits for Purchasely to finish applying each batch, and fails the sync if Purchasely reports that a change couldn't be applied. Large audiences may take several minutes to finish processing on Purchasely's side.

Once synced, you can target the custom audience in Purchasely Placements, Campaigns, and A/B tests to show different screens, offers, and messaging to different groups of users.

## Tips and troubleshooting

To see the exact API requests and responses from each sync run, use the [live debugger](https://docs.hightouch.com/syncs/debugger.md). To get notified by Slack, PagerDuty, SMS, or email when a sync fails, set up [sync alerts](https://docs.hightouch.com/syncs/alerting.md). If you run into an issue this page doesn't cover, [contact support](#pylon-chat).

### Validate your setup

After your first sync completes, confirm the results in Purchasely:

* In the Purchasely Console, check that the custom audience exists and shows the expected user count.
* Rows without a value in the mapped identifier column are rejected rather than synced. Check the sync's rejected rows if counts look low.
