window.bukzaCallbackForBuzaContainer99999 = function(payload){
switch(payload.message.event){
//other handlers
case 'ORDER_COMPLETED':
gtag('event', 'purchase');
break;
}
};
In the example above, BuzaContainer99999 is the id of the div container where the widget is embedded.
If you want to pass order fields with the event (for example, the order total), generate your own event data. To do this, use the mechanism described
here.
The Google Analytics initialization code must already be present on the page containing the widget. Learn more about sending data to Google Analytics
here.
If you are inserting code inside a widget, use the following approach:
<html>
<body>
[Google Analytics 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':
gtag('event', 'purchase');
break;
}
}, false);
</script>
</body>
</html>