Checking e-commerce settings
To check whether e-commerce is set up correctly:
- 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.
- Check that the code snippet on your site contains the parameter
ecommerce:true
orecommerce:"<data container>"
(by defaultecommerce:"dataLayer"
). In the latter case, the name of the data container must match the one specified in the tag settings. - 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
- Open the browser console with the keyboard shortcut Ctrl + Shift + J (⌥ + ⌘ + J for Apple OS).
- 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.
- If the parameters have
ecommerce
, andadd
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.
- Check that the code snippet on your site contains the parameter
ecommerce:true
orecommerce:"data container"
(by defaultecommerce:"dataLayer"
). In the latter case, the name of the data container must match the one specified in the tag settings. - Open the browser console with the keyboard shortcut Ctrl + Shift + J (⌥ + ⌘ + J for Apple OS).
- In the console settings, enable the option Preserve log.
- 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.
- 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.
-
- Copy the array (except for the outer square brackets).
- To view the data, use any JSON parser.
- 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.