การกำหนดเป้าหมาย

การจัดการการกำหนดเป้าหมายทรัพยากรเป็นฟีเจอร์หลักของ Display & Video 360 API คุณกําหนดการกําหนดเป้าหมายให้กับทรัพยากรหลายประเภทได้ และใช้ทรัพยากรอื่นๆ และพื้นที่รหัสจํานวนหนึ่ง หน้านี้จะอธิบายข้อจำกัดที่ควรทราบและแนวทางปฏิบัติแนะนำในการนำบริการตัวเลือกการกำหนดเป้าหมายที่กำหนดใน Display & Video 360 API มาใช้

ใช้การรับค่าการกำหนดเป้าหมาย

ทรัพยากรย่อยสามารถรับช่วงการกำหนดเป้าหมายที่กำหนดให้กับทรัพยากรบางรายการได้ คุณสามารถเรียกดูตัวเลือกการกำหนดเป้าหมายที่ทรัพยากรย่อยรับค่ามาได้ แต่จะแก้ไขไม่ได้ในระดับทรัพยากรย่อย ซึ่งจะช่วยให้การตั้งค่าความปลอดภัยของแบรนด์และ การกำหนดเป้าหมายอื่นๆ มีผลบังคับใช้กับพาร์ทเนอร์หรือผู้ลงโฆษณาทั้งหมด

คุณดูเส้นทางการรับช่วงได้ในแผนภาพด้านล่าง

แผนภาพการสืบทอดการกำหนดเป้าหมาย

ตามที่ระบุไว้ในแผนภาพ ระดับการกำหนดเป้าหมายบางระดับรองรับเฉพาะชุดย่อยของ ประเภทการกำหนดเป้าหมาย ซึ่งหมายความว่าคุณไม่สามารถตั้งค่าตัวเลือกการกำหนดเป้าหมายบางอย่างในระดับที่สูงกว่า และรับค่ามาได้ แต่ต้องตั้งค่าในระดับที่ต่ำกว่าแทน

การรับช่วงในแหล่งข้อมูลของ YouTube และพาร์ทเนอร์

การรับค่าการกำหนดเป้าหมายจะไม่แสดงสำหรับแหล่งข้อมูล YouTube และพาร์ทเนอร์ใน Display & Video 360 API การกำหนดเป้าหมายที่กลุ่มโฆษณาได้รับจะไม่สามารถ ดึงข้อมูลได้ในระดับAdGroup และการกำหนดเป้าหมายบน YouTube ที่กำหนดให้กับทรัพยากรหลักจะไม่ได้รับการรับค่าจากทรัพยากรย่อย

หากต้องการดึงการตั้งค่าการกำหนดเป้าหมายที่ใช้งานได้ทั้งหมดสำหรับกลุ่มโฆษณา คุณควรดึงตัวเลือกการกำหนดเป้าหมายที่กำหนดไว้สำหรับกลุ่มโฆษณา รายการโฆษณาหลัก และผู้ลงโฆษณาหลัก

โปรดทราบว่าการกำหนดเป้าหมายจะกำหนดไว้เมื่อสร้างรายการโฆษณา

นอกเหนือจากตัวเลือกการกำหนดเป้าหมายที่รับช่วงมาแล้ว การกำหนดเป้าหมายส่วนใหญ่จะกำหนดได้หลังจากสร้างรายการโฆษณาแล้วเท่านั้น อย่างไรก็ตาม การกำหนดเป้าหมายบางประเภทมี ชุดย่อยของค่าเริ่มต้นที่กำหนดให้กับรายการโฆษณาเมื่อสร้างรายการโฆษณา ประเภทการกำหนดเป้าหมายมีดังนี้

การพยายามสร้างตัวเลือกการกำหนดเป้าหมายที่มีอยู่หรือลบตัวเลือกการกำหนดเป้าหมายที่กำหนดที่ไม่มีอยู่ จะทำให้เกิดข้อผิดพลาด ดังนั้นเราขอแนะนำให้คุณทราบชุดการกำหนดเป้าหมายทั้งหมด ที่กำหนดให้กับรายการโฆษณาเมื่อสร้าง หากต้องการดึงข้อมูล การกำหนดเป้าหมายที่กำหนดให้กับรายการโฆษณาในประเภทการกำหนดเป้าหมายต่างๆ ให้ใช้ advertisers.lineItems.bulkListAssignedTargetingOptions

