Đặt tiêu chí nhắm mục tiêu

Tuỳ chọn nhắm mục tiêu, Tuỳ chọn nhắm mục tiêu được chỉ định và Tất cả các dịch vụ mục hàng đều được dùng cùng để đặt Nhắm mục tiêu mục hàng trong cột Hiển thị API Video 360. Trang này mô tả và cung cấp các ví dụ về cách tìm các tuỳ chọn nhắm mục tiêu có sẵn, chỉ định các tuỳ chọn nhắm mục tiêu cho dòng mục hàng và thực hiện thao tác hàng loạt trên mục hàng để liệt kê và chỉnh sửa mục đã chỉ định tùy chọn nhắm mục tiêu.

Tìm các lựa chọn nhắm mục tiêu có sẵn

Tùy chọn nhắm mục tiêu sử dụng biến do người dùng chỉ định, có thể nhắm mục tiêu hiện có thực thể hoặc các tuỳ chọn có sẵn để xác định đối tượng mục tiêu mong muốn. Các tuỳ chọn hiện có được xác định bằng cách sử dụng giá trị enum hoặc tuỳ chọn nhắm mục tiêu ID, tùy thuộc vào loại nhắm mục tiêu. Các đối tượng có thể nhắm mục tiêu được xác định bằng cách sử dụng mã nhận dạng thực thể của chúng. Bạn có thể tìm thấy mã tùy chọn nhắm mục tiêu và mã nhận dạng thực thể bằng cách sử dụng Hiển thị và API Video 360.

Dùng các giá trị enum

Tùy chọn nhắm mục tiêu cho các loại nhắm mục tiêu sau đây được chỉ định bằng cách sử dụng các loại enum cụ thể:

TargetingType Enum
TARGETING_TYPE_AGE_RANGE AgeRange
TARGETING_TYPE_CONTENT_INSTREAM_POSITION ContentInstreamPosition
TARGETING_TYPE_CONTENT_OUTSTREAM_POSITION ContentOutstreamPosition
TARGETING_TYPE_DEVICE_TYPE DeviceType
TARGETING_TYPE_DIGITAL_CONTENT_LABEL_EXCLUSION ContentRatingTier
TARGETING_TYPE_ENVIRONMENT Environment
TARGETING_TYPE_EXCHANGE Exchange
TARGETING_TYPE_GENDER Gender
TARGETING_TYPE_HOUSEHOLD_INCOME HouseholdIncome
TARGETING_TYPE_NATIVE_CONTENT_POSITION NativeContentPosition
TARGETING_TYPE_OMID Omid
TARGETING_TYPE_PARENTAL_STATUS ParentalStatus
TARGETING_TYPE_SENSITIVE_CATEGORY_EXCLUSION SensitiveCategory
TARGETING_TYPE_VIDEO_PLAYER_SIZE VideoPlayerSize
TARGETING_TYPE_VIEWABILITY Viewability

Bạn có thể dùng phiên bản chuỗi của giá trị enum có liên quan để xác định giá trị hiện có AssignedTargetingOption tài nguyên của các loại nhắm mục tiêu này và là có sẵn trong trường assignedTargetingOptionIdAlias. Bạn có thể sử dụng giá trị bí danh này thay cho assignedTargetingOptionId khi truy xuất hoặc xoá tuỳ chọn nhắm mục tiêu được chỉ định.

Truy xuất ID tùy chọn nhắm mục tiêu

Các loại nhắm mục tiêu sử dụng tùy chọn có sẵn được chỉ định bằng cách sử dụng các tùy chọn tương ứng mã tuỳ chọn nhắm mục tiêu.

Ví dụ: có một số lượng vị trí trên màn hình hữu hạn có thể được nhắm mục tiêu bằng cách sử dụng loại nhắm mục tiêu TARGETING_TYPE_ON_SCREEN_POSITION. Một trong số các vị trí này có ID tùy chọn nhắm mục tiêu tương ứng.

