Optional: Modify the survey opt-in to gather product reviews

This section includes the following topics:


Integration instructions

We’ll need to collect GTINs (Global Trade Item Numbers) for products included in orders placed on your site. In order to do this, you may need to add a few lines of code to the Google Customer Reviews opt-in module JavaScript snippet on your site. Note that GTINs are required for collecting product ratings through Google Customer Reviews.


Ensure your Google Customer Reviews opt-in snippet has the "products" line

If you’re just beginning your integration, be sure to include the optional field “products” line. If you’ve integrated previously, find the Google Customer Reviews opt-in module snippet in your site’s source code. Below the "// OPTIONAL FIELDS" or “// OPTIONAL” section, ensure your code has the "products" line. If not, you’ll need to add it, as seen below.

<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 FIELDS

         "merchant_id": 117246064,

         "order_id": "ORDER_ID",

         "email": "CUSTOMER_EMAIL",

         "delivery_country": "COUNTRY_CODE",

         "estimated_delivery_date": "YYYY-MM-DD",

 

         // OPTIONAL FIELDS

         "products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}]

       });

   });

 }

</script>

Pass GTINs in the Google Customer Reviews opt-in snippet

// OPTIONAL

"opt_in_style": "OPT_IN_STYLE",

"products": [{"gtin":"GTIN1"}]

The line above specifies the products in a customer’s order as an array of JSON "gtin" objects inside a "products" array. This line has just one "gtin" object, so it will enable Google Customer Reviews to collect a single GTIN for an order, regardless of how many products are part of the order. To collect a GTIN for every product in an order, you’ll need to add code to your site to dynamically add a "gtin" object to the "products" array for every distinct product in the order.

For example, an order that includes 2 distinct products should have a snippet that looks like this:

// OPTIONAL

"opt_in_style": "OPT_IN_STYLE",

"products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}]

And an order that includes 3 distinct products should have a snippet that looks like this:

// OPTIONAL

"opt_in_style": "OPT_IN_STYLE",

"products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}, {"gtin":"GTIN3"}]

Note: Replace "GTIN1", "GTIN2", and "GTIN3" with actual numerical GTIN values.

After you have correctly implemented the new code on your site, we’ll start collecting GTINs from orders placed on your site and gathering product reviews from your shoppers.

Was this helpful?

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