Google Customer Reviews

Hello,

We're just reviewing integrating Google product reviews with our website and wondered whether any FoxyCart users had already succesfully completed the integration, aka: https://support.google.com/merchants/answer/7106244

Many thanks
Comments
  • fc_marijafc_marija FoxyCart Team
    hi @BLJ -

    We've recently had a user working on this integration, but I'm not sure if they've implemented it. If you want to try it out, we can give you some direction based upon that discussion with them.

    You'll want to paste the JS code into your configuration custom footer as shown below. I've included a few notes within the code for clarification, and inserted the values you'll need from the cart.

    {% if first_receipt_display %}

    <!-- 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", //You'll need to get from your Google Merchant Centre account
    "order_id": {{ transaction_id }},
    "email": {{ customer_email }},
    "delivery_country": {{ shipping_address.country }},
    "estimated_delivery_date": "YYYY-MM-DD", //see below

    // OPTIONAL
    "opt_in_style": "OPT_IN_STYLE"
    });
    });
    }
    </script>
    <!-- END GCR Opt-in Module Code -->

    <!-- BEGIN GCR Language Code -->
    <script>
    window.___gcfg = {
    lang: 'en_GB' //your default language here
    };
    </script>
    <!-- END GCR Language Code -->

    {% endif %}


    Currently FoxyCart doesn't have an estimated delivery date value for the transaction - we don't track that information yet. One approach you could take is to alter the date of the checkout ahead an average delivery time. Depending on your set up - you could potentially get more complex and have a specific estimated length of time based on the state too.

    As an example of how you would modify the transaction date:

    {{ checkout_date|date_modify("+7 day")|date("Y-m-d") }}

    That Twig code would output a date in the YYYY-MM-DD format, but 7 days ahead of the date that the checkout occurred on. So if the checkout happened on the 11th of October, that date would be 2017-10-18.

    Hope that gets you started if you decide to use it.
  • PhilippePhilippe Member
    edited September 11
    I will try this tomorrow - I have a question though, regarding the language - our cart functions in multiple language so what is the {{ code for language goes here }} parameter I need to use to replace the hardcoded language in the snippet you offered above ?

    window.___gcfg = {
    lang: 'en_GB' //your default language here
    };


    We use english, French, Spanish and Italian, and google expects those language codes to be provided in the following formats:

    en_AU
    en_GB
    en_US
    es
    fr
    it


    (I am not clear why they use 5 digits code for variations of English - but just 2 letter codes for the others ?)
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    Good question. You could get that by working out what template set the customer is utilising for their transaction. For example:

    {% set locale = "en_US" %}
    {% if template_set == "au" %}
    {% set locale = "en_AU" %}
    {% elseif template_set == "gb" %}
    {% set locale = "en_GB" %}
    {% elseif template_set == "es" %}
    {% set locale = "es" %}
    {% elseif template_set == "fr" %}
    {% set locale = "fr" %}
    {% elseif template_set == "it" %}
    {% set locale = "it" %}
    {% endif %}
    You'll need to update that to have the correct codes for your template sets, but if you insert that before you need to output the locale code, you can then use {{ locale }} to output the locale code in the config.
  • Adam,

    Has tea above code been tested ? When I install it , as discussed above, it breaks a nubmer of items including the sidecars and triggers emails as below:

    An error was recently triggered for one of the templates for your store, iSails. There may be a fatal error in a twig template related to that page which will need to be corrected, otherwise customers may not be able to complete transactions for your store.

    To correct this error, the first step is to recache and save your templates (including category and email templates) and test your store to ensure pages are displaying as they should. If the error persists, you will need to take a closer look at your templates to see what might be causing issues. If you're working with a developer for your store, it might be worth reaching out to them to ask them to assist you in debugging your templates. Also, you might find some additional information about this error from your stores error log available from your stores FoxyCart administration.

    Don't hesitate to get in touch with our support either by email or through the forums if you have any questions about why a specific template might be causing this error.

    - The FoxyCart Team

    https://admin.foxycart.com/
  • fc_adamfc_adam FoxyCart Team
    @Philippe,

    Interesting - I tested it on my own store and it worked as expected. Could you paste in the code you are using within your store and confirm where you're pasting it? If you'd prefer to keep your customisations private, you can whisper them to me using the "whisper" checkbox and entering my name in the text input that appears.
Sign In or Register to comment.