Setting up delivery of detailed data about customers and orders from a CRM
Step 1. Preparing data to be linked to sessions
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. The Yandex Metrica 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 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 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 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
If you can't obtain the ClientId (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.
Step 2. Preparing customer and order data
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 according to the types of statuses 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 doesn't complete any goals.SPAM
: Spam. Similar to canceled orders, doesn't complete any goals.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.
Map the transmitted order statuses to the status types in Yandex.Metrica using the POST /cdp/api/v1/counter/{counterId}/schema/order_statuses 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
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
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
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 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 method.
Step 3. Send customer and order data
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 method.
- In the request body using the POST /cdp/api/v1/counter/{counterId}/data/contacts/json 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 method.
- In the request body using the POST /cdp/api/v1/counter/{counterId}/data/orders/json method.