เปิดใช้งานรายการโฆษณา

รายการโฆษณาทั้งหมดที่สร้างโดยใช้ Display & Video 360 API จะสร้างขึ้นในสถานะฉบับร่างในตอนแรก รายการโฆษณาจะไม่แสดงโฆษณาในสถานะฉบับร่างนี้ คุณจึงปรับการตั้งค่าและการกำหนดเป้าหมายได้โดยไม่ต้องกังวลว่าการเปลี่ยนแปลงเหล่านั้นจะส่งผลต่อการแสดงโฆษณาในปัจจุบัน หน้านี้อธิบายขั้นตอนที่คุณควรทำเพื่อยืนยันว่าบรรทัดรายการพร้อมแสดงโฆษณา และวิธีอัปเดตสถานะเป็น "ใช้งานอยู่"

สิ่งที่ต้องทำก่อนเปิดใช้งาน

เนื่องจากรายการโฆษณาเป็นวิธีใช้รายได้จากโฆษณาผ่านการซื้อและการแสดงโฆษณา คุณจึงต้องตรวจสอบว่ารายการโฆษณาจะแสดงโฆษณาตามที่ตั้งใจไว้เมื่อเปิดใช้งาน ต่อไปนี้คือสิ่งที่ควรพิจารณาก่อนเปิดใช้งานบรรทัดรายการ

  • ตรวจสอบว่าการตั้งค่าช่วงเวลาที่ใช้งานถูกต้อง: ตรวจสอบช่อง flight ของรายการโฆษณาเพื่อให้แน่ใจว่าตั้งค่ากรอบเวลาของรายการโฆษณาไว้ถูกต้อง กรอบเวลาของรายการโฆษณาอาจกําหนดเองสำหรับรายการโฆษณาหรือรับค่าเดิมมาจากใบสั่งซื้อการใส่โฆษณาหลัก
  • ยืนยันว่าไม่มีคําเตือนที่บล็อกการแสดงรายการโฆษณา ใช้ advertisers.lineItems.get เพื่อดึงข้อมูลแหล่งข้อมูลรายการโฆษณา และตรวจสอบช่อง warningMessages เพื่อยืนยันว่ารายการโฆษณาไม่มีคําเตือนที่อาจขัดขวางการแสดงรายการโฆษณา รายการตัวเลือก LineItemWarningMessage จะบันทึกผลกระทบของคำเตือนแต่ละรายการ
  • ยืนยันว่าทรัพยากรหลักทั้งหมดทํางานอยู่ด้วย: รายการโฆษณาที่ใช้งานอยู่จะไม่เริ่มแสดงโฆษณาหากผู้ลงโฆษณา แคมเปญ หรือคําสั่งซื้อการแทรกโฆษณาหลักไม่ทํางาน เรียกดูแหล่งข้อมูลเหล่านี้โดยใช้GETเมธอดในบริการผู้ลงโฆษณา แคมเปญ และคําสั่งซื้อการแทรก

เปิดใช้งานรายการโฆษณา

เปิดใช้งานรายการโฆษณาโดยอัปเดตช่อง entityStatus เป็น ENTITY_STATUS_ACTIVE คุณสามารถอัปเดตช่องนี้สำหรับรายการโฆษณาแต่ละรายการได้โดยใช้เมธอด advertisers.lineItems.patch และสำหรับรายการโฆษณาหลายรายการภายในผู้ลงโฆษณารายหนึ่งโดยใช้ advertisers.lineItems.bulkUpdate

ต่อไปนี้คือตัวอย่างวิธีใช้ bulkUpdate เพื่อเปิดใช้งานรายการโฆษณาหลายรายการ

Java

// Create the line item structure.
LineItem targetLineItem = new LineItem();
targetLineItem.setEntityStatus("ENTITY_STATUS_ACTIVE");

// Create the bulk update request body.
BulkUpdateLineItemsRequest requestBody = new BulkUpdateLineItemsRequest();
requestBody.setLineItemIds(line-item-ids);
requestBody.setTargetLineItem(targetLineItem);
requestBody.setUpdateMask("entityStatus");

// Configure the bulk update request.
LineItems.BulkUpdate request = service.advertisers().lineItems()
    .bulkUpdate(advertiser-id, requestBody);

// Update the line items.
BulkUpdateLineItemsResponse response = request.execute();

// Display the line items that were updated, failed, and skipped.
if (response.getUpdatedLineItemIds() != null) {
  System.out.printf(
      "The following line item IDs were successfully updated: %s.\n",
      Arrays.toString(response.getUpdatedLineItemIds().toArray()));
}
if (response.getFailedLineItemIds() != null) {
  System.out.printf("The following line item IDs failed to update: %s.\n",
      Arrays.toString(response.getFailedLineItemIds().toArray()));
  if (response.getErrors() != null) {
    System.out.printf(
        "The failed updates were caused by the following errors: %s.\n",
        Arrays.toString(response.getErrors().toArray()));
  }
}
if (response.getSkippedLineItemIds() != null) {
  System.out.printf(
      "The following line items IDs were skipped in the update: %s.\n",
      Arrays.toString(response.getSkippedLineItemIds().toArray()));
}

Python

# Create a line item object with only updated entity status.
line_item_obj = {
    'entityStatus': 'ENTITY_STATUS_ACTIVE'
}

# Build the bulk update request.
bulk_update_request = {
    'lineItemIds': line-item-ids,
    'targetLineItem': line_item_obj,
    'updateMask': "entityStatus"
}

# Update the line items.
response = service.advertisers().lineItems().bulkUpdate(
    advertiserId=advertiser-id,
    body=bulk_update_request
).execute()

# Display the line items that were updated, failed, and skipped.
if 'updatedLineItemIds' in response:
  print("The following line item IDs were updated: %s"
        % response['updatedLineItemIds'])
if 'failedLineItemIds' in response:
  print("The following line item IDs failed to update: %s"
        % response['failedLineItemIds'])
  if 'errors' in response:
    print("The failed updates were caused by the following errors:")
    for error in response["errors"]:
      print("Error code: %s, Message: %s" % (error["code"], error["message"]))
if 'skippedLineItemIds' in response:
  print("The following line items IDs were skipped in the update:: %s"
        % response['skippedLineItemIds'])

PHP

// Create request body.
$body = new Google_Service_DisplayVideo_BulkUpdateLineItemsRequest();
$body->setLineItemIds(line-item-ids);

// Create target line item with updated fields.
$lineItem = new Google_Service_DisplayVideo_LineItem();
$lineItem->setEntityStatus('ENTITY_STATUS_ACTIVE');
$body->setTargetLineItem($lineItem);

// Set update mask in request body.
$body->setUpdateMask("entityStatus");

// Call the API, updating the entity status for the identified line item.
$response = $service->advertisers_lineItems->bulkUpdate(
    advertiser-id,
    $body
);

// Display the line items that were updated, failed, and skipped.
if (!empty($response->getUpdatedLineItemIds())) {
    printf('The following line item IDs were updated:\n');
    foreach ($response->getUpdatedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
}
if (!empty($response->getFailedLineItemIds())) {
    print('The following line item IDs failed to update:\n');
    foreach ($response->getFailedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
    if (!empty($response->getErrors())) {
        print('The failed updates were caused by the following errors:\n');
        foreach ($response->getErrors() as $error) {
            printf(
                'Error Code: %s, Message: %s\n',
                $error->getCode(),
                $error->getMessage()
            );
        }
    }
}
if (!empty($response->getSkippedLineItemIds())) {
    print('The following line item IDs were skipped in the update:\n');
    foreach ($response->getSkippedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
}