指定目標

管理資源指定目標是多媒體和Video 360 API。 指定目標可指派給多個資源類型,並使用多個 其他資源和 ID 空間本頁面詳細資料的限制,以及最適當的 導入多媒體和Video 360 API 指定的指定目標 選擇服務。

使用指定目標沿用設定

子係可以沿用指派給某些資源的指定目標 再複習一下,機構節點 是所有 Google Cloud Platform 資源的根節點子項資源沿用的指定目標選項可供擷取,但 無法在子項資源層級編輯。這樣即可啟用品牌安全設定 以便對整個夥伴或廣告客戶執行的其他指定功能

繼承路徑如下圖所示:

指定目標繼承圖表

如圖表所示,部分指定目標層級只支援部分指定層級 指定類型。這表示部分指定目標選項無法在較高層級設定 但必須在較低層級設定

YouTube 中的繼承設定和合作夥伴資源

YouTube 不會反映沿用指定目標的設定,合作夥伴資源,位於 多媒體和Video 360 API。系統不會沿用廣告群組沿用的指定目標 在 AdGroup 層級和 YouTube 指定目標中可擷取 子項資源不會沿用指派給父項資源。

如要擷取廣告群組的所有功能指定設定, 應該擷取 廣告群組的指定選項, 上層委刊項和上層廣告客戶

瞭解在建立委刊項時指派的指定目標

除了沿用的指定目標選項以外,大多數的指定目標只能指派 建立委刊項後不過,某些指定類型 建立委刊項時指派給委刊項的預設值組合這些 指定類型為:

嘗試建立或刪除非現有指派的指定目標選項 傳回錯誤,因此建議您瞭解完整的指定套件 委刊項會在建立時指派給委刊項如果您需要擷取 不同指定類型中指派給某個委刊項的指定目標 advertisers.lineItems.bulkListAssignedTargetingOptions

此外,有些設定是在沒有指定目標選項的情況下預設 類型會指派給資源舉例來說,如果資源並未 TARGETING_TYPE_AUTHORIZED_SELLER_STATUS敬上 這表示該選項採用「授權直接交易」 賣家和經銷商」狀態。

不會預期自動「預設指定目標」

多媒體和在廣告活動或廣告訂單層級設定的 Video 360 指定目標為 不會立即傳給下層委刊項這種指定目標稱為 「預設指定目標」並做為指定範本 才會套用到後續在 UI 中建立的委刊項

多媒體廣告和Video 360 API,系統不會自動將預設指定目標套用到新指標 建立的委刊項建立基本委刊項時,系統不會複製任何廣告活動 或廣告訂單層級指定目標在這種情況下,想要的指定目標必須是 透過指派的指定目標選項,個別套用到委刊項 建立大量編輯方法。

特殊方法可以是例外狀況。例如,透過 複製「advertisers.lineItems.generateDefault」 設定,包括指派的指定目標。 同樣地,透過複製功能建立的委刊項會獲派 與原始委刊項相同的指定目標

YouTube 和無法修改夥伴指定目標

指定 YouTube 和合作夥伴廣告活動無法使用 多媒體和Video 360 API。

YouTube 和合作夥伴的指定目標包括直接指派給 YouTube 和夥伴委刊項和廣告群組,以及 下列任一指定類型:

  • TARGETING_TYPE_SESSION_POSITION
  • TARGETING_TYPE_YOUTUBE_CHANNEL
  • TARGETING_TYPE_YOUTUBE_VIDEO

這個指定目標可使用「多媒體和影片廣告」選項來更新Video 360 UI 上傳結構化資料檔案

透過單一選項指定目標對象

系統會分別指派大部分指定類型的指定目標選項。目標對象 群組指定不遵循這個模組化慣例,而是指派為 在單一 Deployment 中 目標對象區隔指定詳細資料物件,該物件會列出 放送廣告時要納入和排除的目標對象 ID。 適用於這個目標對象群組選項的 assignedTargetingOptionId, 指派後一律為「audienceGroup」。

也就是說,如要變更指定目標對象群組,就必須在 請先刪除已指派的現有目標對象群組 指定目標選項,然後建立新的目標對象群組 所需的變更這項功能可透過單一要求 使用 advertisers.lineItems.bulkEditAssignedTargetingOptions

以下範例說明如何更新指定目標對象 指定其他 Google 目標對象:

Java