Bạn có thể truy xuất các mã lựa chọn nhắm mục tiêu này thông qua Dịch vụ Tùy chọn nhắm mục tiêu. Tuỳ thuộc vào loại nhắm mục tiêu, việc truy xuất được thực hiện theo một trong hai cách:

  • Truy xuất riêng lẻ hoặc danh sách đầy đủ: Truy xuất các tuỳ chọn cho phần lớn các loại nhắm mục tiêu có thể được thực hiện bằng cách sử dụng phương pháp getlist. Sử dụng targetingTypes.targetingOptions.get để truy xuất thông tin chi tiết về tùy chọn nhắm mục tiêu được xác định theo loại nhắm mục tiêu và mã tùy chọn nhắm mục tiêu. Sử dụng targetingTypes.targetingOptions.list để liệt kê tất cả các trang có sẵn tùy chọn nhắm mục tiêu của một loại nhắm mục tiêu nhất định.
  • Tìm kiếm: Các lựa chọn cho các loại nhắm mục tiêu dựa trên vị trí (TARGETING_TYPE_GEO_REGION, TARGETING_TYPE_POITARGETING_TYPE_BUSINESS_CHAIN) phải được truy xuất bằng phương thức search. Sử dụng targetingTypes.targetingOptions.search để truy xuất tùy chọn nhắm mục tiêu của một loại nhất định phù hợp với chuỗi truy vấn nhất định.

Dưới đây là ví dụ về cách lấy danh sách các tiêu chí nhắm mục tiêu có thể có tùy chọn cho loại nhắm mục tiêu TARGETING_TYPE_BROWSER:

Java

// Configure the list request.
TargetingOptions.List request =
   service
       .targetingTypes()
       .targetingOptions()
       .list("TARGETING_TYPE_BROWSER")
       .setAdvertiserId(advertiser-id);

// Create the response and nextPageToken variables.
ListTargetingOptionsResponse response;
String nextPageToken = null;

do {
 // Create and execute the list request.
 response = request.setPageToken(nextPageToken).execute();

 // Check if the response is empty.
 if (response.isEmpty()) {
   System.out.print("List request returned no Targeting Options");
   break;
 }

 // Iterate over retrieved targeting options.
 for (TargetingOption option : response.getTargetingOptions()) {
   System.out.printf(
       "Targeting Option ID: %s, Browser Display Name: '%s'\n",
       option.getTargetingOptionId(), option.getBrowserDetails().getDisplayName());
 }

 // Update the next page token.
 nextPageToken = response.getNextPageToken();
} while (!Strings.isNullOrEmpty(nextPageToken));

Python

# Create the page token variable.
next_page_token = ""

while True:
  # Request the targeting options list.
  response = service.targetingTypes() \
    .targetingOptions().list(
      advertiserId=advertiser-id,
      targetingType="TARGETING_TYPE_BROWSER",
      pageToken=next_page_token
  ).execute()

  # Check if response is empty.
  if not response:
    print("List request returned no Targeting Options")
    break

  # Iterate over retrieved targeting options.
  for option in response['targetingOptions']:
    print("Targeting Option ID: %s, Browser Display Name: %s"
          % (option['targetingOptionId'], option['browserDetails']['displayName']))

  # Break out of loop if there is no next page.
  if 'nextPageToken' not in response:
    break

  # Update the next page token.
  next_page_token = response['nextPageToken']

PHP

// Create the page token variable.
$nextPageToken = null;

do {
    // Build the query parameters object for the request.
    $optParams = array(
        'advertiserId' => advertiser-id,
        'pageToken' => $nextPageToken
    );

    // Call the API, getting the browser targeting options for the
    // identified advertiser.
    $response = $this
        ->service
        ->targetingTypes_targetingOptions
        ->listTargetingTypesTargetingOptions(
            'TARGETING_TYPE_BROWSER',
            $optParams
        );

    // Print the resulting targeting options.
    if (!empty($response->getTargetingOptions())) {
        foreach ($response->getTargetingOptions() as $option) {
            printf(
                'Targeting Option ID: %s, Browser Display Name: %s\n',
                $option['targetingOptionId'],
                $option['browserDetails']['displayName']
            );
        }
    } else {
        print('No targeting options returned\n');
    }

    // Update the next page token.
    $nextPageToken = $response->getNextPageToken();
} while (
    !empty($response->getTargetingOptions())
    && $nextPageToken
);

