Google Review Survey Opt-In Integration
7 years 1 month ago #309873
by SolarMade
Google Review Survey Opt-In Integration was created by SolarMade
-- 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 name@domain.com.
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?
-- 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 name@domain.com.
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.
7 years 1 month ago #309928
by nicolas
Replied by nicolas on topic Google Review Survey Opt-In Integration
Hi,
The order number is available with the code:
The customer email address is available with;
The country code is available with :
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:
where XXX is the column name of the custom field.
If you want to use the order creation date, you can use such code:
The order number is available with the code:
Code:
<?php echo $this->order->order_number; ?>
Code:
<?php echo $this->order->customer->user_email; ?>
Code:
<?php echo $this->order->shipping_address->address_country->zone_code_2; ?>
Code:
<?php echo $this->order->XXX; ?>
If you want to use the order creation date, you can use such code:
Code:
<?php echo hikashop_getDate($this->order->order_created,'Y-m-d'); ?>
Please Log in or Create an account to join the conversation.
7 years 3 weeks ago #310560
by SolarMade
Replied by SolarMade on topic Google Review Survey Opt-In Integration
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.
Regards,
Ian C.
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.
This attachment is hidden for guests.
Please log in or register to see it.
Please log in or register to see it.
Regards,
Ian C.
Please Log in or Create an account to join the conversation.
7 years 3 weeks ago #310572
by nicolas
Replied by nicolas on topic Google Review Survey Opt-In Integration
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:
Otherwise, you could try with:
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:
Code:
<?php echo $this->order->billing_address->address_country->zone_code_2; ?>
Code:
<?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.
7 years 3 weeks ago #310605
by SolarMade
Replied by SolarMade on topic Google Review Survey Opt-In Integration
Nicolas,
This line seems to have done the trick:
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
This line seems to have done the trick:
Code:
<?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.203 seconds