long advertiserId = advertiser-id;
long lineItemId = line-item-id
List<Long> addedGoogleAudienceIds =
    Arrays.asList(google-audience-id-to-add,...);

// Build Google audience targeting settings objects to add to audience
// targeting.
ArrayList<GoogleAudienceTargetingSetting> newGoogleAudienceSettings =
    new ArrayList<GoogleAudienceTargetingSetting>();

// Convert list of Google Audience IDs into list of settings.
for (Long googleAudienceId : addedGoogleAudienceIds) {
  newGoogleAudienceSettings.add(new GoogleAudienceTargetingSetting()
      .setGoogleAudienceId(googleAudienceId));
}

// Create relevant bulk edit request objects.
BulkEditLineItemAssignedTargetingOptionsRequest requestContent =
    new BulkEditLineItemAssignedTargetingOptionsRequest();
AudienceGroupAssignedTargetingOptionDetails updatedAudienceGroupDetails;
ArrayList<DeleteAssignedTargetingOptionsRequest> audienceGroupDeleteRequests =
    new ArrayList<DeleteAssignedTargetingOptionsRequest>();

try {
  // Retrieve existing audience group targeting.
  AssignedTargetingOption existingAudienceGroupTargetingOption =
      service
          .advertisers()
          .lineItems()
          .targetingTypes()
          .assignedTargetingOptions()
          .get(
              advertiserId,
              lineItemId,
              "TARGETING_TYPE_AUDIENCE_GROUP",
              "audienceGroup"
          ).execute();

  // Extract existing audience group targeting details.
  updatedAudienceGroupDetails =
      existingAudienceGroupTargetingOption.getAudienceGroupDetails();

  // Build and add delete request for existing audience group targeting.
  ArrayList<String> deleteAudienceGroupAssignedTargetingIds =
      new ArrayList<String>();
  deleteAudienceGroupAssignedTargetingIds.add("audienceGroup");

  audienceGroupDeleteRequests
      .add(new DeleteAssignedTargetingOptionsRequest()
          .setTargetingType("TARGETING_TYPE_AUDIENCE_GROUP")
          .setAssignedTargetingOptionIds(
              deleteAudienceGroupAssignedTargetingIds
          )
      );
}
catch (GoogleJsonResponseException e) {
  updatedAudienceGroupDetails =
      new AudienceGroupAssignedTargetingOptionDetails();
}

// Set delete requests in edit request.
requestContent.setDeleteRequests(audienceGroupDeleteRequests);

// Construct new group of Google Audiences to include in targeting.
GoogleAudienceGroup updatedIncludedGoogleAudienceGroup =
    updatedAudienceGroupDetails.getIncludedGoogleAudienceGroup();
if (updatedIncludedGoogleAudienceGroup != null) {
  List<GoogleAudienceTargetingSetting> updatedGoogleAudienceSettings =
      updatedIncludedGoogleAudienceGroup.getSettings();
  updatedGoogleAudienceSettings.addAll(newGoogleAudienceSettings);
  updatedIncludedGoogleAudienceGroup
      .setSettings(updatedGoogleAudienceSettings);
} else {
  updatedIncludedGoogleAudienceGroup = new GoogleAudienceGroup();
  updatedIncludedGoogleAudienceGroup.setSettings(newGoogleAudienceSettings);
}

// Add new Google Audience group to audience group targeting details.
updatedAudienceGroupDetails
    .setIncludedGoogleAudienceGroup(updatedIncludedGoogleAudienceGroup);

// Create new targeting option to assign.
AssignedTargetingOption newAudienceGroupTargeting =
    new AssignedTargetingOption();
newAudienceGroupTargeting
    .setAudienceGroupDetails(updatedAudienceGroupDetails);

// Build audience group targeting create request and add to list of create
// requests.
ArrayList<AssignedTargetingOption> createAudienceGroupAssignedTargetingOptions =
    new ArrayList<AssignedTargetingOption>();
createAudienceGroupAssignedTargetingOptions.add(newAudienceGroupTargeting);
ArrayList<CreateAssignedTargetingOptionsRequest> targetingCreateRequests =
    new ArrayList<CreateAssignedTargetingOptionsRequest>();
targetingCreateRequests.add(new CreateAssignedTargetingOptionsRequest()
    .setTargetingType("TARGETING_TYPE_AUDIENCE_GROUP")
    .setAssignedTargetingOptions(
        createAudienceGroupAssignedTargetingOptions
    )
);