Liệt kê các thực thể có thể nhắm mục tiêu

Để nhắm mục tiêu mục hàng bằng thực thể có thể nhắm mục tiêu hiện có, bạn cần mã nhận dạng của thực thể đó. Các thực thể có thể nhắm mục tiêu, chẳng hạn như kênh, đối tượng kết hợp, và các nhóm nguồn khoảng không quảng cáo, có thể truy xuất được thông qua dịch vụ của riêng họ trong quảng cáo Hiển thị và API Video 360.

Mỗi dịch vụ có các phương thức getlist riêng. Sử dụng phương thức get để xác nhận rằng pháp nhân thuộc một nhà quảng cáo nhất định. Sử dụng list để khám phá tất cả các thực thể thuộc loại tài nguyên đó có sẵn cho nhà quảng cáo cụ thể và từ đó có thể dùng để chỉ định nhắm mục tiêu cho cho mục hàng của nhà quảng cáo đó.

Bạn cũng có thể quản lý một tập hợp con các đối tượng có thể nhắm mục tiêu thông qua API. Đây là được thực hiện thông qua các phương thức createpatch trong dịch vụ tương ứng, như cũng như các dịch vụ cho những giá trị riêng lẻ được liệt kê trong các thực thể, chẳng hạn như nguồn khoảng không quảng cáo, từ khoá phủ địnhvị trí.

Tạo mã lựa chọn nhắm mục tiêu địa điểm yêu thích

Tùy chọn nhắm mục tiêu địa điểm yêu thích được đặt tên, dưới TARGETING_TYPE_POI có thể được truy xuất bằng targetingTypes.targetingOptions.search. Trong Ngoài ra, bạn có thể tạo mã tuỳ chọn nhắm mục tiêu TARGETING_TYPE_POI riêng để nhắm mục tiêu theo toạ độ vĩ độ-kinh độ cụ thể.

Hãy làm theo các bước sau để tạo mã tuỳ chọn nhắm mục tiêu POI:

  1. Lấy toạ độ vĩ độ – kinh độ (ví dụ: "40.7414691, -74.003387")
  2. Giá trị toạ độ làm tròn đến vị trí thập phân thứ 6 (ví dụ: "40,741469, -74,003387")
  3. Xoá chữ số thập phân khỏi giá trị toạ độ (ví dụ: "40741469, -74003387")
  4. Nối hai giá trị này để tạo thành một chuỗi, phân tách bằng dấu chấm phẩy (ví dụ: "40741469;-74003387")

Chuỗi kết quả có thể được dùng làm targetingOptionId khi tạo một TARGETING_TYPE_POI được chỉ định tùy chọn nhắm mục tiêu.

Khi được tạo, các trường targetingOptionIdassignedTargetingOptionId của tài nguyên tùy chọn nhắm mục tiêu được chỉ định sẽ được cập nhật, thêm dấu chấm phẩy và hàm băm bao gồm chữ và số.

Chỉ định một tuỳ chọn nhắm mục tiêu

Tiêu chí nhắm mục tiêu được chỉ định cho một mục hàng được thể hiện dưới dạng Tuỳ chọn nhắm mục tiêu được chỉ định. Bạn có thể quản lý các thực thể này bằng cách sử dụng Dịch vụ Tùy chọn nhắm mục tiêu được chỉ định. Việc tạo tùy chọn nhắm mục tiêu được chỉ định sẽ áp dụng các chi tiết nhắm mục tiêu đó cho mục hàng gốc. Việc xóa tùy chọn nhắm mục tiêu được chỉ định hiện tại sẽ xóa nhắm mục tiêu.

Sử dụng advertisers.lineItems.targetingTypes.assignedTargetingOptions.create để tạo tuỳ chọn nhắm mục tiêu được chỉ định. Xác định các thông số nhắm mục tiêu trong Trường details của tài nguyên tuỳ chọn nhắm mục tiêu được chỉ định tương ứng với loại nhắm mục tiêu dự kiến.

Dưới đây là ví dụ về cách tạo tuỳ chọn nhắm mục tiêu được chỉ định của loại nhắm mục tiêu TARGETING_TYPE_BROWSER:

Java

