Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
integration:google_customer_reviews [2018/10/16 02:17] – [Adding Google Customer Reviews to your Foxy store] adamintegration:google_customer_reviews [2021/03/24 19:55] (current) adam
Line 23: Line 23:
 ===== Adding Google Customer Reviews to your Foxy store ===== ===== Adding Google Customer Reviews to your Foxy store =====
  
-First you'll need to enable Customer Reviews for your Google account - [[https://support.google.com/merchants/answer/7188525?hl=en|review their documentation here]] for completing that.+==== Requirements ==== 
 +  * **Customer Reviews enabled on your Google Merchant Account** - [[https://support.google.com/merchants/answer/7188525?hl=en|review their documentation here]] for completing that. 
 +  * **A custom subdomain for your Foxy Store** - The Opt-In Survey will also only display on your approved/validated domains. As such, your Foxy store will need to use a custom subdomain (like ''secure.yourstore.com''), rather than on our standard FoxyCart subdomain (like ''yourstore.foxycart.com''). 
 + 
 +==== Add the integration code to your website ====
  
 Once you have it enabled for your account - you'll then need to add some code to your store. Head to the "configuration" section of your store's Foxy administration, and if it isn't already enabled, enable the "Add custom header and footer code to your templates" option. Within the "footer" textarea, paste the following code: Once you have it enabled for your account - you'll then need to add some code to your store. Head to the "configuration" section of your store's Foxy administration, and if it isn't already enabled, enable the "Add custom header and footer code to your templates" option. Within the "footer" textarea, paste the following code:
Line 55: Line 59:
           "opt_in_style": "CENTER_DIALOG",           "opt_in_style": "CENTER_DIALOG",
           {% if gtin|length > 0 %}           {% if gtin|length > 0 %}
-          "products": [{{ gtin|join(", ") }}]+          "products": [{{ gtin|join(", ")|raw }}]
           {% endif %}           {% endif %}
         });          }); 
Line 67: Line 71:
 In the code above, make sure you update the ''MERCHANT_ID'' text with your own Google Merchant ID, which you can get from the Google Merchant Center. In the code above, make sure you update the ''MERCHANT_ID'' text with your own Google Merchant ID, which you can get from the Google Merchant Center.
  
-You may also need to modify the estimated delivery date value. The code above defaults to setting it to be 1 week after the transaction date. If you need to provide a different estimated delivery date, you will want to edit this portion of the code: ''%%"+7 day"%%''. For example, if you estimate delivery within 5 days, you would make it ''"+5 day"''.+You may also need to modify the estimated delivery date value. The code above defaults to setting it to be 1 week after the transaction date. If you need to provide a different estimated delivery date, you will want to edit this portion of the code: ''%%"+7 day"%%''. For example, if you estimate delivery within 5 days, you would make it ''%%"+5 day"%%''.
  
 ==== Supporting product reviews with GTINs ==== ==== Supporting product reviews with GTINs ====
  
-The survey opt-in also allows for supporting product reviews, which requires that you pass GTIN (Global Trade Item Numbers) for each of your products. The code above does support passing the GTIN, and just require that you set a custom option to each of your product with a name of ''gtin''. For example, in a link like ''&gtin=123456789'' or in a form like ''<input type="hidden" name="gtin" value="123456789">''.+The survey opt-in also allows for supporting product reviews, which requires that you pass GTIN (Global Trade Item Numbers) for each of your products. The code above does support passing the GTIN, and just require that you set a custom option to each of your product with a name of ''gtin''. For example, in a link like ''&gtin=123456789'' or in a form like ''%%<input type="hidden" name="gtin" value="123456789">%%''.
  
 You can [[https://support.google.com/merchants/answer/6219078?hl=en|use this page]] to find GTINs for your products. You can [[https://support.google.com/merchants/answer/6219078?hl=en|use this page]] to find GTINs for your products.
 +
 +==== Using product code instead of a custom product option for gtin ====
 +If you specify the ''gtin'' value as your product ''code'' already, you can use a modified version of the code to use the ''code'' you're passing.
 +
 +Specifically, replace this portion of the code:
 +
 +<code javascript>
 +{% set gtin = [] %}
 +{% for item in items %}
 +  {% for option in item.options %}
 +    {% if option.class == "gtin" %}
 +      {% set gtin = gtin|merge(['{"gtin":"' ~ option.value ~ '"}']) %}
 +    {% endif %}
 +  {% endfor %}
 +{% endfor %}
 +</code>
 +
 +With this version:
 +
 +<code javascript>
 +{% set gtin = [] %}
 +{% for item in items %}
 +  {% set gtin = gtin|merge(['{"gtin":"' ~ item.code ~ '"}']) %}
 +{% endfor %}
 +</code>

Site Tools