// Set create requests in edit request.
requestContent.setCreateRequests(targetingCreateRequests);

// Configure and execute the bulk list request.
BulkEditLineItemAssignedTargetingOptionsResponse response =
    service.advertisers().lineItems()
        .bulkEditLineItemAssignedTargetingOptions(
            advertiserId,
            lineItemId,
            requestContent).execute();

Python

advertiser_id = advertiser-id
line_item_id = line-item-id
added_google_audiences = [google-audience-id-to-add,...]

# Build Google audience targeting settings objects to create.
new_google_audience_targeting_settings = []
for google_audience_id in added_google_audiences:
 new_google_audience_targeting_settings.append(
     {'googleAudienceId': google_audience_id}
 )

# Retrieve any existing line item audience targeting.
retrieved_audience_targeting = service.advertisers().lineItems(
).targetingTypes().assignedTargetingOptions().get(
   advertiserId=advertiser_id,
   lineItemId=line_item_id,
   targetingType="TARGETING_TYPE_AUDIENCE_GROUP",
   assignedTargetingOptionId="audienceGroup"
).execute()

updated_audience_group_details = {}

# Copy over any existing audience targeting.
if 'audienceGroupDetails' in retrieved_audience_targeting:
 updated_audience_group_details = retrieved_audience_targeting[
     'audienceGroupDetails']

# Append the new Google audience IDs to any existing positive Google
# audience targeting.
if 'includedGoogleAudienceGroup' in updated_audience_group_details:
 updated_audience_group_details[
     'includedGoogleAudienceGroup']['settings'].extend(
         new_google_audience_targeting_settings)
else:
 updated_audience_group_details['includedGoogleAudienceGroup'] = {
     'settings': new_google_audience_targeting_settings
 }

# Build bulk edit request.
bulk_edit_request = {
   'deleteRequests': [
       {
         'targetingType': "TARGETING_TYPE_AUDIENCE_GROUP",
         'assignedTargetingOptionIds': [
           "audienceGroup"
         ]
       }
   ],
   'createRequests': [
       {
           'targetingType': "TARGETING_TYPE_AUDIENCE_GROUP",
           'assignedTargetingOptions': [
               {'audienceGroupDetails': updated_audience_group_details}
           ]
       }
   ]
}

# Update the audience targeting
updated_audience_targeting = service.advertisers().lineItems(
).bulkEditLineItemAssignedTargetingOptions(
   advertiserId=advertiser_id,
   lineItemId=line_item_id,
   body=bulk_edit_request
).execute()

PHP

$advertiserId = advertiser-id;
$lineItemId = line-item-id;
$addedGoogleAudienceIds = array(google-audience-id-to-add,...);

// Convert list of Google Audience IDs into list of Google audience
// settings.
$newGoogleAudienceSettings = array();
foreach ($addedGoogleAudienceIds as $googleAudienceId) {
    $newSetting =
        new Google_Service_DisplayVideo_GoogleAudienceTargetingSetting();
    $newSetting->setGoogleAudienceId($googleAudienceId);
    $newGoogleAudienceSettings[] = $newSetting;
}

// Create a bulk edit request.
$requestBody =
    new Google_Service_DisplayVideo_BulkEditLineItemAssignedTargetingOptionsRequest();

$audienceGroupDeleteRequests = array();

try {
    // Retrieve existing audience group targeting.
    $existingAudienceGroupTargetingOption = $this
        ->service
        ->advertisers_lineItems_targetingTypes_assignedTargetingOptions
        ->get(
            $advertiserId,
            $lineItemId,
            'TARGETING_TYPE_AUDIENCE_GROUP',
            'audienceGroup'
        );

    // Extract existing audience group targeting details.
    $updatedAudienceGroupDetails =
        $existingAudienceGroupTargetingOption
            ->getAudienceGroupDetails();

    // Build and add delete request for existing audience group
    // targeting.
    $deleteAudienceGroupAssignedTargetingIds = array();
    $deleteAudienceGroupAssignedTargetingIds[] = "audienceGroup";

    $audienceGroupDeleteRequest =
        new Google_Service_DisplayVideo_DeleteAssignedTargetingOptionsRequest();
    $audienceGroupDeleteRequest
        ->setTargetingType('TARGETING_TYPE_AUDIENCE_GROUP');
    $audienceGroupDeleteRequest
        ->setAssignedTargetingOptionIds(
            $deleteAudienceGroupAssignedTargetingIds
        );
    $audienceGroupDeleteRequests[] = $audienceGroupDeleteRequest;
} catch (\Exception $e) {
    $updatedAudienceGroupDetails =
        new Google_Service_DisplayVideo_AudienceGroupAssignedTargetingOptionDetails();
}

