---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.1
alternate:
  - https://yandex.ru/dev/metrika/en/data-import/data.md
  - https://yandex.ru/dev/metrika/ru/data-import/data.md
  - href: en/data-import/data.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/metrika/en/llms.txt

# Setting up delivery of detailed data about customers and orders from a CRM

## Step 1. Preparing data to be linked to sessions {#data}

Yandex Metrica matches CRM data to users and their site sessions. To match the data, Yandex Metrica uses customer characteristics (`phones`, `emails`, `phones_md5`, `emails_md5`) and a special [ClientId](https://yandex.ru/support/metrica/general/clientid-userid.html?lang=en). The [Yandex Metrica](https://yandex.ru/support/metrica/general/clientid-userid.html?lang=en) ClientId allows for the most accurate matching of orders to user sessions on the site, so we highly recommend sending it.

**How do I set up ClientID transmission?**

Transmission of the [ClientId](https://yandex.ru/support/metrica/general/clientid-userid.html?lang=en) involves including the unique identifier of the Yandex Metrica user in transaction records within your CRM system. Configure the transmission of this parameter based on the user contact channel:

- **Forms and orders on the site**. Obtain the `ClientId` using the [getClientID](https://yandex.ru/support/metrica/objects/get-client-id.html?lang=en) JavaScript method and include it in the hidden field of your lead forms for subsequent transmission to the CRM.

- **User calls**. If your CRM transactions result from calls, you're likely using a call tracking service. Check if your call tracking system can pass the `ClientId` to transactions in your CRM.

- **User emails**. For email-initiated transactions, use email tracking services that can identify the sender's `ClientId` by substituting the email address on your site. These services can then send information about new emails directly to your CRM as transactions.

- **Messenger chats**. For customers originating from messengers, initiate the [getClientID](https://yandex.ru/support/metrica/objects/get-client-id.html?lang=en) method on the site and include the `ClientId` in the deeplink (Telegram, Viber) or in the message template (WhatsApp). When creating a transaction, specify the ID in a separate field.

- **Site widgets**. Make sure that your site widgets can pass the Yandex Metrica `ClientId` to your CRM when transmitting transactions.

{% note info %}

If you can't obtain the [ClientId](https://yandex.ru/support/metrica/general/clientid-userid.html?lang=en) (for example, if it's an offline purchase) or set up its transmission from your CRM, use the Advanced tracking settings option in the tag settings to more accurately match orders using email or phone number.

{% endnote %}

## Step 2. Preparing customer and order data {#csv}

You need to prepare your CRM data before sending it:

#### 2.1 Map the order statuses from your CRM to the matching order status types in Yandex Metrica

Group all the statuses in your CRM by status types in Yandex Metrica:

- `PAID`: Paid (used by default if you don't transmit order statuses). Transmitting this status completes the goals **CRM: Order created** and **CRM: Order paid**.
- `IN_PROGRESS`: In progress. Transmitting this status completes the goal **CRM: Order created**.
- `CANCELLED`: Canceled. Transmitting this status counts toward the **CRM: Order canceled** metric.
- `SPAM`: Spam. Transmitting this status counts toward the **CRM: Spam order** metric.
- `OTHER`: Orders in a different status. This status type is used automatically when you pass or manually specify a JavaScript goal ID as the order status.

You can use default statuses without mapping: you can transmit the IDs `PAID`, `IN_PROGRESS`, `CANCELLED`, and `SPAM`, or your tag's JavaScript goal IDs as the status.

To map the transmitted order statuses to the status types in Yandex Metrica, use the [POST /cdp/api/v1/counter/{counterId}/schema/order_statuses](https://yandex.ru/dev/metrika/en/management/openapi/schema/mapOrderStatuses.md) method. For example, the **New** status with the `new` ID can be assigned the `IN_PROGRESS` type and the **Successful** status with the `success` ID — the `PAID` status.

[Learn more about mapping order statuses](https://yandex.ru/dev/metrika/en/data-import/maporderstatuses-about.md)

#### 2.2 Prepare your CRM customer data to match the Yandex Metrica customer format.

Customer information includes the customer ID from your CRM (required parameter), customer name, the date and time of contact creation in the tag's time zone, the date and time of the contact's last update, and the IDs for matching the customer to Yandex Metrica sessions, including `client_ids`, email addresses, and phone numbers.

[Learn more about the customer data format](https://yandex.ru/dev/metrika/en/data-import/contacts-data.md)

#### 2.3 Prepare your CRM transaction data to match the Yandex Metrica transaction format.

The required parameters are the order ID from your CRM, the ID of the customer who placed the order (also from your CRM), the customer type, the order creation date in the tag's time zone, and the order status.

In addition, you can transmit the date and time of the order's last update, the date and time of order completion (payment/cancellation), and information about the order's revenue, cost, and the goods or services provided.

[Learn more about the order data format](https://yandex.ru/dev/metrika/en/data-import/orders-data.md)

#### 2.4 (Optional) Transmit additional information about customers, orders, and products as additional attributes

Determine what additional customer and order data you want to transmit. With this information, you can create segments that can be tracked in Yandex Metrica reports or used to target your advertising.

**Customer and order attributes**

For example, you can create an attribute named “shoe size” and generate an audience segment with the specified size. You can then set up retargeting for this audience in Yandex Direct, showing them a special offer.

Examples of additional data: customer type (VIP, individual, or business), service type, and product category. To create additional attributes, use the [POST /cdp/api/v1/counter/{counterId}/schema/attributes](https://yandex.ru/dev/metrika/en/management/openapi/schema/createAttributes.md) method with the following path parameter:

- `entity_type=contact` to pass custom client fields.
- `entity_type=order` to pass custom order fields.

**Product lists**

Upload lists of products or services for your orders. Data from these lists, such as product names, will then become available in Yandex Metrica. Use the [POST /cdp/api/v1/counter/{counterId}/schema/products](https://yandex.ru/dev/metrika/en/management/openapi/schema/createProducts.md) method.

## Step 3. Send customer and order data {#upload}

Pass the customer and order data in CSV format or inside a request in JSON format. There are several ways to transmit data in CSV format:

- As a CSV file. In the file, specify the data that you want to pass to Yandex Metrica.
- As multipart/form-data. Be sure to pass the column names in the first line.

Upload the data from the CRM to Yandex.Metrica:

**About customers**

- In a CSV file using the [POST /cdp/api/v1/counter/{counterId}/data/contacts/csv](https://yandex.ru/dev/metrika/en/management/openapi/schema/uploadContacts.md) method.
- In the request body using the [POST /cdp/api/v1/counter/{counterId}/data/contacts/json](https://yandex.ru/dev/metrika/en/management/openapi/schema/uploadContactJson_1.md) method.

We recommend doing the first upload of customer information as early as possible: order data will be linked to sessions that took place after the first successful upload of customer information.

**About orders**

- In a CSV file using the [POST /cdp/api/v1/counter/{counterId}/data/orders/csv](https://yandex.ru/dev/metrika/en/management/openapi/schema/uploadOrders.md) method.
- In the request body using the [POST /cdp/api/v1/counter/{counterId}/data/orders/json](https://yandex.ru/dev/metrika/en/management/openapi/schema/uploadOrdersJson_1.md) method.
