D
D
danforth2017-07-11 19:02:51
JavaScript
danforth, 2017-07-11 19:02:51

How to send e-commerce to Yandex.Metrica?

Hello!
There is a site where, when you click the "Buy" button, you need to send information about the purchase to the metric. In this case, the "Buy" button leads to another site (payment system). Yes, I know that you need to know the answer to the payment, and then send the data if the client has paid, but the problem is that after the payment, the client is redirected to the partner’s website, i.e. Whether he paid or not, I will not know in any way - he simply will not return to the page to me. Therefore, we will omit errors in logic.
I did this, but I'm not sure that the data flies into the metric at all:

$("#buttonbuy").on("click", function(e){
    window.datalayer.push({
      "ecommerce": {
        "currencyCode": "RUB",
        "purchase": {
          "products": [
            {
              "id": product.id,
              "name": product.name,
              "price": product.price,
              "quantity": 1,
              "category": product.category,
            }
          ]
        }
      }
    });
  });

I had a question: if you push information into the datalayer, does it immediately fly there, or does it need to be sent manually somehow through some method? And if the information is sent at push, then does it have time to go before the transition to another page?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2017-07-11
@dimonchik2013

what's stopping you from tracing?
F12 Chrome, Fiddler

R
Roman Alexandrovich, 2017-07-11
@RomReed

I think you need to open the debugger with f12 and look in the Network slot. There you should see your data fly away and at what point. And I would just make a test purchase and look at the metrics.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question