---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.5
alternate:
  - https://yandex.com/support/metrica/en/ecommerce/data.md
  - https://yandex.com/support/metrica/es/ecommerce/data.md
  - https://yandex.com/support/metrica/pt/ecommerce/data.md
  - https://yandex.com/support/metrica/ru/ecommerce/data.md
  - https://yandex.com/support/metrica/tr/ecommerce/data.md
  - https://yandex.com/support/metrica/zh/ecommerce/data.md
  - href: en/ecommerce/data.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
title: Transmitting E-commerce data
description: In E-commerce, every product item is an object that certain actions can be performed on, This data is transmitted as JavaScript objects containing the action ID and a list of descriptions of items that this action was performed on.
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/metrica/en/llms.txt


# Transmitting E-commerce data

<!-- source: en/_includes/code/counter-initialize/id-counter-initialize/rest-js.md -->
{% note warning %}

Working with the JavaScript API requires knowledge of HTML and JavaScript. If you don’t know these languages, contact your website developer or webmaster.

{% endnote %}
<!-- endsource: en/_includes/code/counter-initialize/id-counter-initialize/rest-js.md -->


## About the data container and its transmission to Yandex Metrica {#about}

In E-commerce, every product item is an object that certain actions can be performed on, such as viewing the complete item description or adding it to the basket. This data is transmitted as JavaScript objects containing the action ID and a list of descriptions of items that this action was performed on. In the context of the JavaScript API, we call these objects _E-commerce objects_.

