Legacy ecommerce code will become obsolete soon – time to make changes to your scripts

2 March, 14:31

Soon, support for the legacy method of transferring ecommerce data that uses preset session parameters will be discontinued. If you still use this method and need to receive ecommerce statistics for your reports, you will need to make changes to your scripts for transferring ecommerce data by March 27.

Please note that on March 13 and 20 there will be a preliminary disabling of the legacy method of transferring data. On these days, the legacy code will not transfer data to reports, while it will stop working completely from March 27 on.

In this post we’ll try to answer all possible questions about switching to the new script for transferring ecommerce data. If anything is still unclear, please leave a comment or contact support.

What are the benefits of updating my scripts?

It will allow you to get more useful information in reports about products such as their categories, brands and specific modifications. In addition, you can track not only products added to a cart, but also product page views. This will help you better understand how customers interact with product offers. The updated scripts will even let you record the usage of promocodes. A detailed list of the data that you can transfer in reports for the updated ecommerce code can be found in the relevant Help section.

The old scripts suit me fine – why do I need to change them?

For the moment we still support both methods of transferring ecommerce data, but going forward we will be unable to allocate resources to both keep supporting this and the development of new features in Yandex.Metrica.

How do I know which version of code for transferring ecommerce data is in use in my tags?

The easiest method is to go to your ecommerce reports and check to see if there is a notification about using an outdated method of transferring ecommerce data. However, if you are only working with a site’s code, have no access to the Yandex.Metrica interface and cannot see these reports, then you can compare your site’s current code for transferring ecommerce data with the example of updated code below.

How do I switch from legacy code to the updated version?

1. In your tag settings, check the box marked “Dispatch ecommerce data to Metrica”.

2. Add the following code to all pages of your site:

<script type="text/javascript">
  window.dataLayer = window.dataLayer || [];

3. Choose one or several events whose data that you want to transfer in reports.

4. Now, create code that will fill in all fields for the selected ecommerce event, and add it to your site. To illustrate this, let’s compare an example of the legacy code with the updated code for transferring an “order created” event. This is how this event might be transferred using the legacy code:

var yaParams = {
  order_id: "12345",
  order_price: 123.45,
  currency: "RUB",
  exchange_rate: 1,
  goods: [
      id: "25341",
      name: "Yandex hoodie male",
      price: 1345.26

While the purchase used to look like this:

yaCounterXXXXXX.reachGoal('TARGET_NAME', yaParams);

Now, with the updated code, the order creation and order purchase would look like this:

  "ecommerce": {
    "purchase": {
      "actionField": {
        "id": "12345",
        "revenue": 123.45
      "products": [
          "id": "25341",
          "name": "Yandex hoodie male",
          "price": 1345.26

5. Update the code snippet on all pages of your site.

If you are not sure how to correctly configure a script for sending ecommerce data, we recommend you talk to your webmaster or site developer.

We will also notify users separately who have still not updated their code two weeks before March 27. A special notification will appear in the ecommerce reports interface, while a reminder will be sent to the email address associated with your Yandex account.