arrow_back_iosQuestions
help

How to connect Yandex.Metrica?

check_circle
In the widget event processing code, add the code for sending data to Yandex.Metrica. You will get something like this just after your widget code:
window.bukzaCallbackFor[Widget Container ID] = function(payload){
    switch(payload.message.event){
        //other handlers
        case 'ORDER_COMPLETED':
            yaCounter[ID Counter].reachGoal('ORDER_COMPLETED',
            {
                order_price: payload.message.data.total,
                currency: "RUB"
            });
            break;
    }
};
In this case, the initialization code of the Yandex.Metrica counter should already be added to the page with the widget. More information about sending data to the Yandex.Metrica read here.
If you insert code inside a widget, use something like this:
<html>
<body>
[Yandex.Metrica initialization code]
<script>
window.addEventListener('message', function (e) {
 if (e && e.origin
      && e.origin.indexOf('bukza.com') !== -1)
   var message = JSON.parse(e.data);
   switch (message.event) {
       //other handlers
       case 'ORDER_COMPLETED':
           yaCounter[ID счетчика].reachGoal('ORDER_COMPLETED',
           {
               order_price: message.data.total,
               currency: "USD"
           });
         break;
     }
   }, false);
</script>
</body>
</html>
Didn't find the answer to your question?
Ask it to us on
mail_outline support@bukza.com