To transmit data as E-commerce objects to Yandex Metrica, add them to the special JavaScript array `window.dataLayer` in the global namespace (window) using the [push](http://www.w3schools.com/jsref/jsref_push.asp) method. We call this array the _data container_.


{% note alert %}

Don’t transmit the data when the user is going to another page on the site. An example is when an `onclick` event is used on the “Checkout” button. In this case, the next page might load before the tag sends the data to Yandex Metrica. As a result, information about the event is lost.

{% endnote %}


The data container must be located in the global namespace, and its name must match the name specified during tag configuration or initialization. If the data container is named `dataLayer`, or the Yandex Metrica counter was initiated with the [ecommerce](https://yandex.com/support/metrica/en/code/counter-initialize.md#param-ecommerce) parameter set to `true`, it is assumed that the data container is the `window.dataLayer` array.

```html

...


```

The name of the data container and the structure of the E-commerce objects it contains match the corresponding entities in Google Analytics Enhanced Ecommerce. This means that if you have already set up data sending to Google Analytics Enhanced Ecommerce, including via the [Global Site Tag](https://developers.google.com/gtagjs/?hl=en), and enabled Ecommerce in Yandex Metrica, the latter will start collecting data. Yandex Metrica also supports GA4 Ecommerce and collects data without any additional settings.


{% note alert %}

The data container may contain a maximum of 8,192 characters. 
If you are sending more data in the container, we recommend splitting the order into parts with sub-numbers (e.g., `order1-1`, `order1-2`, `order1-3`). This way, both orders and sub-orders will be displayed in Yandex Metrica.

To assess the actual number of orders, set a JS goal and send it to Yandex Metrica with one of the sub-orders. When sending multiple containers of one order divided into sub-orders, one goal will be achieved, and you will be able to use it to calculate the total number of orders.

{% endnote %}


An ecommerce object has the following format:

```javascript
window.dataLayer.push({
    "ecommerce": {
        "currencyCode": "RUB",
        "<actionType>": {
            "actionField": <actionField>,
            "products": [<productFieldObject>, <productFieldObject>, ...]
        }
    }
});
```


#|
||
**Field**
|
**Type**
|
**Description**
||
||
`ecommerce`[*](*Параметр)
|
Object
|
Required container field
||
||
`currencyCode`
|
String
|
Three-letter [ISO 4217 currency code](https://www.six-group.com/en/products-services/financial-information/data-standards.html#scrollTo=currency-codes).

If a different currency is passed, null values are sent instead of currencies and amounts.
||
||
`<actionType>`[*](*Параметр) {#action_type}
|
—
|
The field name (substituted in place of `<actionType>`) is the identifier of an action performed with a set of products.

Possible values:

- `impressions`: Viewing the product list.
- `click`: Clicking an item in the product list.
- `detail`: Viewing an item.
- `add`: Adding the item to the shopping cart.
- `remove`: Removing an item from the shopping cart.
- `purchase`: Purchasing.
- `promoView`: Viewing an internal ad.
- `promoClick`: Clicking an internal ad.

If information about removing the item was transmitted to Yandex Metrica, the report might show a negative number of items (the total is calculated by subtracting the number of deleted items from the total number of added items). If the price of the item was transmitted, it might also have a negative value in the report.
||
||
`actionField`[**](*Обязательный_параметр)
|
Object
|
An [actionField](#action_data) object. Additional data describing the action performed.

Only processed if the action is a [purchase](#purchase) (`<actionType>` — `purchase`).
||
||
`products`[*](*Параметр)
|
Array
|
List of descriptions of items that the specified action was performed on. Product descriptions are [productFieldObject](#product_data) objects.

Not used for the `promoClick`, `promoView`, and `impressions` actions.
||
||
`promotions`[*](*Параметр)
|
Array
|
List of descriptions for the ad campaign that the specified action was performed on. Ad campaign descriptions are [promoFieldObject](#promo_data) objects.
||
|#

<sup >*</sup> Required parameter.

<sup >**</sup> Required parameter for sending the purchase information.

### Item data {#product_data}

An object describing a particular item.

The structure of the object describing the item is denoted as **productFieldObject**.


#|

### Поля объекта {#product_data}

||
**Field**
|
**Type**
|
**Description**
||
||
`id`[*](*Указать)
|
String
|
Item ID. For example, the SKU.

**It is necessary to specify either id or name**
||
||
`name`[*](*Указать)
|
String
|
Item name. For example, "T-shirt"

**You must specify either "name" or "id"**
||
||
`brand`
|
String
|
The brand or trademark associated with the item. For example, "Yandex"
||
||
`category`
|
String
|
The category the item belongs to.

The hierarchy of categories supports up to 4 levels. Use the / symbol to separate levels. For example, "Clothing / Men's clothing / T-shirts"
||
||
`coupon`
|
String
|
A promo code associated with the item. For example, "PARTNER_SITE_15"
||
||
`discount`
|
Number
|
Discount amount (a numeric value).
||
||
`list`
|
String
|
List that the item belongs to.

To evaluate the effectiveness of a list at different stages of user interaction with the product, we recommend specifying the product list in all events that occurred after the list was viewed.
||
||
`position`
|
Integer
|
Item position in the list. For example, 2
||
||
`price`
|
Number
|
Item price.
||
||
`quantity`
|
Integer
|
Item quantity.
||
||
`variant`
|
String
|
A variation of the item. For example, “Red”
||
|#

### Action data {#action_data}

An object containing data about an action performed with an item or set of products.

Only processed if the action is a purchase (`<actionType>` — `purchase`).

The structure of the object describing the action is denoted as **actionField**.

When transmitting data about an action, Yandex Metrica creates a goal. This allows you to get information about revenue from Yandex Direct campaigns. In the list of available goals in Yandex Direct, this goal is shown as "eCommerce: Purchase (tag № <tag number>)". You can track goal completion yourself by transmitting the [goal_id](#goal_id) field.


#|

### Поля объекта {#action_data}

||
**Field**
|
**Type**
|
**Description**
||
||
`id`[*](*Поле)
|
String
|
ID of the product purchased.

Required information.

Example: TRX#54321
||
||
`coupon`
|
String
|
A promo code associated with the entire purchase
||
||
`goal_id` {#goal_id}
|
Integer
|
The [goal](https://yandex.com/support/metrica/en/general/goals.md) number. Specified if this [action](#action_type) was the goal. 
The goal must be set as a [JavaScript event](https://yandex.com/support/metrica/en/general/goals.md) type.

You can view a goal number in the Yandex Metrica interface: go to the **Settings** section and open the **Goals** tab.
![](../_assets/order-ecommerce.png){.border-yes}
||
||
`revenue`
|
Number
|
The revenue received.

If omitted, it is calculated automatically as the sum of the prices of all the items associated with the purchase
||
|#

### Promo campaign data {#promo_data}

An object describing promo campaigns.

This object uses a similar container but with **promoFieldObject** instead of **productFieldObject**.


#|

### Поля объекта {#promo_data}

||
**Field**
|
**Type**
|
**Description**
||
||
`id`[*](*Поле)
|
String
|
ID of the promo campaign.

**Required information**
||
||
`name`
|
String
|
Promo campaign name
||
||
`creative`
|
String
|
Ad banner name
||
||
`creative_slot`
|
String
|
Ad banner slot
||
||
`position`
|
String
|
Ad banner position
||
|#


## Examples {#examples}

To transmit information, you need to create a script on the site that will be responsible for a certain event (for example, making an order) in the format described above. Below are examples of scripts for actions supported by Yandex Metrica.

All the examples assume that the [tag was initialized with E-commerce enabled](https://yandex.com/support/metrica/en/data/e-commerce.md), and data is transferred via the [window.dataLayer container](#about).

### Viewing a product list {#product-list}

The data must be sent the moment the product list is opened.

```javascript
dataLayer.push({
    "ecommerce": {
        "currencyCode": "RUB",
        "impressions": [
            {
                "id": "P15432",
                "name": "T-shirt",
                "price": 477.60,
                "brand": "Yandex",
                "category": "Clothing / Men's clothing / T-shirts",
                "variant": "Red",
                "list": "Search",
                "position": 1
            },
            {
                "id": "P15435",
                "name": "T-shirt",
                "price": 500.60,
                "brand": "Yandex",
                "category": "Clothing / Men's clothing / T-shirts",
                "variant": "Blue",
                "list": "Search",
                "position": 2
            }
        ]
    }
});
```

### Clicking a product list item {#click-on-product}

The data must be sent the moment the user clicks the product link.

```javascript
dataLayer.push({
    "ecommerce": {
        "currencyCode": "RUB",
        "click": {
            "products": [
                {
                    "id": "39084",
                    "name": "Yandex Tumbler",
                    "price": 1089.69,
                    "brand": "Yandex",
                    "category": "Housewares / Tableware / Insulated bottles and thermal mugs",
                    "variant": "Red",
                    "list": "Search",
                    "position": 1
                }
            ]
        }
    }
});
```

### Viewing a product {#product-detail}

The data must be sent the moment the page opens with the product card.

```javascript
dataLayer.push({
    "ecommerce": {
        "currencyCode": "RUB",
        "detail": {
            "products": [
                {
                    "id": "P15432",
                    "name": "T-shirt",
                    "price": 477.60,
                    "brand": "Yandex",
                    "category": "Clothing / Men's clothing / T-shirts",
                    "variant": "Red",
                    "list": "Search results",
                    "position": 1
                }
            ]
        }
    }
});
```

### Adding an item to the basket {#add}

The data must be sent at the moment when the order is added to the basket. For example, upon clicking "Add to basket".

```javascript
dataLayer.push({
    "ecommerce": {
        "currencyCode": "RUB",
        "add": {
            "products": [
                {
                    "id": "43521",
                    "name": "Yandex bag",
                    "price": 654.32,
                    "brand": "Yandex",
                    "category": "Accessories / Bags",
                    "quantity": 1,
                    "list": "Category search results",
                    "position": 2
                }
            ]
        }
    }
});
```

### Removing an item from the basket {#remove}

The data must be sent at the moment when the item is removed from the basket.

```javascript
dataLayer.push({
    "ecommerce": {
        "currencyCode": "RUB",
        "remove": {
            "products": [
                {
                    "id": "15243",
                    "name": "Yandex screen wipes for smartphones",
                    "category": "Smartphone accessories",
                    "quantity": 1,
                    "list": "Accessories",
                    "position": 3
                }
            ]
        }
    }
});
```

### Purchase {#purchase}

The data must be sent the moment the order is confirmed.

```javascript
dataLayer.push({
    "ecommerce": {
        "currencyCode": "RUB",
        "purchase": {
            "actionField": {
                "id": "TRX987"
            },
            "products": [
                {
                    "id": "25341",
                    "name": "Yandex men's sweatshirt",
                    "price": 1345.26,
                    "brand": "Yandex",
                    "category": "Clothing / Men's clothing / Hoodies and sweatshirts",
                    "variant": "Orange",
                    "quantity": 1,
                    "list": "Clothing",
                    "position": 1
                },
                {
                    "id": "25314",
                    "name": "Yandex women's sweatshirt",
                    "price": 1543.62,
                    "brand": "Yandex",
                    "category": "Clothing / Women's clothing / Hoodies and sweatshirts",
                    "variant": "White",
                    "quantity": 3,
                    "list": "Sweatshirts",
                    "position": 2
                }
            ]
        }
    }
});
```

### Viewing an internal ad {#adv-view}

The data must be sent the moment the user views the ad.

```javascript
dataLayer.push({
    "ecommerce": {
        "promoView": {
            "promotions": [
                {
                    "id": "BF001",
                    "name": "Black Friday",
                    "creative": "Banner_1",
                    "position": "Slot1"
                },
                {
                    "id": "SUMMER002",
                    "name": "Summer sales",
                    "creative": "Banner_3",
                    "position": "Slot2"
                }
            ]
        }
    }
});
```

### Clicking an internal ad {#adv-click}

The data must be sent the moment the user clicks the ad or completes another target action related to the ad.

```javascript
dataLayer.push({
    "ecommerce": {
        "promoClick": {
            "promotions": [
                {
                    "id": "BF001",
                    "name": "Black Friday",
                    "creative": "Banner_1",
                    "position": "Slot1"
                }
            ]
        }
    }
});
```

### Learn more

- [Checking e-commerce settings](https://yandex.com/support/metrica/en/ecommerce/check.md)
- [Troubleshooting](https://yandex.com/support/metrica/en/ecommerce/troubleshooting.md)


<!-- source: en/_includes/buttons/chat-button.md -->
[Chat with us](https://yandex.com/chat/#/user/036e6a02-3620-9cdc-4c5e-a34667a7379e?utm_source=spravka){.button}

<!-- source: en/_includes/styles/href-to-button.md -->

<!-- endsource: en/_includes/styles/href-to-button.md -->
<!-- endsource: en/_includes/buttons/chat-button.md -->

<!-- source: en/_includes/reports/support-button.md -->
<div class="cut-button">

{% cut "Write an email" %}

<!-- source: en/_includes/popup/id-popup/wrong-sup.md -->
Please note: Our support team will never initiate a call to you. Do not follow any instructions of people who call you and introduce themselves as the Yandex Metrica support team.
<!-- endsource: en/_includes/popup/id-popup/wrong-sup.md -->

<div style="padding: 15px;
     margin: 10px 0;
     background: #FFFFFF;
     border-radius: 10px;
     border: 1px solid var(--g-color-line-generic);">
  <iframe style="background: #FFFFFF;"
        height="700"
        width="100%"
        frameborder="0"
        src="https://forms.yandex.com/surveys/1705/?&iframe=1&lang=en">
  </iframe>
</div>

{% endcut %}

</div>



<!-- source: en/_includes/styles/cut-button.md -->

<!-- endsource: en/_includes/styles/cut-button.md -->

<!-- source: en/_includes/styles/href-to-button.md -->

<!-- endsource: en/_includes/styles/href-to-button.md -->
<!-- endsource: en/_includes/reports/support-button.md -->

<!-- source: en/_includes/footer-links.md -->
- - -

<div class="borderless-table">

#|
||
Useful links

- [Demo tag](https://metrica.yandex.com/r/dashboard?)
- [Add a tag](https://metrica.yandex.com/add/)
- [Free tag setup](https://yandex.com/promo/freeservice/metrica?utm_source=help_metrica_en&utm_medium=cpc&utm_campaign=1)
- [Yandex Metrica API](https://tech.yandex.com/metrika/)
- [Suggest your idea](https://yandex.com/support/metrica/troubleshooting/idea.html)
- [Discuss in Telegram](https://t.me/yandexmetrika)
|
Online training

- [Get a Yandex Metrica certificate](https://yandex.ru/adv/expert/exam/metrika/?utm_source=metrika_help&utm_medium=web&utm_campaign=static&utm_content=useful_links)


- [Take a training course](https://yandex.com/adv/edu/online/metrika?utm_source=metrika_help&utm_medium=web&utm_campaign=static&utm_content=useful_links)

||
|#

</div>

<!-- source: en/_includes/styles/table-style.md -->

<!-- endsource: en/_includes/styles/table-style.md -->
<!-- endsource: en/_includes/footer-links.md -->

[*Параметр]: Required parameter.

[*Обязательный_параметр]: Required parameter for transmitting purchase information.

[*Указать]: **You must specify either "name" or "id"**.

[*Поле]: Required information.