// Create an AssignedTargetingOption object of the
// browser targeting type.
AssignedTargetingOption assignedTargetingOption =
   new AssignedTargetingOption()
       .setBrowserDetails(
           new BrowserAssignedTargetingOptionDetails()
               .setTargetingOptionId(targeting-option-id));

// Configure the create request.
AssignedTargetingOptions.Create request =
   service
       .advertisers()
       .lineItems()
       .targetingTypes()
       .assignedTargetingOptions()
       .create(
           advertiser-id,
           line-item-id,
           "TARGETING_TYPE_BROWSER",
           assignedTargetingOption);

// Send the request.
AssignedTargetingOption response = request.execute();

// Display the new assigned targeting option.
System.out.printf("AssignedTargetingOption %s was created.",
   response.getName());

Python

# Create a assigned targeting option object.
assigned_targeting_option_obj = {
    'browserDetails': {
        'targetingOptionId': targeting-option-id
    }
}

# Create the assigned targeting option.
assigned_targeting_option = service.advertisers().lineItems()\
  .targetingTypes().assignedTargetingOptions().create(
    advertiserId=advertiser-id,
    lineItemId=line-item-id,
    targetingType="TARGETING_TYPE_BROWSER",
    body=assigned_targeting_option_obj
).execute()

# Display the new assigned targeting option.
print("Assigned Targeting Option %s was created."
      % assigned_targeting_option["name"])

PHP

// Create a assigned targeting option object.
$assignedTargetingOption =
    new Google_Service_DisplayVideo_AssignedTargetingOption();

// Create and set browser details.
$details =
    new Google_Service_DisplayVideo_BrowserAssignedTargetingOptionDetails();
$details->setTargetingOptionId(targeting-option-id);
$assignedTargetingOption->setBrowserDetails($details);

// Call the API, creating the browser assigned targeting option for the
// given line item.
$result = $this
    ->service
    ->advertisers_lineItems_targetingTypes_assignedTargetingOptions
    ->create(
        advertiser-id,
        line-item-id,
        'TARGETING_TYPE_BROWSER',
        $assignedTargetingOption
    );

printf(
    'Assigned Targeting Option %s was created.\n',
    $result['name']
);

Lỗi

Lỗi cấu hình nhắm mục tiêu

Có một số quy tắc phức tạp liên quan đến nhắm mục tiêu trong Mạng Hiển thị và Video 360. Các chính sách này được thực thi trong màn hình và Video 360 API thông qua các lỗi được trả về khi tạo tuỳ chọn nhắm mục tiêu được chỉ định. Lỗi mà API trả về sẽ nêu rõ lỗi vi phạm.

Lỗi chủ yếu là do tiêu chí nhắm mục tiêu hiện có được chỉ định cho một mục hàng. Sử dụng advertisers.lineItems.targetingTypes.assignedTargetingOptions.list để truy xuất tất cả các tùy chọn nhắm mục tiêu của một loại nhắm mục tiêu nhất định được chỉ định cho một dòng đánh giá xem liệu có thể nhắm mục tiêu mong muốn hay không với các giới hạn, và sử dụng advertisers.lineItems.targetingTypes.assignedTargetingOptions.delete để xóa bất kỳ nhắm mục tiêu không mong muốn nào trước khi cố gắng tạo lại tùy chọn nhắm mục tiêu được chỉ định.

YouTube và Lỗi nhắm mục tiêu đối tác

Nhắm mục tiêu cụ thể cho YouTube & Bạn không thể cập nhật chiến dịch của Đối tác bằng màn hình và Video 360 API và cố gắng làm như vậy sẽ dẫn đến lỗi.

YouTube và Nhắm mục tiêu đối tác bao gồm tất cả nhắm mục tiêu được chỉ định trực tiếp cho YouTube và Mục hàng của Đối tác và Nhóm quảng cáo, cũng như bất kỳ tiêu chí nhắm mục tiêu nào thuộc các loại nhắm mục tiêu sau đây:

  • TARGETING_TYPE_SESSION_POSITION
  • TARGETING_TYPE_YOUTUBE_CHANNEL
  • TARGETING_TYPE_YOUTUBE_VIDEO

Lỗi đồng thời

