登录

Sending Ecommerce events

MyTracker supports key ecommerce events of orders and refunds. By changing the event parameters, you can send all order actions:

  • order placement with payment;
  • order placement without payment;
  • payment for a previously placed order;
  • canceled or partially canceled order;
  • full or partial refund;
  • product replacement in an order.

Use the dataLayer container to transfer events to MyTracker. Send each event to the container as a JavaScript object using the push method. Event parameters and sample scripts are described below.

You can also use S2S API to send events. Including for orders in mobile apps and events that are not tracked on the site, for example, when you change the order status in the order management system.

Data format

MyTracker supports the popular Ecommerce data transfer formats, which correspond to Google Analytics and Yandex Metrics markup.

If you have already configured Google and Yandex events, then you only need to enable Ecommerce event tracking for MyTracker. For details, refer to the topics on event sending in Google Analytics and Yandex Metrics markup.

Events

Event parameters:

Parameter Type Description
event* String Event name:
  • mt_order (order)
  • mt_refund (refund)
MyTracker also supports events in Google Analytics and Yandex Metrics markup:
  • purchase
  • refund
ecommerce* Object Main event container
status String Order action

Possible values for the mt_order event:
  • PAY (payment for product, default value)
  • ADD (product adding)
Possible values for the mt_refund event:
  • REFUND (return of paid product, default value)
  • CANCEL (canceling an unpaid product)
currency_code String Three-letter ISO 4217 currency code. Project currency by default.
order_id* String Unique order number
action_id String Unique action number within the order
coupon String The name or coupon code associated with the order
items* Array Array with the product description

* — required parameters

Products

Product parameters:

Parameter Type Description
item_id* String The ID of the product
item_name* String The name of the product. For example, Xiaomi Redmi Wath 3.
affiliation String The supplying company or store to which the product belongs. For example, Xiaomi store.
price Number The monetary value of the product
discount Number The monetary discount value associated with the product
coupon String The name or coupon code associated with the product
tax Number Tax cost associated with the product. Value from 1 to 100, in percent.
index Integer Product position in the list
item_brand String The brand of the product. For example, Xiaomi.
item_variant String A variation of the product. For example, Green.
item_list_id String The ID of the list in which the product was presented to the user
item_list_name String The name of the list in which the product was presented to the user. For example, New.
item_category1 String One of the categories to which the product belongs. For example, electronics.
item_category2 String One of the categories to which the product belongs. For example, phones and watches.
item_category3 String One of the categories to which the product belongs. For example, a watch.
item_category4 String One of the categories to which the product belongs. For example, a smartwatch.
location_id String The identifier or name of the product location, store, pick-up point, etc.
quantity Integer The number of product units

* — required parameters

Sending orders

To send orders, use the mt_order event. In the status parameter, send the action:

  • ADD to add a product.
  • PAY to pay for a product.

If the status is not sent, the order will be considered fully paid for (the default status is PAY).

Examples of sending different events:

Event Parameters
Order placement with payment event: "mt_order"
status: "PAY"

Send an event when the user has placed and fully paid for an order on the site.
Order placement without payment event: "mt_order"
status: "ADD"

Send an event when the user has placed a pending payment order. For example, the user will pay for the order at the pick-up point or with the courier.
Full or partial payment of the order Payment of the order implies that the mt_order event was sent before it. Possible chain of action: ADD→PAY.

event: "mt_order"
status: "PAY"
order_id: <previously placed order number>
items: <description of paid products>

Send an event when a user has paid for the product.
Adding a product to an order Adding a product implies that the mt_order event was sent before it. Possible chains of action: ADD→ADD, ADD→PAY, PAY→ADD, PAY→PAY.

event: "mt_order"
status: "PAY" if products are paid for
status: "ADD" if products are not paid for
order_id: <previously placed order number>
items: <description of added products>

Send an event when a user has added a product.

Example of a code for sending a fully paid order:

