Notification

This help center shows articles applicable to Merchant Center Next. Learn more about the upgrade and get answers to frequently asked questions.

Integrate the survey opt-in module

The survey opt-in module lets customers choose whether to participate in Google Customer Reviews and also transmits the necessary transaction information to Google. This module is required on all order confirmation pages to participate in Google Customer Reviews. If you’re having issues integrating the survey opt-in module, try troubleshooting.

This article includes the following topics:

If a user opts in, Google sends them a survey after the estimated delivery date of their order. For more information, read the Google Customer Reviews survey.

The survey opt-in works on desktop and mobile. Be sure to add the opt-in code snippet to both your desktop and mobile sites.


Integration instructions

To include the survey opt-in module on the order confirmation page, you must:

  1. Update the DOCTYPE
  2. Add the opt-in code

The survey opt-in module's code should be placed on the order confirmation page of your checkout flows. All confirmation pages must use HTTPS, not HTTP.

Because this module triggers the Google Customer Reviews survey opt-in, the order details in this module must be accurate to the best of your ability.

If your check-out process uses a third-party processor, it must redirect back to the confirmation page on your domain.

Don't obscure the GCR customer survey opt-in module with any other content on your order confirmation page.

Update the DOCTYPE

Be sure that the confirmation page uses the HTML5 DOCTYPE:

<!DOCTYPE html>

This doctype must be the first line item in the HTML code on your page. Using the HTML5 DOCTYPE ensures that web browsers will render your pages in standard mode instead of quirks mode. Quirks mode refers to a technique used by some web browsers to maintain backward compatibility with web pages designed for older browsers, instead of strictly complying with W3C and IETF standards in standards mode.

Note: Don't include comments or whitespace before the DOCTYPE.

Add the opt-in code

To give your customers the option of submitting a review of their experience buying from you, add the opt-in module to your order confirmation page.

To add the survey opt-in module to your order confirmation page:

  1. Paste the following HTML snippet into your order confirmation page:

<!-- 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(

{

// REQUIRED

"merchant_id": "MERCHANT_ID",

"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": "OPT_IN_STYLE"

});

});

}

</script>

<!-- END GCR Opt-in Module Code →

Place the code just before the closing </BODY> tag. When you place the survey module code with the badge code, the order doesn't matter. The survey module code can be placed before or after the badge code.

  1. Replace the variables with your site-specific, dynamic values. The following table describes the available settings:
Variable Required? Description

MERCHANT_ID

(Merchant ID)

Required Your Merchant Center ID. You can find this ID in the top right of your Merchant Center account.

ORDER_ID

(Order ID)

Required A unique ID for the order.

CUSTOMER_EMAIL

(Customer email)

Required The customer's email address, in the format name@domain.com.

COUNTRY_CODE

(Country code)

Required The 2-letter country code identifies where the customer's order will be delivered. This value must be in ISO 3166-1 alpha-2 format. Don't use “ZZ” for this field. For example, "US".

ESTIMATED_DELIVERY_DATE

(Estimated delivery date)

Required 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".

GTIN1, GTIN2

(GTIN)

Optional Numerical GTIN values.

OPT_IN_STYLE

(Opt-in style)

Optional

Specifies how the opt-in module's dialog box is displayed. Possible values are:

"CENTER_DIALOG": Displayed as a dialog box in the center of the view.

"BOTTOM_RIGHT_DIALOG": Displayed as a dialog box at the bottom right of the view.

"BOTTOM_LEFT_DIALOG": Displayed as a dialog box at the bottom left of the view.

"TOP_RIGHT_DIALOG": Displayed as a dialog box at the top right of the view.

"TOP_LEFT_DIALOG": Displayed as a dialog box at the top left of the view.

"BOTTOM_TRAY": Displayed at the bottom of the view.

The default value is "CENTER_DIALOG".

Optionally, specify the language that the opt-in module should use by pasting the following code snippet into your web page. If you don’t specify a value for the lang parameter, the badge uses the user's browser setting to automatically choose the language.

<!-- BEGIN GCR Language Code -->

<script>

window.___gcfg = {

lang: 'LANGUAGE'

};

</script>

<!-- END GCR Language Code →

Place the code just before the closing </BODY> tag on the page. When placed with the opt-in code, the order doesn't matter.

Set the value of the lang parameter by replacing LANGUAGE with one of the following supported languages:

Code Language name
af Afrikaans
ar Arabic
cs Czech
da Danish
de German
en English
en-AU English-Australia
en-GB English (UK)
en-US English (US)
es Spanish
es-419 Spanish (Latin America)
fil Filipino
fr French
ga Irish
id Indonesian
it Italian
ja Japanese
ms Malay
ml Dutch
no Norwegian
pl Polish
pt-BR Portuguese (Brazil)
pt-PT Portuguese
ru Russian
sv Swedish
tr Turkish
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)

Example survey opt-in code

The variable values are typically replaced on your order confirmation page with server-side code. The following example shows how you might implement the opt-in module code with PHP:

<!-- 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 ?>",

"products": [{"gtin":"<?php echo $gtin_1 ?>"}, {"gtin":"<?php echo $gtin_2 ?>"}],

"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 →

If the opt-in module doesn't appear on your page or you get errors when loading the page, try troubleshooting.

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Main menu
13113122477309925116
true
Search Help Center
true
true
true
true
true
71525
false
false