When you are developing ecommerce websites, you may need to integrate Google Customer Reviews code. Google Customer Reviews enable ecommerce businesses to collect feedback from the buyers and then shows these ratings on the search results and search ads.

<script>
window.renderOptIn = function() {
window.gapi.load(‘surveyoptin’, function() {
window.gapi.surveyoptin.render(
{
“merchant_id”: XXXXXXXXX,
“order_id”: “ORDER_ID”,
“email”: “CUSTOMER_EMAIL”,
“delivery_country”: “COUNTRY_CODE”,
“estimated_delivery_date”: “YYYY-MM-DD”
});
});
}
</script>

If you are going to embed Google Customer Reviews code in your BigCommerce website, you may not know which variables to use for the date “YYYY-MM-DD”.

<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”: XXXXXXXXX,
“order_id”: “ORDER_ID”,
“email”: “CUSTOMER_EMAIL”,
“delivery_country”: “COUNTRY_CODE”,
“estimated_delivery_date”: “YYYY-MM-DD”
});
});
}
</script>

If you are going to embed Google Customer Reviews code in your BigCommerce website, you may not know which variables to use for the date “YYYY-MM-DD”.

For the “COUNTRY_CODE”, you will use “US” for United States and “MX” for Mexico (You will have to use ISO 3166-1 alpha-2 format. https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

You can use the below code for getting date:

var d = new Date(%%LNG_DateOfOrder%%);
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
var formated_date = curr_year + “-” + curr_month + “-” + curr_date;

If you want to set the delivery date to be 7 days from the order placement date, you can add that no. of days to the variable curr-date

<script>

function formatDate(date) {

var day = date.getDate();
var monthIndex = date.getMonth();
monthIndex++;
var year = date.getFullYear();

return year + ‘-‘ + monthIndex + ‘-‘ + day;
}

var d = new Date(%%LNG_DateOfOrder%%);
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
var formated_date = curr_year + “-” + curr_month + “-” + curr_date;
var d1 = new Date(formated_date).getTime();
var days = 86400 * 7 * 1000;
d1 = d1 + days;
document.write(d1);
var d2 = new Date(d1);

var DATE_TO_BE_USED = formatDate(d2);

</script>

We are showing your code for 7 days ahead. The JS variable “DATE_TO_BE_USED” in the code is used for 7 days ahead. You can change it to any number of days, by simply changing the multiplier, i.e.7, in this equation 86400 X 7 X 1000.

By / Published On: July 3rd, 2017 /

Subscribe To Receive The Latest News

Curabitur ac leo nunc. Vestibulum et mauris vel ante finibus maximus.

Thank you for your message. It has been sent.
There was an error trying to send your message. Please try again later.

Add notice about your Privacy Policy here.