นอกจากนี้ ระบบจะตั้งค่าบางอย่างโดยค่าเริ่มต้นเมื่อไม่มีการกำหนดตัวเลือกการกำหนดเป้าหมายประเภทนั้นให้กับทรัพยากร เช่น หากทรัพยากรไม่มีตัวเลือกการกำหนดเป้าหมาย TARGETING_TYPE_AUTHORIZED_SELLER_STATUS ที่กำหนดไว้ แสดงว่าทรัพยากรนั้นใช้สถานะ "ผู้ขายและตัวแทนจำหน่ายโดยตรงที่ได้รับอนุญาต"

แก้ไขการกำหนดเป้าหมายของ YouTube และพาร์ทเนอร์ไม่ได้

คุณอัปเดตการกำหนดเป้าหมายสำหรับแคมเปญ YouTube และพาร์ทเนอร์โดยเฉพาะไม่ได้โดยใช้ API ของ Display & Video 360

การกำหนดเป้าหมาย YouTube และพาร์ทเนอร์ประกอบด้วยการกำหนดเป้าหมายทั้งหมดที่กำหนดให้กับ รายการโฆษณา YouTube และพาร์ทเนอร์และกลุ่มโฆษณาโดยตรง รวมถึง การกำหนดเป้าหมายประเภทต่อไปนี้

  • TARGETING_TYPE_SESSION_POSITION
  • TARGETING_TYPE_YOUTUBE_CHANNEL
  • TARGETING_TYPE_YOUTUBE_VIDEO

คุณอัปเดตการกำหนดเป้าหมายนี้ได้โดยใช้ UI ของ Display & Video 360 โดยตรง หรือโดยการอัปโหลดไฟล์ Structured Data

กำหนดการกำหนดกลุ่มเป้าหมายด้วยตัวเลือกเดียว

ระบบจะกําหนดตัวเลือกการกําหนดเป้าหมายสําหรับการกําหนดเป้าหมายประเภทส่วนใหญ่แยกกัน การกำหนดกลุ่มเป้าหมาย ของกลุ่มไม่ได้เป็นไปตามรูปแบบโมดูลาร์นี้ แต่จะกำหนด ในออบเจ็กต์รายละเอียดการกำหนดกลุ่มเป้าหมายเดียวที่กำหนดค่าได้ ซึ่งแสดงรหัสของกลุ่มเป้าหมายที่จะรวมและยกเว้นเมื่อแสดงโฆษณา 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
    );

เตรียมพร้อมสำหรับตัวเลือกการกำหนดเป้าหมายที่จะเลิกใช้งาน

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

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

ดูรายละเอียดเกี่ยวกับการเลิกใช้งานที่สำคัญก่อนหน้านี้และที่กำลังจะเกิดขึ้นได้ที่หน้าการเลิกใช้งานที่ประกาศแล้ว

อย่าส่งคำขอพร้อมกันเพื่ออัปเดตสินค้าในรายการสั่งซื้อเดียวกัน

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

หากต้องการเพิ่มหรือนำตัวเลือกการกำหนดเป้าหมายที่กำหนดหลายรายการสำหรับรายการโฆษณาเดียวออกพร้อมกัน คุณควรใช้คำขอเดียวของ advertisers.lineItems.bulkEditAssignedTargetingOptions หากต้องการอัปเดตการตั้งค่าและการกำหนดเป้าหมายของรายการโฆษณา ให้จัดคิวคำขอ patch หรือ bulkUpdate และคำขอการกำหนดเป้าหมายที่เกี่ยวข้อง เพื่อให้มั่นใจว่าจะไม่มีการส่งคำขอที่ 2 จนกว่าคำขอแรกจะส่งการตอบกลับ