Tìm cách cập nhật chế độ cài đặt hoặc tiêu chí nhắm mục tiêu của một mục hàng thông qua nhiều yêu cầu đồng thời sẽ dẫn đến lỗi.

Nếu bạn cần thêm hoặc xóa nhiều tùy chọn nhắm mục tiêu được chỉ định cho một cùng một lúc, bạn nên sử dụng yêu cầu chỉnh sửa hàng loạt. Nếu bạn muốn cập nhật cài đặt và nhắm mục tiêu, hãy advertisers.lineItems.patch và yêu cầu nhắm mục tiêu có liên quan để đảm bảo lần thứ hai yêu cầu sẽ không được gửi cho đến khi yêu cầu đầu tiên trả về phản hồi.

Hoạt động nhắm mục tiêu hàng loạt và trên toàn tài nguyên

Bạn có thể sử dụng phương pháp nhắm mục tiêu hàng loạttrên toàn tài nguyên để quản lý các phương pháp nhắm mục tiêu đã chỉ định tùy chọn nhắm mục tiêu trên các loại nhắm mục tiêu:

  • Sử dụng phương pháp nhắm mục tiêu hàng loạt để truy xuất hoặc chỉnh sửa các tùy chọn nhắm mục tiêu trên nhiều loại nhắm mục tiêu và trong nhiều tài nguyên. Bạn có thể truy xuất cấu hình nhắm mục tiêu đầy đủ của nhiều mục hàng đang sử dụng advertisers.lineItems.bulkListAssignedTargetingOptions hoặc cập nhật giống hệt với tiêu chí nhắm mục tiêu trên nhiều mục hàng bằng cách sử dụng advertisers.lineItems.bulkEditAssignedTargetingOptions. Những nội dung này chỉ có trong advertisers.lineItems .
  • Sử dụng Phương pháp nhắm mục tiêu trên toàn tài nguyên để truy xuất hoặc chỉnh sửa các lựa chọn nhắm mục tiêu trên nhiều loại nhắm mục tiêu trong một tài nguyên duy nhất. Có các trong partners, advertisers, advertisers.campaignsadvertisers.insertionOrders dịch vụ và được đặt tên listAssignedTargetingOptions hoặc editAssignedTargetingOptions.

Nếu bạn muốn có cái nhìn đầy đủ về nhắm mục tiêu hiện tại của mục hàng, hãy áp dụng cấu hình nhắm mục tiêu được đặt sẵn cho một mục hàng hoặc cần thực hiện nhiều thay đổi đến nhắm mục tiêu của một mục hàng, hãy cân nhắc sử dụng các tiêu chí nhắm mục tiêu này .

Nhắm mục tiêu danh sách hàng loạt

advertisers.lineItems.bulkListAssignedTargetingOptions cung cấp một cách xem tất cả tiêu chí nhắm mục tiêu được chỉ định cho một hoặc nhiều mục hàng trên nhiều loại nhắm mục tiêu. API này hoạt động tương tự như mọi list khác . Bạn có thể dùng tham số truy vấn filter để lọc kết quả theo TargetingType hoặc Inheritance.

Dưới đây là ví dụ về cách liệt kê tất cả các tuỳ chọn nhắm mục tiêu được chỉ định cho một mục hàng mà đối tác hoặc nhà quảng cáo mẹ kế thừa:

Java

// Configure the bulk list request.
LineItems.BulkListAssignedTargetingOptions request =
    service.advertisers().lineItems()
        .bulkListAssignedTargetingOptions(advertiser-id);

// Set Line Items to retrieve targeting for.
request.setLineItemIds(line-item-ids);

// Set filter to only return inherited assigned targeting options.
request.setFilter(
    "inheritance=\"INHERITED_FROM_ADVERTISER\" OR inheritance=\"INHERITED_FROM_PARTNER\"");

// Create the response and nextPageToken variables.
BulkListAssignedTargetingOptionsResponse response;
String nextPageToken = null;

