Hello Everyone,
I am trying to integrate Google's survey opt-in module to the checkout. Unlike my trustpilot AFS Integration, this has to be implemented on the order confirmation page.
This is the default script that I was provided:
<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": "MERCHANT_ID",
"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>
Would the best approach be the use of tag manager or through the theme order_wizard_confirmation_module template file?
If I go through tag manager, I could use the suitecommerce - transaction trigger, and custom HTML to write the script. However, I am not sure how to call certain fields.
- {{SuiteCommerce - Transaction ID}}
- {{SuiteCommerce - Customer Email?}}
- {{SuiteCommerce - Country Code}}
- {{SuiteCommerce - Delivery Time}}
The order_wizard_confirmation module seems to be the best choice. The TPL also names fields that I can use on this template.
<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": 123456789,
"order_id": "{{confirmationNumber}}",
"email": "CUSTOMER_EMAIL",
"delivery_country": "{{model.addresses.0.country}}",
"estimated_delivery_date": "{{model.summary.estimatedshipping_formatted}}",
// OPTIONAL FIELDS
"products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}]
});
});
}
</script>
For the module part, there's no reference for me to get the customer email.