Setting up simplified delivery of customer and order data
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. Creating a special-format CSV file
Create a file in the simplified order and customer data format, including the following required information: order date, at least one ID (client_ids
, emails
, phones
, emails_md5
, phones_md5
), and the order ID
from your CRM if you plan to update it in the future.
You can also transmit the customer ID from your CRM, order status (the order status will trigger the completion of relevant goals), order revenue, and order cost.
Learn more about the simplified order and customer data format
Step 3. Uploading data to Yandex Metrica
Pass the data to Yandex Metrica using the POST /cdp/api/v1/counter/{counterId}/data/simple_orders method.
Using the simplified method, you can send order and customer data to Yandex Metrica in a CSV file without additional settings (order status mapping, uploading separate lists of customers and orders, or uploading a product list and additional attributes). To collect statistics, pass the order creation date and time in the tag's time zone (create_date_time
) and one of the customer parameters (ClientID, phone number, email address, a hashed phone number, or a hashed email address). You can transmit orders in different statuses with revenue and cost price data.
The information sent is taken into account in End-to-end analytics reports. In addition, you can use the data for retargeting and optimizing conversions in Yandex Direct.
Learn more about the format of transmitted data
Examples of an uploaded file
- Upload data by ClientID. We recommend using this ID type, because it's more accurate in matching the uploaded data with information about site users in Yandex Metrica.
- Upload data by email addresses.
- Upload data by phone numbers.
- Upload different IDs in a single file.
When sending order data, pass the value that corresponds to the state of the orders being uploaded in the merge_mode
parameter. If you are not sure which status to pass when resending data, specify SAVE
.
Sample request
POST https://api-metrica.yandex.net/cdp/api/v1/counter/2215573/data/simple_orders?merge_mode=SAVE&delimiter_type=COMMA
Content-Disposition: form-data; name="file"; filename="data.csv"
Content-Type: multipart/form-data; boundary=------------------------7zDUQOAIAE9hEWoV
Context-Length: TBD
--------------------------7zDUQOAIAE9hEWoV
Content-Disposition: form-data; name="file"; filename="data.csv"
Content-Type: text/csv
id,create_date_time,client_uniq_id,client_ids,emails,phones,order_status,revenue,cost,goals,currency
s_ord1,10.01.2024 11:56,s_user1,,"mail@example.com,mail2@example.com",,PAID,200,150,”oplata_cash:200,filial_1”,
s_ord2,20.01.2024 11:59,,12345,mail3@example.com,,,200,150,,EUR
,12.02.2024,,34456,,79876543210,SPAM,,,plohoy_lead,
--------------------------7zDUQOAIAE9hEWoV--
Here's an example of how data is sent
Three orders are sent in this example:
Order with the ID s_ord1
- Order date: 10.01.2024 11:56
- Customer ID from the CRM:
s_user1
- Customer emails: mail@example.com, mail2@example.com
- ClientID and phone numbers: Missing
- Order status:
PAID
(completes the goals CRM: Order created and CRM: Order paid) - Revenue: 200
- Cost: 150 (goal revenue is set to 50)
- In addition, the following JavaScript goals are transmitted:
oplata_cash
with revenue set to 200filial_1
with no revenue (the goal revenue from the main order columns is used: 200-150=50)
- Currency: Not specified (all revenue values are in rubles)
Order with the ID s_ord2
- Order date: 20.01.2024 11:59
- Customer ID from the CRM: Not transmitted
- Customer email: mail3@example.com
- ClientID: 12345
- Phone numbers: Missing
- Order status: Not transmitted (transmits
PAID
by default; completes the goals CRM: Order created and CRM: Order paid) - Revenue: 200
- Cost: 150 (goal revenue is set to 50)
- Additional goals: None
- Currency: EUR (all revenue values are in euros)
Order with no ID
- Order date: 12.02.2024 (without specifying the hour and minute — Yandex Metrica searches for past sessions to associate with the order starting from 12.02.2024 23:59)
- Customer ID from the CRM: Not transmitted
- Customer email: mail3@example.com
- ClientID: 34456
- Phone number: 79876543210
- Order status:
SPAM
(doesn't complete any goals) - Revenue and cost: Not specified
- In addition, the following JavaScript goal is transmitted:
bad_lead
: Achieved with no revenue
- Currency: Not specified