do {
  // Set page token and execute the list request.
  response = request.setPageToken(nextPageToken).execute();

  // Check if the response is empty.
  if (response.isEmpty()) {
    System.out.print("Bulk list request returned no Assigned Targeting Options");
    break;
  }

  // Iterate over retrieved line item assigned targeting option wrapper objects.
  for (LineItemAssignedTargetingOption lineItemAssignedTargetingOption
      : response.getLineItemAssignedTargetingOptions()) {
    System.out.printf(
        "Assigned Targeting Option %s found\n",
        lineItemAssignedTargetingOption.getAssignedTargetingOption().getName());
  }

  // Update the next page token.
  nextPageToken = response.getNextPageToken();
} while (!Strings.isNullOrEmpty(nextPageToken));

Python

# Create the page token variable.
next_page_token = ""

while True:
  # Execute the list request.
  response = service.advertisers().lineItems() \
    .bulkListAssignedTargetingOptions(
      advertiserId=advertiser-id,
      lineItemIds=line-item-ids,
      filter="inheritance=\"INHERITED_FROM_ADVERTISER\" OR "
             "inheritance=\"INHERITED_FROM_PARTNER\"",
      pageToken=next_page_token
  ).execute()

  # Check if response is empty.
  if not response:
    print("Bulk list request returned no Assigned Targeting Options")
    break

  # Iterate over retrieved assigned targeting options.
  for lineItemAssignedTargetingOption in response['lineItemAssignedTargetingOptions']:
    print("Assigned Targeting Option %s found"
          % (lineItemAssignedTargetingOption['assignedTargetingOption']['name']))

  # Break out of loop if there is no next page.
  if 'nextPageToken' not in response:
    break

  # Update the next page token.
  next_page_token = response['nextPageToken']

PHP

// Create the page token variable.
$nextPageToken = null;

do {
    // Build the query parameters object for the request.
    $optParams = array(
        'lineItemIds' => line-item-ids,
        'filter' => "inheritance=\"INHERITED_FROM_ADVERTISER\" OR "
            . "inheritance=\"INHERITED_FROM_PARTNER\"",
        'pageToken' => $nextPageToken
    );

    // Call the API, getting all the assigned targeting options for the
    // identified line item.
    $response = $service
        ->advertisers_lineItems
        ->bulkListAssignedTargetingOptions(
            advertiser-id,
            $optParams
    );

    // Print the returned assigned targeting options.
    if (!empty($response->getLineItemAssignedTargetingOptions())) {
        foreach ($response->getLineItemAssignedTargetingOptions() as $option) {
            printf('Assigned Targeting Option %s found\n', $option->getAssignedTargetingOption()['name']);
        }
    } else {
        print('No targeting options returned\n');
    }

    // Update the next page token.
    $nextPageToken = $response->getNextPageToken();
} while (
    !empty($response->getLineItemAssignedTargetingOptions())
    && $nextPageToken);

Chỉnh sửa hàng loạt tiêu chí nhắm mục tiêu

advertisers.lineItems.bulkEditAssignedTargetingOptions cung cấp cách thêm và xóa nhiều tùy chọn nhắm mục tiêu của các tùy chọn nhắm mục tiêu khác nhau từ một hoặc nhiều mục hàng cùng lúc.

Phương thức này lấy danh sách DeleteAssignedTargetingOptionsRequests và danh sách CreateAssignedTargetingOptionsRequests. Một yêu cầu duy nhất đối tượng có thể cho biết việc xóa hoặc tạo nhiều tiêu chí nhắm mục tiêu được chỉ định các tùy chọn có cùng loại nhắm mục tiêu.

Nếu việc cố gắng xóa hoặc tạo tùy chọn nhắm mục tiêu được chỉ định gây ra lỗi lỗi cho một mục hàng, thì thao tác hàng loạt sẽ bị bỏ qua đối với mục hàng đó. Chiến lược phát hành đĩa đơn yêu cầu trả về danh sách dòng được cập nhật thành công mục, cũng như danh sách mục hàng không thực hiện được bản cập nhậtthông tin cập nhật liên quan lỗi.

Dưới đây là ví dụ về cách chỉnh sửa hàng loạt tùy chọn nhắm mục tiêu được chỉ định cho một hoặc nhiều mục hàng được cung cấp danh sách các tùy chọn nhắm mục tiêu được chỉ định để xóa và nhắm mục tiêu để tạo:

Java