// Set delete requests in edit request.
$requestBody->setDeleteRequests($audienceGroupDeleteRequests);

// Construct new group of Google audiences to include in targeting.
$updatedIncludedGoogleAudienceGroup = $updatedAudienceGroupDetails
    ->getIncludedGoogleAudienceGroup();

if (!empty($updatedIncludedGoogleAudienceGroup)) {
    // Get existing settings.
    $updatedGoogleAudienceSettings =
    $updatedIncludedGoogleAudienceGroup->getSettings();

    // Add new Google audiences to existing list.
    $updatedGoogleAudienceSettings = array_merge(
        $updatedGoogleAudienceSettings,
        $newGoogleAudienceSettings
    );

    // Set updated Google audience list.
    $updatedIncludedGoogleAudienceGroup
        ->setSettings($updatedGoogleAudienceSettings);
} else {
    // Create new Google audience group.
    $updatedIncludedGoogleAudienceGroup =
        new Google_Service_DisplayVideo_GoogleAudienceGroup();

    // Set list of new Google audiences for targeting.
    $updatedIncludedGoogleAudienceGroup
        ->setSettings($newGoogleAudienceSettings);
}

// Add new Google Audience group to audience group targeting details.
$updatedAudienceGroupDetails
    ->setIncludedGoogleAudienceGroup(
        $updatedIncludedGoogleAudienceGroup
    );

// Create new targeting option to assign.
$newAudienceGroupTargeting =
    new Google_Service_DisplayVideo_AssignedTargetingOption();
$newAudienceGroupTargeting
    ->setAudienceGroupDetails($updatedAudienceGroupDetails);

// Build audience group targeting create request and add to list of
// create requests.
$createAudienceGroupAssignedTargetingOptions = array();
$createAudienceGroupAssignedTargetingOptions[] =
    $newAudienceGroupTargeting;
$createAudienceGroupTargetingRequest =
    new Google_Service_DisplayVideo_CreateAssignedTargetingOptionsRequest();
$createAudienceGroupTargetingRequest->setTargetingType(
    "TARGETING_TYPE_AUDIENCE_GROUP"
);
$createAudienceGroupTargetingRequest->setAssignedTargetingOptions(
    $createAudienceGroupAssignedTargetingOptions
);
$createRequests[] = $createAudienceGroupTargetingRequest;

// Set create requests in edit request.
$requestBody->setCreateRequests($createRequests);

// Call the API, editing the assigned targeting options for the
// identified line item.
$response = $this
    ->service
    ->advertisers_lineItems
    ->bulkEditLineItemAssignedTargetingOptions(
        $advertiserId,
        $lineItemId,
        $requestBody
    );

為即將淘汰的指定目標選項做好準備

這些指定目標選項不是固定的,且有一小部分可能會隨時淘汰 。指定目標選項在淘汰後不會影響委刊項的廣告 放送。選項淘汰後,這些選項將從現有行中取消指派 若項目和要求試圖擷取或指派這些選項,就會導致 發生錯誤。

為避免這些錯誤,建議您定期檢查儲存的項目 指定目標選項 ID為了節省配額,建議您 定期使用的 ID:但儲存 ID 表示 指定目標選項已淘汰因此,您應該 定期使用 targetingOptions.targetingTypes.get: 擷取所有已儲存的指定目標選項 ID,確認這些 ID 仍然有效 (Display &Video 360) 中Video 360。

請參閱「宣布淘汰項目」頁面,瞭解重要的 瞭解舊版和即將淘汰的功能

請勿同時提出更新相同委刊項的要求

嘗試更新單一委刊項的設定或指派指定目標 使用多個並行要求會傳回錯誤。適用的要求 包括:

如果需要為單一請求新增或移除多個指定的指定目標選項 建議您同時使用單一委刊項 advertisers.lineItems.bulkEditAssignedTargetingOptions敬上 請求。如要更新委刊項的設定和指定目標,請將委刊項排入佇列 patchbulkUpdate 要求和相關 確保第二個請求不會在 會傳回回應。