Detect if Yes is selected on Google Customer Reviews Popup

285 views Asked by At

I have Google Customer Reviews setup on my store checkout and I am trying to determine if a customer selects yes to opt-in to the reviews. I was hoping for a javascript success call, but don't see anything. Does anyone know how to do this?

Here is the Google code:

<!-- BEGIN GCR Opt-in Module Code -->
<script src="https://apis.google.com/js/platform.js?onload=renderOptIn"
  async defer>
</script>

<script>
  window.renderOptIn = function() { 
    window.gapi.load('surveyoptin', function() {
      window.gapi.surveyoptin.render(
        {
          "merchant_id": 42,
          "order_id": "<?php echo $order_id ?>",
          "email": "<?php echo $email_address ?>",
          "delivery_country": "<?php echo $user_country ?>",
          "estimated_delivery_date": "<?php echo $delivery_date ?>",
          "opt_in_style": "BOTTOM_LEFT_DIALOG"
        }); 
     });
  }
</script>
<!-- END GCR Opt-in Module Code -->

<!-- BEGIN GCR Language Code -->
<script>
  window.___gcfg = {
    lang: 'en_US'
  };
</script>
<!-- END GCR Language Code -->
1

There are 1 answers

0
ronalses aguilar On

maybe you can hear the event when the user clicks on the button.

You should only get the id o idenfifier of the button and then add a few code lines like these.

document.addEventListener('click', (event) => {
  if (!event.target.matches('.google-button')) return 

   /* Put all you code here */
})

Assuming the identifier is the .google-button class.

I hope this can give you an idea. Regards!