Google Review Survey Opt-In Integration

  • Posts: 31
  • Thank you received: 3
  • Hikashop Business
2 months 17 hours ago #309873

-- url of the page with the problem -- : www.solarmade.com
-- HikaShop version -- : 4.2.1
-- Joomla version -- : 3.9.4
-- PHP version -- : 7.1.14
-- Browser(s) name and version -- : Chrome 76.0.3809.100
-- Error-message(debug-mod must be tuned on) -- : N/A

Hello,

We are trying to implement the Google Customer Review survey opt-in module by adding the following code to the view checkout / end.php


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

<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
// REQUIRED
"merchant_id": "100618039",
"order_id": "ORDER_ID",
"email": "CUSTOMER_EMAIL",
"delivery_country": "COUNTRY_CODE",
"estimated_delivery_date": "YYYY-MM-DD"

// OPTIONAL
"products":[{"gtin":"GTIN1"}, {"gtin":"GTIN2">}],
"opt_in_style": "CENTER_DIALOG"
});
});
}
</script>
<!-- END GCR Opt-in Module Code -->

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


We are having a bit of trouble determining the correct values to use for the variables marked in bold. This code was pulled directly from Google's Integration guide so everything else should be correct aside from the bold values that we need to replace. Here is the data that Google needs from these variables:

ORDER_ID: A unique ID for the order (order number).
CUSTOMER_EMAIL: The customer's email address, in the format This email address is being protected from spambots. You need JavaScript enabled to view it..
COUNTRY_CODE: The two-letter country code identifies where the customer's order will be delivered. This value must be in ISO 3166-1 alpha-2 format. Do not use “ZZ” for this field. For example, "US".
YYYY-MM-DD: The estimated delivery date for the order, where YYYY is the year, MM is the month, and DD is the day. For example, "2016-09-13". (We may be able to use the order creation date for this field, if an estimated delivery date for orders is unavailable.)

Can you offer a bit of help as to how we should enter these variables to send the correct data to Google?

Please Log in or Create an account to join the conversation.

  • Posts: 67119
  • Thank you received: 9946
  • MODERATOR
1 month 4 weeks ago #309928

Hi,

The order number is available with the code:

<?php echo $this->order->order_number; ?>
The customer email address is available with;
<?php echo $this->order->customer->user_email; ?>
The country code is available with :
<?php echo $this->order->shipping_address->address_country->zone_code_2; ?>
There is no "estimated date of delivery". Now, you could create a custom field of the table "order" and of the type "text" to enter the delivery date and in that case you can use such code:
<?php echo $this->order->XXX; ?>
where XXX is the column name of the custom field.
If you want to use the order creation date, you can use such code:
<?php echo hikashop_getDate($this->order->order_created,'Y-m-d'); ?>

Please Log in or Create an account to join the conversation.

  • Posts: 31
  • Thank you received: 3
  • Hikashop Business
1 month 1 week ago #310560

Hi Nicolas,

Thanks for looking into this. We've been trying to implement the code in our view: checkout/end.php but Chrome DevTools is generating the error: "delivery_country cannot be empty!" when we run through checkout.

Could there be an issue with the variable for the country code, or any ideas what else could be causing this?

Here is the code snippet we are adding to the beginning of the checkout/end.php file.

File Attachment:

File Name: GoogleRevi...9-05.txt
File Size:1 KB


Regards,
Ian C.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 67119
  • Thank you received: 9946
  • MODERATOR
1 month 1 week ago #310572

Hi,

The first thing that comes to mind is that the products in your cart didn't need shipping and thus there is no shipping address registered in the order. In such case, you can use the billing address country instead:

<?php echo $this->order->billing_address->address_country->zone_code_2; ?>
Otherwise, you could try with:
<?php echo $this->order->shipping_address->address_country_code_2; ?>

The following user(s) said Thank You: SolarMade

Please Log in or Create an account to join the conversation.

  • Posts: 31
  • Thank you received: 3
  • Hikashop Business
1 month 1 week ago #310605

Nicolas,

This line seems to have done the trick:

<?php echo $this->order->shipping_address->address_country_code_2; ?>

We are successfully generating the survey opt-in module at the end of checkout now. We'll know for certain if it is working when Google emails me the survey after a few days, I'll keep you updated with the results.

Thanks again for your help!
Ian

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum