広告申込情報を有効にする

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);
    }
}