window.bukzaCallbackForBuzaContainer99999 = function(payload){
switch(payload.message.event){
//other handlers
case 'ORDER_COMPLETED':
ym(777777, 'reachGoal', 'booked',
{
order_price: payload.message.data.total,
currency: "RUB"
});
break;
}
};
In the example above:
-
uzaContainer99999 — the id value of the div container where the widget is inserted.
-
777777 — the Yandex.Metrica tag ID.
-
booked — the Goal ID. The ID is set on the tag editing page when creating or changing a "JavaScript event" goal.
In this case, the initialization code of the Yandex.Metrica 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':
ym(777777,'reachGoal', 'booked',
{
order_price: message.data.total,
currency: "USD"
});
break;
}
}, false);
</script>
</body>
</html>