訂單追蹤信號可讓您向 Google 提供透過商家網站完成的訂單歷來追蹤資料。為買家提供更精確的運送預估時間。訂單追蹤信號也有助於在產品資訊中加入免運費及快速出貨註解。
你可以提交透過商家網站完成的訂單資料。你提交的資料會補充在 Merchant Center 帳戶設定中提供的運送設定資訊。舉例來說,如果你向買家提供的運送預估時間為 3 到 7 天,但最近的過往訂單追蹤記錄顯示,在某些地區,訂單通常會在 3 天內送達,Google 就會更新你的產品資訊,向消費者提供更準確的預估時間。
本指南說明如何使用 ordertrackingsignals
資源提交歷來訂單追蹤資料。
必要條件
如要為其他帳戶傳送訂單追蹤信號,您的帳戶必須預先獲得核准,這需要其他帳戶連結帳戶持有人。
詳情請參閱「連結合作夥伴帳戶與 Merchant Center 帳戶」。
使用 ordertrackingsignals
資源
ordertrackingsignals
資源包含單一 create
端點,可供你提交歷來訂單追蹤資料。
每項要求只能提交一筆訂單。以下資訊說明為何需要這項參數,以及如何將其加入要求主體。
訂單詳細資料 (訂單建立時間、交貨地點郵遞區號和區碼)、
shippingInfo
和追蹤號碼:有助於計算實際處理和運送時間。merchant_id
和lineItems
:用於將訂單與 Merchant Center 帳戶中的產品配對。customerShippingFee
:向買家收取的運費。
提交新的訂單追蹤信號資料
以下是提交零售商訂單「123456789」訂單追蹤信號的範例要求,該訂單共有 8 個項目。
https://merchantapi.googleapis.com/products/ordertracking/v1/accounts/{ACCOUNT_ID}/ordertrackingsignals
{
"merchantId": {ACCOUNT_ID},
"orderCreatedTime": {
"year": 2025,
"month": 1,
"day": 2,
"hours": 0,
"minutes": 0,
"seconds": 0,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"orderId": "123456789",
"shippingInfo": [
{
"shipmentId": "1",
"trackingId": "100",
"carrier": "FEDEX",
"carrierService": "GROUND",
"shippedTime": {
"year": 2025,
"month": 1,
"day": 3,
"hours": 0,
"minutes": 0,
"seconds": 0,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"shippingStatus": "DELIVERED"
},
{
"shipmentId": "2",
"earliestDeliveryPromiseTime": {
"year": 2025,
"month": 1,
"day": 4,
"hours": 0,
"minutes": 0,
"seconds": 0,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"latestDeliveryPromiseTime": {
"year": 2025,
"month": 1,
"day": 5,
"hours": 0,
"minutes": 0,
"seconds": 0,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"actualDeliveryTime": {
"year": 2025,
"month": 1,
"day": 5,
"hours": 0,
"minutes": 0,
"seconds": 0,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"shippedTime": {
"year": 2025,
"month": 1,
"day": 3,
"hours": 0,
"minutes": 0,
"seconds": 0,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"shippingStatus": "DELIVERED"
}
],
"lineItems": [
{
"lineItemId": "item1",
"productId": "en~US~trouser",
"quantity": "3"
},
{
"lineItemId": "item2",
"productId": "en~US~sneaker",
"quantity": "5"
}
],
"shipmentLineItemMapping": [
{
"shipmentId": "1",
"lineItemId": "item1",
"quantity": "1"
},
{
"shipmentId": "2",
"lineItemId": "item1",
"quantity": "2"
},
{
"shipmentId": "1",
"lineItemId": "item2",
"quantity": "4"
},
{
"shipmentId": "2",
"lineItemId": "item2",
"quantity": "1"
}
],
"customerShippingFee": {
"amount_micros": 4500000,
"currency_code": "USD"
},
"deliveryPostalCode": "94043",
"deliveryRegionCode": "US"
}
以下是成功呼叫的回應範例:
{
"orderCreatedTime": {
"year": 2025,
"month": 1,
"day": 2,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"orderId": "15e2b0d3c33891ebb0f1ef609ec419420c20e320ce94c65fbc8c3312448eb225",
"shippingInfo": [
{
"shipmentId": "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b",
"trackingId": "100",
"carrier": "FEDEX",
"carrierService": "GROUND",
"shippedTime": {
"year": 2025,
"month": 1,
"day": 3,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"shippingStatus": "DELIVERED"
},
{
"shipmentId": "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35",
"shippedTime": {
"year": 2025,
"month": 1,
"day": 3,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"earliestDeliveryPromiseTime": {
"year": 2025,
"month": 1,
"day": 4,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"latestDeliveryPromiseTime": {
"year": 2025,
"month": 1,
"day": 5,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"actualDeliveryTime": {
"year": 2025,
"month": 1,
"day": 5,
"timeZone": {
"id": "America/Los_Angeles"
}
},
"shippingStatus": "DELIVERED"
}
],
"lineItems": [
{
"lineItemId": "item1",
"productId": "en~US~8465944842",
"quantity": "3"
},
{
"lineItemId": "item2",
"productId": "en~US~8465944842",
"quantity": "5"
}
],
"shipmentLineItemMapping": [
{
"shipmentId": "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b",
"lineItemId": "item1",
"quantity": "1"
},
{
"shipmentId": "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35",
"lineItemId": "item1",
"quantity": "2"
},
{
"shipmentId": "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b",
"lineItemId": "item2",
"quantity": "4"
},
{
"shipmentId": "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35",
"lineItemId": "item2",
"quantity": "1"
}
],
"customerShippingFee": {
"amountMicros": "4500000",
"currencyCode": "USD"
},
"deliveryPostalCode": "94043",
"deliveryRegionCode": "US",
"orderTrackingSignalId": "2424724582881888160",
"merchantId": "1234"
}
以下程式碼範例說明如何提交訂單追蹤信號資料:
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.ordertracking.v1.CreateOrderTrackingSignalRequest;
import com.google.shopping.merchant.ordertracking.v1.OrderTrackingSignal;
import com.google.shopping.merchant.ordertracking.v1.OrderTrackingSignal.LineItemDetails;
import com.google.shopping.merchant.ordertracking.v1.OrderTrackingSignal.ShipmentLineItemMapping;
import com.google.shopping.merchant.ordertracking.v1.OrderTrackingSignal.ShippingInfo;
import com.google.shopping.merchant.ordertracking.v1.OrderTrackingSignal.ShippingInfo.ShippingState;
import com.google.shopping.merchant.ordertracking.v1.OrderTrackingSignalsServiceClient;
import com.google.shopping.merchant.ordertracking.v1.OrderTrackingSignalsServiceSettings;
import com.google.shopping.type.Price;
import com.google.type.DateTime;
import com.google.type.TimeZone;
import java.util.Arrays;
import java.util.List;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to create an order tracking signal. */
public class CreateOrderTrackingSignalSample {
private static String getParent(String accountId) {
return String.format("accounts/%s", accountId);
}
private static void createOrderTrackingSignal(Config config, List<String> productIds)
throws Exception {
GoogleCredentials credentials = new Authenticator().authenticate();
OrderTrackingSignalsServiceSettings orderTrackingSignalsServiceSettings =
OrderTrackingSignalsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.build();
String parent = getParent(config.getAccountId().toString());
String firstProductId = productIds.get(0);
String secondProductId = productIds.get(1);
DateTime orderCreatedTime =
DateTime.newBuilder()
.setYear(2025)
.setMonth(3)
.setDay(24)
.setHours(12)
.setMinutes(2)
.setSeconds(22)
.setTimeZone(TimeZone.newBuilder().setId("America/Los_Angeles"))
.build();
DateTime shippedTime1 =
DateTime.newBuilder()
.setYear(2025)
.setMonth(3)
.setDay(25)
.setHours(16)
.setMinutes(22)
.setTimeZone(TimeZone.newBuilder().setId("America/Los_Angeles"))
.build();
DateTime shippedTime2 =
DateTime.newBuilder()
.setYear(2025)
.setMonth(3)
.setDay(26)
.setHours(16)
.setMinutes(22)
.setTimeZone(TimeZone.newBuilder().setId("America/Los_Angeles"))
.build();
DateTime earliestDeliveryPromiseTime =
DateTime.newBuilder()
.setYear(2025)
.setMonth(3)
.setDay(27)
.setTimeZone(TimeZone.newBuilder().setId("America/Los_Angeles"))
.build();
DateTime latestDeliveryPromiseTime =
DateTime.newBuilder()
.setYear(2025)
.setMonth(3)
.setDay(30)
.setTimeZone(TimeZone.newBuilder().setId("America/Los_Angeles"))
.build();
DateTime actualDeliveryTime =
DateTime.newBuilder()
.setYear(2025)
.setMonth(3)
.setDay(29)
.setHours(16)
.setMinutes(22)
.setTimeZone(TimeZone.newBuilder().setId("America/Los_Angeles"))
.build();
ShippingInfo shippingInfo1 =
ShippingInfo.newBuilder()
.setShipmentId("shipment_id1")
.setCarrier("UPS")
.setCarrierService("Ground")
.setTrackingId("1Z23456789")
.setShippedTime(shippedTime1)
.setEarliestDeliveryPromiseTime(earliestDeliveryPromiseTime)
.setLatestDeliveryPromiseTime(latestDeliveryPromiseTime)
.setActualDeliveryTime(actualDeliveryTime)
.setShippingStatus(ShippingState.DELIVERED)
.setOriginPostalCode("94043")
.setOriginRegionCode("US")
.build();
ShippingInfo shippingInfo2 =
ShippingInfo.newBuilder()
.setShipmentId("shipment_id2")
.setCarrier("USPS")
.setCarrierService("Ground Advantage")
.setTrackingId("987654321")
.setShippedTime(shippedTime2)
.setShippingStatus(ShippingState.SHIPPED)
.setOriginPostalCode("94043")
.setOriginRegionCode("US")
.build();
try (OrderTrackingSignalsServiceClient orderTrackingSignalsServiceClient =
OrderTrackingSignalsServiceClient.create(orderTrackingSignalsServiceSettings)) {
CreateOrderTrackingSignalRequest request =
CreateOrderTrackingSignalRequest.newBuilder()
.setParent(parent)
.setOrderTrackingSignal(
OrderTrackingSignal.newBuilder()
// Unique order ID across all merchants orders.
.setOrderId("unique_order_id443455")
// If sending signal on behalf of another merchant use setMerchantId to
// indicate the merchant.
// .setMerchantId(123L)
.setOrderCreatedTime(orderCreatedTime)
.addShippingInfo(shippingInfo1)
.addShippingInfo(shippingInfo2)
// Details of the line items in the order including quantity and fields
// identifying the product.
.addLineItems(
LineItemDetails.newBuilder()
.setQuantity(2)
.setProductId(firstProductId)
.setLineItemId("item1"))
.addLineItems(
LineItemDetails.newBuilder()
.setQuantity(1)
.setProductId(secondProductId)
.setLineItemId("item2")
// Optional fields used to identify the product when product ID is not
// sufficient.
.setMpn("00638HAY")
.setProductTitle("Tshirt-small-blue")
.setBrand("Brand1")
// Any GTIN associated with the product.
.addGtins("001234567890"))
// Mapping of line items to shipments.
.addShipmentLineItemMapping(
ShipmentLineItemMapping.newBuilder()
.setShipmentId("shipment_id1")
.setLineItemId("item2")
.setQuantity(1))
.addShipmentLineItemMapping(
ShipmentLineItemMapping.newBuilder()
.setShipmentId("shipment_id2")
.setLineItemId("item1")
.setQuantity(1))
.addShipmentLineItemMapping(
ShipmentLineItemMapping.newBuilder()
.setShipmentId("shipment_id1")
.setLineItemId("item1")
.setQuantity(1))
// The price represented as a number in micros (1 million micros is an
// equivalent to one's currency standard unit, for example, 1 USD = 1000000
// micros).
.setCustomerShippingFee(
Price.newBuilder()
// Equivalent to 5 USD.
.setAmountMicros(5000000)
.setCurrencyCode("USD"))
.setDeliveryPostalCode("10011"))
.build();
System.out.println("Sending Create OrderTrackingSignal request.");
OrderTrackingSignal response =
orderTrackingSignalsServiceClient.createOrderTrackingSignal(request);
System.out.println("Created OrderTrackingSignal below.");
System.out.println(response);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// All products in the order. Replace with actual products in the order. Be sure to include all
// products in the order.
String productId1 = "online~en~us~sku123";
String productId2 = "online~en~us~skuabc";
List<String> productIds = Arrays.asList(productId1, productId2);
createOrderTrackingSignal(config, productIds);
}
}
代表零售商提交新的訂單追蹤信號資料
如要代表零售商提交新的訂單追蹤信號資料,請按照下列步驟操作:
- 請務必先啟用這項功能,才能代表其他商家提交資料。如要申請存取權,請傳送電子郵件至 OrderTrackingSignals@google.com 與我們聯絡。
- 設定
merchant_id
欄位,並代表商家傳送資料。
更新現有的訂單追蹤信號資料
如要修改已提交的訂單追蹤資料,請提交含有新資料的要求,並使用相同的 orderId
。如要取得運送預估時間和快速免運徽章,系統只會使用每個 orderId
最近提交的資料。