// Create a bulk edit request.
BulkEditAssignedTargetingOptionsRequest requestContent =
    new BulkEditAssignedTargetingOptionsRequest();

// Set line item IDs in edit request.
requestContent.setLineItemIds(line-item-ids);

// Build delete request list.
ArrayList<DeleteAssignedTargetingOptionsRequest> deleteRequests =
    new ArrayList<DeleteAssignedTargetingOptionsRequest>();

// Add browser assigned targeting option IDs to delete request list.
deleteRequests.add(new DeleteAssignedTargetingOptionsRequest()
    .setTargetingType("TARGETING_TYPE_BROWSER")
    .setAssignedTargetingOptionIds(delete-browser-assigned-targeting-ids));

// Add device make or model assigned targeting option IDs to delete request list.
deleteRequests.add(new DeleteAssignedTargetingOptionsRequest()
    .setTargetingType("TARGETING_TYPE_DEVICE_MAKE_MODEL")
    .setAssignedTargetingOptionIds(
        delete-device-make-model-assigned-targeting-ids));

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

// Build create request list.
ArrayList<CreateAssignedTargetingOptionsRequest> createRequests =
    new ArrayList<CreateAssignedTargetingOptionsRequest>();

// Create browser assigned targeting option create request.
CreateAssignedTargetingOptionsRequest createBrowserTargetingRequest =
    new CreateAssignedTargetingOptionsRequest();
createBrowserTargetingRequest.setTargetingType("TARGETING_TYPE_BROWSER");

// Create and set list of browser assigned targeting options.
ArrayList<AssignedTargetingOption> createBrowserAssignedTargetingOptions =
    new ArrayList<AssignedTargetingOption>();
for (String targetingOptionId : create-browser-assigned-targeting-ids) {
  createBrowserAssignedTargetingOptions.add(new AssignedTargetingOption()
      .setBrowserDetails(
          new BrowserAssignedTargetingOptionDetails()
              .setTargetingOptionId(targetingOptionId)));
}
createBrowserTargetingRequest
    .setAssignedTargetingOptions(createBrowserAssignedTargetingOptions);

// Add browser assigned targeting options to list of create requests.
createRequests.add(createBrowserTargetingRequest);

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

// Configure the bulk edit request.
LineItems.BulkEditAssignedTargetingOptions request =
    service.advertisers().lineItems()
        .bulkEditAssignedTargetingOptions(
            advertiser-id,
            requestContent);

// Execute bulk edit request.
BulkEditAssignedTargetingOptionsResponse response = request.execute();

// Check if any line items updated successfully.
if (response.getUpdatedLineItemIds() == null || response.getUpdatedLineItemIds().isEmpty()) {
  System.out.println("No line items were updated successfully.");
} else {
  System.out.printf(
      "Targeting configurations for the following line item IDs were updated: %s.\n",
      Arrays.toString(response.getUpdatedLineItemIds().toArray()));
}

// Check if any line items failed to update.
if (response.getFailedLineItemIds() == null || response.getFailedLineItemIds().isEmpty()) {
  System.out.println("No line items failed to update.");
} else {
  // Print the line items that failed to update.
  System.out.printf(
      "Targeting configurations for the following line item IDs failed to update: %s.\n",
      Arrays.toString(response.getFailedLineItemIds().toArray()));

  // Print errors thrown for failed updates.
  System.out.println("The failed updates were caused by the following errors:");
  for (Status error : response.getErrors()) {
    System.out.printf("Error Code: %s, Message: %s\n", error.getCode(), error.getMessage());
  }
}

Python

# Build assigned targeting option objects to create.
createBrowserAssignedTargetingOptions = []
for targeting_id in create-browser-assigned-targeting-ids:
  createBrowserAssignedTargetingOptions.append(
      {'browserDetails': {'targetingOptionId': targeting_id}}
  )

# Create a bulk edit request.
bulk_edit_line_item_request = {
    'lineItemIds': line-item-ids,
    'deleteRequests': [
        {
            'targetingType': 'TARGETING_TYPE_BROWSER',
            'assignedTargetingOptionIds':
              delete-browser-assigned-targeting-ids
        },
        {
            'targetingType': 'TARGETING_TYPE_DEVICE_MAKE_MODEL',
            'assignedTargetingOptionIds':
              delete-device-make-model-assigned-targeting-ids
        }
    ],
    'createRequests': [
        {
            'targetingType': 'TARGETING_TYPE_BROWSER',
            'assignedTargetingOptions':
              createBrowserAssignedTargetingOptions
        }
    ]
}