window.dataLayer.push({
  event: "mt_order",
  ecommerce: {
    status: "PAY",
    currency_code: "USD",
    order_id: "000919",
    action_id: "119029",
    coupon: "two-for-one",
    items: [{
      item_id: "00912",
      item_name: "Apple",
      affilation: "Gardens",
      item_list_id: "5",
      item_list_name: "Fruits",
      price: "11.90",
      discount: "2",
      coupon: "two-for-one",
      tax: "20",
      index: "1",
      item_brand: "Honey Crisp",
      item_variant: "Green",
      item_category1: "Foodstuffs",
      item_category2: "Fruits",
      item_category3: "Apples",
      item_category4: "Sweet",
      location_id: "Oregon",
      quantity: "3"
    },
    {
      item_id: "00912",
      item_name: "Pear",
      affilation: "Gardens",
      item_list_id: "5",
      item_list_name: "Fruits",
      price: "11.90",
      discount: "1",
      coupon: "two-for-one",
      tax: "20",
      index: "2",
      item_brand: "Patten",
      item_variant: "Green",
      item_category1: "Foodstuffs",
      item_category2: "Fruits",
      item_category3: "Pears",
      item_category4: "Sweet",
      location_id: "Oregon",
      quantity: "2"
    }]
  }
});

Sending refunds

To send refunds, use the mt_refund event. In the status parameter, send the action:

  • REFUND to return a paid product.
  • CANCEL to delete an unpaid product.

If the status is not sent, it will be assumed that all existing payments on the order have been returned (the default status is REFUND).

Examples of sending different events:

Event Parameters
Full or partial cancellation of an unpaid order Canceling an order implies that the mt_order event was sent before it. Possible chains of action: ADD→CANCEL, PAY→CANCEL.

event: "mt_refund"
status: "CANCEL"
order_id: <previously placed order number>
items: <description of canceled products>

Send an event when a user has canceled or partially canceled an order, or, for example, when an order reserve has expired.
Full or partial cancellation of a paid order Canceling a paid order implies that the mt_order event was sent before it. Possible chains of action: PAY→REFUND, CANCEL→REFUND.

event: "mt_refund"
status: "REFUND"
order_id: <previously paid order number>
items: <description of returned products>

Send the event when the user has completed the return.

Example code for refunding a fully paid order:

window.dataLayer.push({
  event: "mt_refund",
  ecommerce: {
    status: "REFUND",
    currency_code: "USD",
    order_id: "000919",
    action_id: "119030",
    coupon: "two-for-one",
    items: [{
      item_id: "00912",
      item_name: "Apple",
      affilation: "Gardens",
      item_list_id: "5",
      item_list_name: "Fruits",
      price: "11.90",
      discount: "2",
      coupon: "two-for-one",
      tax: "20",
      index: "1",
      item_brand: "Honey Crisp",
      item_variant: "Green",
      item_category1: "Foodstuffs",
      item_category2: "Fruits",
      item_category3: "Apples",
      item_category4: "Sweet",
      location_id: "Oregon",
      quantity: "3"
    },
    {
      item_id: "00912",
      item_name: "Pear",
      affilation: "Gardens",
      item_list_id: "5",
      item_list_name: "Fruits",
      price: "11.90",
      discount: "1",
      coupon: "two-for-one",
      tax: "20",
      index: "2",
      item_brand: "Patten",
      item_variant: "Green",
      item_category1: "Foodstuffs",
      item_category2: "Fruits",
      item_category3: "Pears",
      item_category4: "Sweet",
      location_id: "Oregon",
      quantity: "2"
    }]
  }
});

Recommendation for sending

  • To send multiple order actions, use the same order_id but a different action_id. It is not necessary to use sequential numbering for actions. For example, action_id: "005" for placing an order, action_id: "001" for adding a product, action_id: "038" for payment.
  • When sending different events mt_order and mt_refund, you can repeat the action_id. For example, action_id: "001" for order placement and action_id: "001" for refund.
  • To replace a product, use the mt_refund and mt_order events sequentially

Sending Google Analytics events

If you use Google Analytics Enhanced Ecommerce or Google Analytics Ecommerce (GA4), MyTracker can collect purchase and refund events automatically. You only need to install the MyTracker counter on your site and enable Ecommerce event tracking, no other settings are required.

In Google Analytics markup, each transaction is equated to an order, there are no fields for status transfer. As a result, MyTracker records the purchase event as a fully paid order, and the refund event as a full refund.

To track order status, and send partial additions, payments, and product cancellations, we recommend using MyTracker markup — mt_order and mt_refund events.

Sending Yandex Metrica events

If you use Yandex Metrica, MyTracker can collect purchase events automatically. You only need to install the MyTracker counter on your site and enable Ecommerce event tracking, no other settings are required.

In Yandex Metrica markup, each transaction is equated to an order, there are no refund events and there is no field for status transfer. As a result, MyTracker records the purchase event as a fully paid order.

To send refunds, partial additions, payments, and product cancellations, we recommend using MyTracker markup — mt_order and mt_refund events.

Was this article helpful?
    Sorry, the translation has not been completed yet