Checking e-commerce settings

To check whether e-commerce is set up correctly:
  1. Go to the tag settings in Yandex Metrica and make sure that:
    • The E-commerce option is enabled.
    • The field Data container contains the value dataLayer (default) or another value.
  2. Check that the code snippet on your site contains the parameter ecommerce:true or ecommerce:"<data container>" (by default ecommerce:"dataLayer"). In the latter case, the name of the data container must match the one specified in the tag settings.
  3. Append the ym_debug=1 parameter to the page URL in the browser's address bar and reload the page.
    http://example.com/?_ym_debug=1
  4. Open the browser console with the keyboard shortcut Ctrl + Shift + J ( + + J for Apple OS).
  5. Perform an action on the page: for example, add an item to the shopping cart. It must correspond to the event Adding an item to the basket.
  6. If the parameters have ecommerce, and add at the level below, the format corresponds to the example in the Adding an item to the basket event: this means that the order data has been transmitted to Yandex Metrica. After a while, it appears in reports.

Checking the correctness of the transmitted data

The example checks the data that is passed in the event Adding an item to the basket.

  1. Check that the code snippet on your site contains the parameter ecommerce:true or ecommerce:"data container" (by default ecommerce:"dataLayer"). In the latter case, the name of the data container must match the one specified in the tag settings.
  2. Open the browser console with the keyboard shortcut Ctrl + Shift + J ( + + J for Apple OS).
  3. In the console settings, enable the option Preserve log.
  4. Perform an action on the page: for example, add an item to the shopping cart. It must correspond to the event Adding an item to the basket.
  5. In the console, insert the command JSON.stringify(<container name>). By default JSON.stringify(dataLayer).
If in the console:
There is information about the data array.
  1. Copy the array (except for the outer square brackets).
  2. To view the data, use any JSON parser.
  3. Make sure that the data format matches the event Adding an item to the basket.
The error “dataLayer is not defined” was displayed.
This means that the line window.dataLayer = window.dataLayer || []; is not specified in the code of the page where you are checking the event. To set up data transfer, see the section Transmitting data about products and actions.
An empty data array was displayed in the form of [] (square brackets).
This means that the array is declared (in the example dataLayer), but data transmission is not set up for the event being checked.