# Edit the line item targeting.
response = service.advertisers().lineItems()\
  .bulkEditAssignedTargetingOptions(
    advertiserId=advertiser-id,
    body=bulk_edit_line_item_request
).execute()

# Print successfully updated line items.
if 'updatedLineItemIds' not in response:
  print("No line items were updated successfully.")
else:
  print("Targeting configurations for the following line item IDs were updated: %s"
        % response['updatedLineItemIds'])

# Print line items that failed to update.
if 'failedLineItemIds' not in response:
  print("No line items failed to update.")
else:
  print("Targeting configurations for 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"]))

PHP

// Create delete request list.
$deleteRequests = array();

// Create and add browser assigned targeting option IDs to delete request list.
$deleteBrowserTargetingRequest =
    new Google_Service_DisplayVideo_DeleteAssignedTargetingOptionsRequest();
$deleteBrowserTargetingRequest->setTargetingType(
    "TARGETING_TYPE_BROWSER"
);
$deleteBrowserTargetingRequest->setAssignedTargetingOptionIds(
    delete-browser-assigned-targeting-ids
);
$deleteRequests[] = $deleteBrowserTargetingRequest;

// Create and add device assigned targeting option IDs to delete request list.
$deleteDeviceTargetingRequest =
    new Google_Service_DisplayVideo_DeleteAssignedTargetingOptionsRequest();
$deleteDeviceTargetingRequest->setTargetingType(
    "TARGETING_TYPE_DEVICE_MAKE_MODEL"
);
$deleteDeviceTargetingRequest->setAssignedTargetingOptionIds(
    delete-device-make-model-assigned-targeting-ids
);
$deleteRequests[] = $deleteDeviceTargetingRequest;

// Create create request list.
$createRequests = array();

// Create and populate list of browser assigned targetion options to create.
$createBrowserAssignedTargetingOptions = array();
foreach (create-browser-assigned-targeting-ids as $optionId) {
    $option = new Google_Service_DisplayVideo_AssignedTargetingOption();
    $details =
        new Google_Service_DisplayVideo_BrowserAssignedTargetingOptionDetails();
    $details->setTargetingOptionId($optionId);

    $option->setBrowserDetails($details);
    $createBrowserAssignedTargetingOptions[] = $option;
}

// Create and add browser assigned targeting option create request to create
// request list.
$createBrowserTargetingRequest =
    new Google_Service_DisplayVideo_CreateAssignedTargetingOptionsRequest();
$createBrowserTargetingRequest->setTargetingType(
    "TARGETING_TYPE_BROWSER"
);
$createBrowserTargetingRequest->setAssignedTargetingOptions(
    $createBrowserAssignedTargetingOptions
);
$createRequests[] = $createBrowserTargetingRequest;

// Create a bulk edit request and assign create and delete request lists.
$body =
    new Google_Service_DisplayVideo_BulkEditAssignedTargetingOptionsRequest();
$body->setLineItemIds(line-item-ids);
$body->setCreateRequests($createRequests);
$body->setDeleteRequests($deleteRequests);

// Call the API, editing the assigned targeting options for the identified
// line item.
$response = $service
    ->advertisers_lineItems
    ->bulkEditAssignedTargetingOptions(
        advertiser-id,
        $body
    );

// Print successfully updated line items.
if (!empty($response->getUpdatedLineItemIds())) {
    printf('Targeting configurations for the following line item IDs were updated:\n');
    foreach ($response->getUpdatedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
} else {
    print('No line items were updated successfully.\n');
}

// Print line items that failed to update.
if (!empty($response->getFailedLineItemIds())) {
    print('Targeting configurations for the following line item IDs failed to update:\n');
    foreach ($response->getFailedLineItemIds() as $id) {
        printf('%s\n', $id);
    }
    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());
    }
} else {
    print('No line items failed to update.\n');
}