Metrica

Online store parameters

Yandex.Metrica lets you make a detailed report on orders completed on the store's website.

To set up a report:

Step 1. Creating the “Order confirmation” goal

  1. In the Yandex.Metrica service, go to the counter editing page.
  2. In the Goals section, create a Page URL or Event type of goal.

When these goals are completed, the parameters should either be passed to the target pages, or passed with the reachGoal function.

Depending on the type of goal, choose one of the ways to edit the counter code.

Step 2. Editing counter code

  1. Set up transmission of session parameters — add the following lines to the counter code:

    ...
    <script type="text/javascript">
    var yaParams = {/*Session parameters*/};
    </script>
    ...

    Also add the parameter for passing order information to the counter code, params:window.yaParams||{ }:

    ...
    (function (d, w, c) {
     (w[c] = w[c] || []).push(function() {
    try { var yaCounterXXXXXX = new Ya.Metrika({id: XXXXXX, params:window.yaParams||{ }}); }
    catch(e) { }
    });
    ...
  2. Install the resulting code on the target page (for example, on the order confirmation page). You can leave the normal counter code on the rest of the pages.

  1. Add the following code to the page that was specified when creating the JavaScript event goal:

    <script type="text/javascript">
    var yaParams = {/*Session parameters here*/};
    </script>
  2. When the goal has been completed, call the following function:

    yaCounterXXXXXX.reachGoal('TARGET_NAME', yaParams);

    where:

    • XXXXXX is your counter number.
    • TARGET_NAME is any code word for identifying your goal (for example, ORDER).
    • yaParams is order parameters.

Step 3. Passing order parameters to the yaParams variable

On goal pages on the site, you must pass order information to the yaParams variable. To set up data transmission, contact your webmaster or other specialist responsible for site administration. Data is formatted according to the JSON standard.

Example of the format for transmitting data:

var yaParams = 
{
  order_id: "12345",
  order_price: 123.45, 
  currency: "RUB",
  exchange_rate: 1,
  goods: 
     [
        {
          id: "1", 
          name: "item name", 
          price: 100,
          quantity: 1
        } 
      ]
};

Name

Type

Required

Default

Description

order_id

string or number

Order ID.

order_price

number

Amount of the order as shown to the user in the currency in currency.

currency

string

Currency of the order (the following values are accepted: RUR, RUB, UAH, BYN, USD, EUR, TRY, KZT, GBR, CNY, MDL, LVL, TMT, CAD, THB, AUD); by default, the national currency that is determined based on the store's region.

exchange_rate

number

1

The exchange rate for currency, if the store uses its own exchange rate.

If a different currency is shown when making the order, in order to convert it to a supported currency, indicate both currency (the currency to convert to) and exchange_rate (the exchange rate).

goods

array

Array of products.

goods.id

string or number

ID of a product in the store.

goods.name

string or number

Name of the product.

We recommend transmitting this parameter to the report. This makes it easier to navigate the list of products. If you pass the name parameter, you don’t need to pass id.

goods.price

number

0

Price of the product in the currency specified in currency.

goods.quantity

integer

1

Quantity of products.

You can use different parameters to share other values. They will be processed in the same way as the parameters in the Visit parameters report. However, for other parameters, you must use a separate variable different from yaParams.