ใช้โปรโมชันเพื่อแสดงข้อเสนอพิเศษสำหรับสินค้าที่คุณขายใน Google โปรโมชันจะแสดงในผลิตภัณฑ์และบริการต่างๆ ของ Google ซึ่งรวมถึง Google Search, Shopping และ Chrome โปรโมชันต้องเป็นไปตามเกณฑ์บางอย่างจึงจะได้รับอนุมัติ ดูข้อมูลเพิ่มเติมได้ที่เกณฑ์โปรโมชัน
เมื่อคุณเพิ่มโปรโมชันไปยังผลิตภัณฑ์ ผู้เลือกซื้อจะเห็นลิงก์ข้อเสนอพิเศษ เช่น "ลด 15%" หรือ "จัดส่งฟรี" ลิงก์ข้อเสนอจะเพิ่มความน่าสนใจให้ผลิตภัณฑ์และกระตุ้นให้ผู้เลือกซื้อทำการซื้อ โดยโปรโมชันทั้งหมดจะนำไปใช้ที่จุดชำระเงินหรือจุดขาย
ดูข้อมูลเพิ่มเติมได้ที่ข้อมูลเบื้องต้นเกี่ยวกับโปรโมชัน
ข้อกำหนดเบื้องต้น
Google ต้องการให้คุณระบุข้อมูลที่เฉพาะเจาะจงเกี่ยวกับธุรกิจและผลิตภัณฑ์ก่อนที่จะแสดงโปรโมชัน คุณต้องมีสิ่งต่อไปนี้
- แหล่งข้อมูลสินค้าใน Google Merchant Center
- แหล่งข้อมูลโปรโมชันใน Google Merchant Center
- บัญชี Google Ads สำหรับแคมเปญ Shopping
นอกจากนี้ คุณต้องลงทะเบียนบัญชี Merchant Center ในโปรแกรมโปรโมชันด้วย หากไม่แน่ใจว่าได้ลงทะเบียนแล้วหรือไม่ ให้ตรวจสอบที่ Merchant Center
หากยังไม่ได้ลงทะเบียน โปรดกรอกแบบฟอร์มคำขอ ทีมโปรโมชันจะแจ้งให้ทราบเมื่อคุณเริ่มดำเนินการได้
ดูข้อมูลเพิ่มเติมได้ที่เกณฑ์และนโยบายการเข้าร่วม
สร้างแหล่งข้อมูล
คุณใช้เมธอด accounts.dataSources.create เพื่อสร้างแหล่งข้อมูลโปรโมชันได้ หากมีแหล่งข้อมูลโปรโมชันอยู่แล้ว ให้ใช้เมธอด accounts.dataSources.list เพื่อดึงข้อมูลแหล่งข้อมูลทั้งหมด จากนั้นคุณจะใช้ช่อง name ของแหล่งข้อมูลโปรโมชันเพื่อสร้างโปรโมชันได้
หากต้องการอ้างอิงโดยตรงในการเรียก API ในอนาคต เราขอแนะนำอย่างยิ่งให้จัดเก็บ accounts.dataSources.name ไว้ในฐานข้อมูลในเครื่องสำหรับโปรโมชันแต่ละรายการ คุณสามารถทดแทนข้อมูลในฐานข้อมูลในเครื่องแบบครั้งเดียวได้
คำขอต่อไปนี้แสดงวิธีสร้างแหล่งข้อมูลสำหรับการเพิ่มโปรโมชัน
POST https://merchantapi.googleapis.com/datasources/v1/accounts/{ACCOUNT_ID}/dataSources
{
"displayName": "{DISPLAY_NAME}",
"promotionDataSource": {
"contentLanguage": "{CONTENT_LANGUAGE}",
"targetCountry": "{TARGET_COUNTRY}"
}
}
แทนที่ค่าต่อไปนี้
- {ACCOUNT_ID}: ตัวระบุที่ไม่ซ้ำกันของบัญชีตามที่ปรากฏใน UI ของ Merchant Center
- {DISPLAY_NAME}: ชื่อที่แสดงของแหล่งข้อมูล
- {CONTENT_LANGUAGE}: รหัสภาษา ISO 639-1 แบบ 2 ตัวอักษรของผลิตภัณฑ์ในแหล่งข้อมูล
- {TARGET_COUNTRY}: รหัสเขตแดน CLDR ของประเทศเป้าหมายที่คุณต้องการให้โปรโมชันแสดง
หลังจากคำขอทำงานสำเร็จ คุณจะเห็นการตอบกลับต่อไปนี้ซึ่งมีรายละเอียดเกี่ยวกับแหล่งข้อมูลโปรโมชันที่สร้างขึ้นใหม่
{
"name": "accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}",
"dataSourceId": "{DATASOURCE_ID}",
"displayName": "{DISPLAY_NAME}",
"promotionDataSource": {
"targetCountry": "{TARGET_COUNTRY}",
"contentLanguage": "{CONTENT_LANGUAGE}"
},
"input": "API"
}
สร้างโปรโมชัน
คุณใช้เมธอด accounts.promotions.insert เพื่อสร้างหรืออัปเดตโปรโมชันได้ เมธอด accounts.promotions.insert จะใช้ทรัพยากร promotions และชื่อแหล่งข้อมูลเป็นอินพุต โดยจะแสดงผลโปรโมชันใหม่หรือโปรโมชันที่อัปเดตแล้ว หากดำเนินการสำเร็จ
การสร้างโปรโมชันต้องใช้ชื่อแหล่งข้อมูล นอกจากนี้ คุณต้องระบุค่าสำหรับช่องต่อไปนี้ในคำขอด้วย
contentLanguageredemptionChannelpromotionIdtargetCountryattributes.offerTypeattributes.genericRedemptionCodeattributes.couponValueTypeattributes.productApplicabilityattributes.promotionEffectiveTimePeriod.endTimeattributes.promotionEffectiveTimePeriod.startTimeattributes.longTitle
Google จะตรวจสอบและอนุมัติโปรโมชันของคุณก่อนเผยแพร่ ดูข้อมูลเพิ่มเติมได้ที่กระบวนการอนุมัติโปรโมชัน
เราขอแนะนำให้อ่านนโยบายโปรโมชันเพื่อให้มั่นใจว่าโปรโมชันที่คุณสร้างมีมูลค่าเพิ่มและเป็นไปตามนโยบายโฆษณา Shopping
คำขอต่อไปนี้แสดงวิธีสร้างโปรโมชันออนไลน์
HTTP
POST https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions:insert
{
"promotion": {
"name": "{PROMOTION_NAME}",
"promotionId": "{PROMOTION_ID}",
"targetCountry": "{TARGET_COUNTRY}",
"redemptionChannel": [
"ONLINE"
],
"contentLanguage": "{CONTENT_LANGUAGE}",
"attributes": {
"promotionDisplayTimePeriod": {
"endTime": "{PROMOTION_END_TIME}",
"startTime": "{PROMOTION_START_TIME}"
},
"offerType": "{OFFER_TYPE}",
"longTitle": "{LONG_TITLE}"
}
},
"dataSource": "accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}"
}
cURL
curl --request POST \
'https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions:insert?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"dataSource":"{DATASOURCE_ID}","promotion":{"name":"accounts/{ACCOUNT_ID}/promotions/{PROMOTION_ID}y","promotionId":"abc","contentLanguage":"en","targetCountry":"US","redemptionChannel":["ONLINE"]}}' \
--compressed
ดูข้อมูลเกี่ยวกับกฎที่เกี่ยวข้องกับการตั้งค่ารหัสโปรโมชันได้ที่ข้อกำหนดขั้นต่ำสำหรับแอตทริบิวต์รหัสโปรโมชัน
ค่าที่ถูกต้องสำหรับช่อง offerType ที่ต้องกรอกคือ NO_CODE และ GENERIC_CODE หากคุณไม่ระบุค่าใดค่าหนึ่งเหล่านี้ คำขอ API จะไม่สำเร็จพร้อมกับการตอบกลับ HTTP 400 [offer_type] validation/missing_required: Invalid or
missing required attribute: offer_type ระบบจะแสดงข้อความแสดงข้อผิดพลาดที่คล้ายกันหากคุณไม่ได้ระบุฟิลด์ที่จำเป็น
หากคุณไม่ระบุค่าสำหรับช่อง attributes.genericRedemptionCode คำขอจะดำเนินการไม่สำเร็จพร้อมการตอบกลับ HTTP 400 [genericRedemptionCode] No
redemption code provided
ค่าสำหรับช่อง promotion.attributes.promotionDisplayTimePeriod.startTime และ promotion.attributes.promotionDisplayTimePeriod.endTime ต้องอยู่ในรูปแบบ yyyy-mm-ddThh:mm:ssZ โปรดตรวจสอบว่าได้แทนที่ค่าของช่องเหล่านี้ด้วยวันที่ในอนาคต
ดูข้อมูลเพิ่มเติมได้ที่ข้อกำหนดในการจัดทำข้อมูลโปรโมชัน
ดูแนวทางปฏิบัติแนะนำเกี่ยวกับการสร้างโปรโมชันได้ที่แนวทางปฏิบัติแนะนำสำหรับโปรโมชัน
ดูรายการแอตทริบิวต์ที่เกี่ยวข้องกับโปรโมชันได้ที่เพิ่มแอตทริบิวต์ Structured Data
หลังจากคำขอสร้างโปรโมชันทำงานสำเร็จแล้ว อาจใช้เวลา 2-3 นาทีเพื่อให้โปรโมชันเรียกข้อมูลได้โดยใช้ API หรือปรากฏใน Merchant Center
ต่อไปนี้คือตัวอย่างที่คุณใช้เพื่อแทรกโปรโมชันหลายรายการแบบอะซิงโครนัสได้
Java
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutureCallback;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.grpc.ChannelPoolSettings;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.protobuf.Timestamp;
import com.google.shopping.merchant.promotions.v1.Attributes;
import com.google.shopping.merchant.promotions.v1.CouponValueType;
import com.google.shopping.merchant.promotions.v1.InsertPromotionRequest;
import com.google.shopping.merchant.promotions.v1.OfferType;
import com.google.shopping.merchant.promotions.v1.ProductApplicability;
import com.google.shopping.merchant.promotions.v1.Promotion;
import com.google.shopping.merchant.promotions.v1.PromotionsServiceClient;
import com.google.shopping.merchant.promotions.v1.PromotionsServiceSettings;
import com.google.shopping.merchant.promotions.v1.RedemptionChannel;
import com.google.shopping.type.CustomAttribute;
import com.google.shopping.type.Destination.DestinationEnum;
import com.google.type.Interval;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to insert multiple promotions asynchronously. */
public class InsertPromotionsAsyncSample {
private static String generateRandomString() {
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
Random random = new Random();
StringBuilder sb = new StringBuilder(8);
for (int i = 0; i < 8; i++) {
sb.append(characters.charAt(random.nextInt(characters.length())));
}
return sb.toString();
}
private static Promotion createPromotion(String accountId) {
String merchantPromotionId = generateRandomString();
Attributes attributes =
Attributes.newBuilder()
.setProductApplicability(ProductApplicability.ALL_PRODUCTS)
.setOfferType(OfferType.GENERIC_CODE)
.setGenericRedemptionCode("ABCD1234")
.setLongTitle("My promotion")
.setCouponValueType(CouponValueType.PERCENT_OFF)
.addPromotionDestinations(DestinationEnum.SHOPPING_ADS)
.setPercentOff(10)
// Note that promotions have a 6-month limit.
// For more information, read here: https://support.google.com/merchants/answer/2906014
// Also note that only promotions valid within the past 365 days are shown in the UI.
.setPromotionEffectiveTimePeriod(
Interval.newBuilder()
.setStartTime(Timestamp.newBuilder().setSeconds(1726842472))
.setEndTime(Timestamp.newBuilder().setSeconds(1726842473))
.build())
.build();
return Promotion.newBuilder()
.setName(String.format("accounts/%s/merchantPromotions/%s", accountId, merchantPromotionId))
.setPromotionId(merchantPromotionId)
.setContentLanguage("fr")
.setTargetCountry("CH")
.addRedemptionChannel(RedemptionChannel.ONLINE)
.setAttributes(attributes)
// Custom attributes allow you to add additional information which is not available in
// Attributes. For example, you might want to pilot experimental functionality.
.addCustomAttributes(
CustomAttribute.newBuilder()
.setName("another example name")
.setValue("another example value")
.build())
.build();
}
public static void asyncInsertPromotions(String accountId, String dataSourceId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
// Creates a channel provider. This provider manages a pool of gRPC channels
// to enhance throughput for bulk operations. Each individual channel in the pool
// can handle up to approximately 100 concurrent requests.
//
// Channel: A single connection pathway to the service.
// Pool: A collection of multiple channels managed by this provider.
// Requests are distributed across the channels in the pool.
//
// We recommend estimating the number of concurrent requests you'll make, divide by 50 (50%
// utilization of channel capacity), and set the pool size to that number.
InstantiatingGrpcChannelProvider channelProvider =
InstantiatingGrpcChannelProvider.newBuilder()
.setChannelPoolSettings(ChannelPoolSettings.staticallySized(30))
.build();
PromotionsServiceSettings merchantPromotionsServiceSettings =
PromotionsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.setTransportChannelProvider(channelProvider)
.build();
try (PromotionsServiceClient merchantPromotionsServiceClient =
PromotionsServiceClient.create(merchantPromotionsServiceSettings)) {
// Arbitrarily creates five merchant promotions with random IDs.
List<InsertPromotionRequest> requests = new ArrayList<>();
for (int i = 0; i < 5; i++) {
InsertPromotionRequest request =
InsertPromotionRequest.newBuilder()
.setParent(String.format("accounts/%s", accountId))
.setPromotion(createPromotion(accountId))
.setDataSource(String.format("accounts/%s/dataSources/%s", accountId, dataSourceId))
.build();
requests.add(request);
}
// Inserts the merchant promotions.
List<ApiFuture<Promotion>> futures =
requests.stream()
.map(
request ->
merchantPromotionsServiceClient.insertPromotionCallable().futureCall(request))
.collect(Collectors.toList());
// Creates callback to handle the responses when all are ready.
ApiFuture<List<Promotion>> responses = ApiFutures.allAsList(futures);
ApiFutures.addCallback(
responses,
new ApiFutureCallback<List<Promotion>>() {
@Override
public void onSuccess(List<Promotion> results) {
System.out.println("Inserted merchant promotions below:");
System.out.println(results);
}
@Override
public void onFailure(Throwable throwable) {
System.out.println(throwable);
}
},
MoreExecutors.directExecutor());
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
asyncInsertPromotions(config.getAccountId().toString(), "<YOUR_DATA_SOURCE_ID>");
}
}
ต่อไปนี้เป็นตัวอย่างโปรโมชันที่คุณใช้เพื่อเริ่มต้นใช้งานได้
โปรโมชันในร้านที่ใช้ได้กับสินค้าทั้งหมดและร้านค้าทั้งหมด
ตัวอย่างคำขอต่อไปนี้แสดงวิธีสร้างโปรโมชันในร้านที่ใช้ได้กับผลิตภัณฑ์ทั้งหมดในบัญชี Merchant Center และร้านค้าทั้งหมดที่เพิ่มในบัญชี Business Profile ที่ลิงก์ไว้
POST https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions:insert
{
"promotion": {
"promotionId": "buy_2_get_10_off",
"contentLanguage": "en",
"targetCountry": "US",
"redemptionChannel": [
"IN_STORE"
],
"attributes": {
"longTitle": "Buy 2 and get 10$ OFF purchase",
"productApplicability": "ALL_PRODUCTS",
"offerType": "NO_CODE",
"couponValueType": "BUY_M_GET_MONEY_OFF",
"promotionDisplayTimePeriod": {
"startTime": "2024-2-06T00:47:44Z",
"endTime": "2024-5-06T00:47:44Z"
},
"promotionEffectiveTimePeriod": {
"startTime": "2024-2-06T00:47:44Z",
"endTime": "2024-5-06T00:47:44Z"
},
"moneyOffAmount": {
"amountMicros": "1000000",
"currencyCode": "USD"
},
"minimumPurchaseQuantity": 2,
"storeApplicability": "ALL_STORES",
"promotionUrl": "http://promotionnew4url.com/",
"promotionDestinations": [
"LOCAL_INVENTORY_ADS"
],
}
},
"dataSource": "accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}"
}
ต้องระบุข้อมูลในช่อง productApplicability แอตทริบิวต์นี้จะระบุว่าโปรโมชันมีสิทธิ์ใช้กับสินค้าทั้งหมดหรือใช้กับสินค้าที่เฉพาะเจาะจงเท่านั้น ค่าที่รองรับคือ ALL_PRODUCTS และ SPECIFIC_PRODUCTS ดูข้อมูลเพิ่มเติมได้ที่เลือกผลิตภัณฑ์สำหรับโปรโมชัน
ต้องระบุข้อมูลในช่อง couponValueType ซึ่งจะระบุประเภทโปรโมชันที่คุณกำลังแสดง ดูรายการค่าที่รองรับได้ที่ประเภทมูลค่าของคูปอง
คุณต้องระบุแอตทริบิวต์บางรายการ ทั้งนี้ขึ้นอยู่กับประเภทมูลค่าของคูปองที่เลือก
ช่อง minimumPurchaseQuantity ช่วยให้คุณกำหนดค่าสำหรับจำนวนการซื้อขั้นต่ำที่จำเป็นต่อการแลกสิทธิ์รับข้อเสนอโปรโมชัน ดูข้อมูลเพิ่มเติมได้ที่จำนวนการซื้อขั้นต่ำสำหรับโปรโมชัน
ในทำนองเดียวกัน คุณสามารถใช้ช่อง minimumPurchaseAmount เพื่อกำหนดจำนวนเงินขั้นต่ำที่ต้องใช้จ่ายเพื่อแลกรับโปรโมชัน ดูข้อมูลเพิ่มเติมได้ที่ยอดสั่งซื้อขั้นต่ำ
ดูข้อมูลเพิ่มเติมเกี่ยวกับค่าที่คุณต้องระบุเพื่อสร้างโปรโมชันในร้านได้ที่ข้อกำหนดเกี่ยวกับแหล่งข้อมูลสำหรับโปรโมชันในร้าน
โปรโมชันออนไลน์ที่ใช้กับผลิตภัณฑ์ที่เลือกซึ่งมีรหัสแลกรับข้อเสนอ
ตัวอย่างคำขอต่อไปนี้แสดงวิธีสร้างโปรโมชันออนไลน์ที่ใช้กับผลิตภัณฑ์ที่เลือกซึ่งมีรหัสแลกรับข้อเสนอ
POST https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions:insert
{
"promotion": {
"promotionId": "25_pct_off",
"contentLanguage": "en",
"targetCountry": "US",
"redemptionChannel": [
"ONLINE"
],
"attributes": {
"longTitle": "10% off on selected items",
"productApplicability": "SPECIFIC_PRODUCTS",
"offerType": "GENERIC_CODE",
"genericRedemptionCode": "SPRINGSALE",
"couponValueType": "PERCENT_OFF",
"promotionDisplayTimePeriod": {
"startTime": "2024-2-06T00:47:44Z",
"endTime": "2024-5-06T00:47:44Z"
},
"promotionEffectiveTimePeriod": {
"startTime": "2024-2-06T00:47:44Z",
"endTime": "2024-5-06T00:47:44Z"
},
"percentOff": 25,
"promotionDestinations": [
"FREE_LISTINGS"
],
"itemIdInclusion": [
"1499860100",
"1499860101",
"1499860102",
"1499860103",
"1499860104"
],
}
},
"dataSource": "accounts/{ACCOUNT_ID}/dataSources/1000000573361824"
}
ดูโปรโมชัน
หากต้องการดูโปรโมชัน ให้ใช้ accounts.promotions.get
คำขอ GET นี้เป็นแบบอ่านอย่างเดียว โดยต้องใช้ merchantId และรหัสของโปรโมชัน เมธอด GET จะแสดงผลทรัพยากรโปรโมชันที่เกี่ยวข้อง
เช่น
HTTP
GET https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions/{PROMOTION_ID}
cURL
curl \
'https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions/{PROMOTION_ID}?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'Accept: application/json' \
--compressed
แทนที่ค่าต่อไปนี้
- {ACCOUNT_ID}: ตัวระบุที่ไม่ซ้ำกันของบัญชี Merchant Center
- {PROMOTION_ID}: ตัวระบุที่ไม่ซ้ำกันของโปรโมชันที่คุณต้องการเรียกข้อมูล รูปแบบคือ {CHANNEL} ~{CONTENT_LANGUAGE}~ {TARGET_COUNTRY}~{PROMOTION_ID}
โปรดทราบว่าระบบจะใช้เวลา 2-3 นาทีจึงจะเรียกข้อมูลโปรโมชันที่สร้างใหม่ได้โดยใช้ API
ดูโปรโมชันในร้าน
ตัวอย่างคำขอต่อไปนี้จะดึงข้อมูลโปรโมชันในร้านที่มีรหัสโปรโมชันเป็น in_store~en~US~buy_2_get_10_off
GET https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions/in_store~en~US~buy_2_get_10_off
หลังจากคำขอสำเร็จแล้ว คุณจะเห็นการตอบกลับต่อไปนี้
{
"name": "accounts/{ACCOUNT_ID}/promotions/in_store~en~US~buy_2_get_10_off",
"promotionId": "buy_2_get_10_off",
"contentLanguage": "en",
"targetCountry": "US",
"redemptionChannel": [
"IN_STORE"
],
"attributes": {
"longTitle": "Buy 2 and get 10$ OFF purchase",
"productApplicability": "ALL_PRODUCTS",
"offerType": "NO_CODE",
"couponValueType": "BUY_M_GET_MONEY_OFF",
"promotionDisplayTimePeriod": {
"startTime": "2024-2-06T00:47:44Z",
"endTime": "2024-5-06T00:47:44Z"
},
"promotionEffectiveTimePeriod": {
"startTime": "2024-2-06T00:47:44Z",
"endTime": "2024-5-06T00:47:44Z"
},
"moneyOffAmount": {
"amountMicros": "1000000",
"currencyCode": "USD"
},
"minimumPurchaseQuantity": 2,
"storeApplicability": "ALL_STORES",
"promotionUrl": "http://promotionnew4url.com/",
"promotionDestinations": [
"LOCAL_INVENTORY_ADS"
],
}
"dataSource": "accounts/{ACCOUNT_ID}/dataSources/1000000573361824"
}
ช่อง moneyOffAmount ในตัวอย่างนี้ระบุส่วนลดที่เสนอในโปรโมชัน ดูข้อมูลเพิ่มเติมได้ที่จำนวนเงินที่เป็นส่วนลดของโปรโมชัน
ช่อง promotionUrl ในตัวอย่างนี้ระบุลิงก์ไปยังเว็บไซต์ของร้านค้าที่ผู้เลือกซื้อจะดูข้อมูลเพิ่มเติมเกี่ยวกับโปรโมชันได้ โปรโมชันโฆษณาสินค้าคงคลังในร้านจะแสดงข้อผิดพลาดหากคุณไม่ใส่ช่อง promotionUrl
ดูโปรโมชันออนไลน์
คำขอตัวอย่างต่อไปนี้จะดึงข้อมูลโปรโมชันออนไลน์ที่มีรหัสโปรโมชันเป็น online~en~US~25_pct_off
GET https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions/online~en~US~25_pct_off
{
"name": "accounts/{ACCOUNT_ID}/promotions/online~en~US~25_pct_off",
"promotionId": "25_pct_off",
"contentLanguage": "en",
"targetCountry": "US",
"redemptionChannel": [
"ONLINE"
],
"attributes": {
"longTitle": "10% off on selected items",
"productApplicability": "SPECIFIC_PRODUCTS",
"offerType": "GENERIC_CODE",
"genericRedemptionCode": "WINTERGIFT",
"couponValueType": "PERCENT_OFF",
"promotionDisplayTimePeriod": {
"startTime": "2024-2-06T00:47:44Z",
"endTime": "2024-5-06T00:47:44Z"
},
"promotionEffectiveTimePeriod": {
"startTime": "2024-2-06T00:47:44Z",
"endTime": "2024-5-06T00:47:44Z"
},
"percentOff": 25,
"promotionDestinations": [
"FREE_LISTINGS"
],
"itemIdInclusion": [
"1499860100",
"1499860101",
"1499860102",
"1499860103",
"1499860104"
],
}
"dataSource": "accounts/{ACCOUNT_ID}/dataSources/{dataSource}"
}
ช่อง itemIdInclusion ที่ใช้ในตัวอย่างนี้จะระบุผลิตภัณฑ์ที่มีสิทธิ์ใช้โปรโมชัน ดูข้อมูลเพิ่มเติมได้ที่รหัสผลิตภัณฑ์สำหรับโปรโมชัน
แสดงรายการโปรโมชัน
คุณสามารถใช้เมธอด promotions.list เพื่อดูโปรโมชันทั้งหมดที่สร้างขึ้น
ตัวอย่างคำขอมีดังนี้
HTTP
GET https://merchantapi.googleapis.com/promotions/v1/{ACCOUNT_ID}/promotions
cURL
curl \
'https://merchantapi.googleapis.com/promotions/v1/accounts/{ACCOUNT_ID}/promotions?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'Accept: application/json' \
--compressed
การตอบกลับจะมีรายการโปรโมชันทั้งหมดในบัญชี คุณจะดูรายละเอียดของโปรโมชันแต่ละรายการได้ เช่น promotionId, redemptionChannel, dataSource, promotionStatus และอื่นๆ
ดูสถานะของโปรโมชัน
หากต้องการดูสถานะของโปรโมชัน ให้ดูแอตทริบิวต์ promotionStatus ที่แสดงผลโดยเมธอด promotions.get หรือ promotions.list
ช่อง promotionStatus อาจมีค่าต่อไปนี้
IN_REVIEW: โปรโมชันยังอยู่ระหว่างการตรวจสอบREJECTED: โปรโมชันไม่ได้รับอนุมัติLIVE: โปรโมชันได้รับอนุมัติและทำงานอยู่STOPPED: บัญชีหยุดการโปรโมตEXPIRED: โปรโมชันไม่ได้ใช้งานแล้วPENDING: โปรโมชันไม่ได้หยุดทำงาน และรีวิวทั้งหมดได้รับอนุมัติแล้ว แต่วันที่ใช้งานเป็นวันที่ในอนาคตSTATE_UNSPECIFIED: ไม่ทราบสถานะโปรโมชัน
หากต้องการทำความเข้าใจกระบวนการอนุมัติโปรโมชันที่คุณสร้างขึ้น โปรดดูกระบวนการอนุมัติโปรโมชัน
ตัวอย่างสถานะโปรโมชัน
ตัวอย่างต่อไปนี้แสดงความแตกต่างระหว่างคำขอที่สำเร็จและไม่สำเร็จ
ไม่มีการแมปผลิตภัณฑ์
เนื้อหาการตอบกลับต่อไปนี้แสดงโปรโมชันออนไลน์ที่ไม่ได้รับอนุมัติเนื่องจากไม่มีการแมปผลิตภัณฑ์
"promotionStatus": {
"destinationStatuses": [
{
"reportingContext": "FREE_LISTINGS",
"status": "REJECTED"
}
],
"itemLevelIssues": [
{
"code": "promotion_sku_unmapped",
"severity": "DISAPPROVED",
"resolution": "merchant_action",
"reportingContext": "FREE_LISTINGS",
"description": "Unmapped",
"detail": "This promotion couldn't be tested during review because it doesn't apply to any products that are currently in your Products feed",
"documentation": "https://support.google.com/merchants/answer/2906014",
"applicableCountries": [
"US"
]
},
{
"code": "promotion_sku_additional_requirements",
"severity": "DISAPPROVED",
"resolution": "merchant_action",
"reportingContext": "FREE_LISTINGS",
"description": "Promotion conditions not allowed",
"detail": "This promotion has additional requirements that are not allowed such as requiring customers to verify additional details like phone number or ID before showing the promotion details",
"documentation": "https://support.google.com/merchants/answer/2906014",
"applicableCountries": [
"US"
]
}
]
}
หากต้องการแก้ปัญหาโปรโมชันที่ไม่ได้รับอนุมัติและดูวิธีหลีกเลี่ยงการไม่อนุมัติในอนาคต โปรดดูหัวข้อแก้ไขปัญหาเกี่ยวกับโปรโมชันที่ไม่ได้รับอนุมัติ
หากโปรโมชันที่คุณสร้างไม่ได้รับอนุมัติ คุณจะได้รับอีเมลที่ระบุเหตุผลของการปฏิเสธและวิธีการแก้ไขปัญหา
โปรโมชันอยู่ระหว่างการประเมิน
เนื้อหาการตอบกลับต่อไปนี้แสดงโปรโมชันที่ยังอยู่ระหว่างการประเมิน
"promotionStatus": {
"destinationStatuses": [
{
"reportingContext": "FREE_LISTINGS",
"status": "PENDING"
},
{
"destination": "SHOPPING_ADS",
"status": "PENDING"
}
],
"itemLevelIssues": []
}
โปรโมชันที่ได้รับอนุมัติและใช้งานอยู่
เนื้อหาการตอบกลับต่อไปนี้แสดงโปรโมชันที่ผู้เลือกซื้อจะเห็น
"promotionStatus": {
"destinationStatuses": [
{
"reportingContext": "FREE_LISTINGS",
"status": "LIVE"
},
{
"destination": "SHOPPING_ADS",
"status": "LIVE"
} ],
"itemLevelIssues": []
}
ดูข้อมูลเพิ่มเติมได้ที่คำถามที่พบบ่อยเกี่ยวกับสถานะโปรโมชัน
ลบโปรโมชัน
คุณไม่สามารถลบโปรโมชันโดยใช้ API หากต้องการลบโปรโมชัน คุณจะต้องเข้าถึง UI ของ Merchant Center ดูข้อมูลเพิ่มเติมได้ที่แก้ไขโปรโมชันหรือเปลี่ยนสถานะโปรโมชัน
หากต้องการสิ้นสุดโปรโมชันที่มีอยู่ คุณสามารถใช้เมธอด accounts.promotions.insert เพื่ออัปเดตช่อง attributes.promotionEffectiveTimePeriod.endTime เป็นเวลาในอดีตได้
ดูข้อมูลเพิ่มเติม
- ดูรายละเอียดเพิ่มเติมได้ที่ศูนย์ช่วยเหลือเกี่ยวกับโปรโมชัน
- หากต้องการแก้ปัญหาที่พบได้ทั่วไป โปรดดูหัวข้อแก้ปัญหาที่เกี่ยวข้องกับ API ย่อยของโปรโมชัน
- ดูข้อมูลเกี่ยวกับการย้ายข้อมูลจาก Content API for Shopping ได้ที่ย้ายข้อมูลการจัดการโปรโมชัน