本章節包含下列主題:
整合操作說明
我們需要收集你網站訂單所包含產品的全球交易品項識別碼 (GTIN),因此,請在網站的 Google 顧客評論參與意願選項模組的 JavaScript 程式碼片段中,新增幾行程式碼。
注意:如果你使用的是舊版 Trusted Stores 參與意願選項模組,請務必更新為新版 Google 顧客評論模組,以收集產品評論。如果不確定網站所使用的模組版本,請參閱「確認網站目前使用的是否為 Trusted Stores 參與意願選項程式碼片段」部分。
確認 Google 顧客評論參與意願選項程式碼片段包含「products」行
如果剛開始整合作業,請務必加入選項欄位「products」行。如果你先前已完成整合作業,請在網站原始碼中找出 Google 顧客評論參與意願選項模組程式碼片段。在「// OPTIONAL FIELDS」或「// OPTIONAL」部分下方,請確認程式碼包含「products」行。如果沒有,您必須自行新增該行文字 (如下所示)。
<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>
在 Google 顧客評論參與意願選項程式碼片段中傳送全球交易品項識別碼 (GTIN)
// OPTIONAL
"opt_in_style": "OPT_IN_STYLE",
"products": [{"gtin":"GTIN1"}]
上方這段程式碼會將顧客訂單中的產品指定為「products」陣列中的 JSON「gtin」物件陣列。由於該行程式碼只有一個「gtin」物件,因此無論訂單中有多少產品,Google 顧客評論都只會收集一項產品的全球交易品項識別碼。如要收集訂單中所有產品的全球交易品項識別碼,必須在網站中新增程式碼,系統才會在「products」陣列中,為訂單中每種產品動態新增「gtin」物件。
舉例來說,如果訂單包含 2 種不同產品,可以使用以下程式碼片段:
// OPTIONAL
"opt_in_style": "OPT_IN_STYLE",
"products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}]
而包含 3 種不同產品的訂單,則可以使用下列程式碼片段:
// OPTIONAL
"opt_in_style": "OPT_IN_STYLE",
"products": [{"gtin":"GTIN1"}, {"gtin":"GTIN2"}, {"gtin":"GTIN3"}]
在自家網站上正確導入新版程式碼後,系統就會開始收集貴商家網站訂單的全球交易品項識別碼,以及購物者的產品評論。
確認網站目前使用的是否為 Trusted Stores 參與意願選項程式碼片段
如果你使用的是舊版 Trusted Stores 程式碼,請同時移除網站上的 Trusted Stores 參與意願選項模組程式碼及徽章程式碼,再按照 Google 顧客評論技術整合指南的指示,將新版參與意願選項模組程式碼片段新增至網站 (也可視需求加入新的徽章程式碼片段)。
如果使用的是舊版 Trusted Stores 參與意願選項模組程式碼片段,網站會顯示下列程式碼:
<!-- START Google Trusted Stores Order -->
<div id="gts-order" style="display:none;" translate="no">
<!-- start order and merchant information -->
<span id="gts-o-id">MERCHANT_ORDER_ID</span>
<span id="gts-o-email">CUSTOMER_EMAIL</span>>
<span id="gts-o-country">CUSTOMER_COUNTRY</span>
<span id="gts-o-currency">CURRENCY</span>
<span id="gts-o-total">ORDER_TOTAL</span>
<span id="gts-o-discounts">ORDER_DISCOUNTS</span>
<span id="gts-o-shipping-total">ORDER_SHIPPING</span>
<span id="gts-o-tax-total">ORDER_TAX</span>
<span id="gts-o-est-ship-date">ORDER_EST_SHIP_DATE</span>
<span id="gts-o-est-delivery-date">ORDER_EST_DELIVERY_DATE</span>
<span id="gts-o-has-preorder">HAS_BACKORDER_PREORDER</span>
<span id="gts-o-has-digital">HAS_DIGITAL_GOODS</span>
<!-- end order and merchant information -->
<!-- start repeated item specific information -->
<!-- item example: this area repeated for each item in the order -->
<span class="gts-item">
<span class="gts-i-name">ITEM_NAME</span>
<span class="gts-i-price">ITEM_PRICE</span>
<span class="gts-i-quantity">ITEM_QUANTITY</span>
<span class="gts-i-prodsearch-id">ITEM_GOOGLE_SHOPPING_ID</span>
<span class="gts-i-prodsearch-store-id"ITEM_GOOGLE_SHOPPING_ACCOUNT_ID/span>
</span>
<!-- end item 1 example -->
<!-- end repeated item specific information -->
</div>
<!-- END Google Trusted Stores Order
如果使用的是舊版 Trusted Stores 參與意願選項模組程式碼片段,那網站的 Trusted Stores 徽章程式碼片段也可能是舊版,如下所示:
<!-- BEGIN: Google Trusted Stores -->
<script type="text/javascript">
var gts = gts || [];
gts.push(["id", "{some ID number}"]);
gts.push(["badge_position", "{some position}"]);
gts.push(["locale", "PAGE_LANGUAGE"]);
gts.push(["google_base_offer_id", "ITEM_GOOGLE_SHOPPING_ID"]);
gts.push(["google_base_subaccount_id", "ITEM_GOOGLE_SHOPPING_ACCOUNT_ID"]);
(function() {
var gts = document.createElement("script");
gts.type = "text/javascript";
gts.async = true;
gts.src = "https://www.googlecommerce.com/trustedstores/api/js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gts, s);
})();
</script>
<!-- END: Google Trusted Stores -->