arrow_back_iosQuestions
help

How to connect Google Analytics?

check_circle
In the widget event processing code, add the code for sending data to Google Analytics. 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':
            gtag('event', 'purchase',
            {
                "value": payload.message.data.total
            });
            break;
    }
};
The Google Analytics initialization code must already be added to the page with the widget. Learn more about sending data to Google Analytics here.
If you insert code inside a widget, use something like this:
<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',
            {
                "value": message.data.total
            });
         break;
     }
   }, false);
</script>
</body>
</html>
Didn't find the answer to your question?
Ask it to us on
mail_outline support@bukza.com