CharlieW Posted November 20, 2020 Share Posted November 20, 2020 (edited) Does anyone have experience with Google Customer Reviews Opt-in Integration on the order confirmation page? I've followed all the instructions to the best of my understanding, but don't see the Opt-in dialog box appear on the order confirmation page when in test mode. For 7.1, if it matters. *EDIT - Works if I put in a static date, but fails if I use PHP for a dynamic delivery date. I have no experience with PHP, so I don't know what the issue might be. Here is my code in Settings>Advanced>Code Injection>Order Confirmation Page <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": *********, "order_id": "{orderId}", "email": "{customerEmailAddress}", "delivery_country": "US", "estimated_delivery_date": "<?php echo date("Y-m-d", strtotime("+ 7 days")); ?>" }); }); } </script> Google's instructions are here - https://support.google.com/merchants/answer/7106244 Thanks for your advice! Edited November 20, 2020 by CharlieW Clarity, progress update Link to comment
Richardf21 Posted January 19, 2021 Share Posted January 19, 2021 I have the same issue, I don't think php works with squarespace onlineKarma 1 Link to comment
onlineKarma Posted February 12, 2021 Share Posted February 12, 2021 Same issue here - don't see a solution so far. But I think Squarespace is in generall working on the shopping features (as they are yet quite limited in general). Link to comment
Adrian213 Posted April 7, 2021 Share Posted April 7, 2021 Hello, If you haven't sorted this already, you need to use Javascript to generate the date - won't work with PHP. I believe the date is used by Google to send the review to the cusomer so it needn't be too specific, in this example I've just added 7 days to the current date: <script src="https://apis.google.com/js/platform.js?onload=renderOptIn" async defer></script> <script> window.renderOptIn = function() { window.gapi.load('surveyoptin', function() { const deliveryDate = new Date(); deliveryDate.setDate(deliveryDate.getDate() + 7); function formatDate(date) { var d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); } window.gapi.surveyoptin.render( { // REQUIRED FIELDS "merchant_id": 12345678, "order_id": "{orderId}", "email": "{customerEmailAddress}", "delivery_country": "GB", "estimated_delivery_date": formatDate(deliveryDate) // OPTIONAL FIELDS //"products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}] }); }); } </script> Hope it helps Link to comment
ferguswood Posted January 14, 2022 Share Posted January 14, 2022 (edited) On 4/7/2021 at 10:39 AM, Adrian213 said: Hello, If you haven't sorted this already, you need to use Javascript to generate the date - won't work with PHP. I believe the date is used by Google to send the review to the cusomer so it needn't be too specific, in this example I've just added 7 days to the current date: <script src="https://apis.google.com/js/platform.js?onload=renderOptIn" async defer></script> <script> window.renderOptIn = function() { window.gapi.load('surveyoptin', function() { const deliveryDate = new Date(); deliveryDate.setDate(deliveryDate.getDate() + 7); function formatDate(date) { var d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); } window.gapi.surveyoptin.render( { // REQUIRED FIELDS "merchant_id": 12345678, "order_id": "{orderId}", "email": "{customerEmailAddress}", "delivery_country": "GB", "estimated_delivery_date": formatDate(deliveryDate) // OPTIONAL FIELDS //"products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}] }); }); } </script> Hope it helps Hi @Adrian213, Thank you very much for this. So does this code you've kindly shared work for you? EDIT: Code above works a treat! I've noticed companies such as Nudie Jeans use this service and you are able to write a review straight after your purchase - has anybody any idea how you would be able to change the code so this happens? Many thanks! Edited January 14, 2022 by ferguswood Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment