Triển khai chiến lược Đặt giá thầu tuỳ chỉnh

API Display & Video 360 cho phép bạn quản lý toàn diện việc triển khai tính năng đặt giá thầu tuỳ chỉnh. Bạn có thể tạo các thuật toán đặt giá thầu tuỳ chỉnh, tải lên và xác minh từng tập lệnh, cũng như chỉ định một thuật toán cụ thể làm chiến lược đặt giá thầu cho một tài nguyên.

Trang này mô tả cách tạo, cập nhật và chỉ định thuật toán đặt giá thầu tuỳ chỉnh bằng API Display & Video 360. Mỗi mục sẽ có một mã mẫu.

Tạo thuật toán đặt giá thầu tuỳ chỉnh

Đối tượng CustomBiddingAlgorithm đại diện cho một thuật toán riêng lẻ mà bạn có thể chỉ định cho một mục hàng để sử dụng trong chiến lược giá thầu của mục hàng đó. Đối tượng này có thông tin chi tiết về thuật toán, chẳng hạn như customBiddingAlgorithmTypeentityStatus, cũng như readinessStatesuspensionState cho mô hình đã tạo của từng nhà quảng cáo có liên quan. Bạn có thể tạo các đối tượng CustomBiddingScriptCustomBiddingAlgorithmRules làm tài nguyên con để thuật toán sử dụng.

Dưới đây là ví dụ về cách tạo thuật toán đặt giá thầu tuỳ chỉnh dựa trên tập lệnh:

Java

// Create the custom bidding algorithm structure.
CustomBiddingAlgorithm customBiddingAlgorithm =
    new CustomBiddingAlgorithm()
        .setAdvertiserId(advertiser-id)
        .setDisplayName(display-name)
        .setEntityStatus("ENTITY_STATUS_ACTIVE")
        .setCustomBiddingAlgorithmType("SCRIPT_BASED");

// Configure the create request.
CustomBiddingAlgorithms.Create request =
    service.customBiddingAlgorithms().create(customBiddingAlgorithm);

// Create the custom bidding algorithm.
CustomBiddingAlgorithm response = request.execute();

// Display the new custom bidding algorithm name.
System.out.printf(
    "Custom bidding algorithm %s was created.%n",
    response.getName()
);

Python

# Create a custom bidding algorithm object.
custom_bidding_algorithm_obj = {
    'advertiserId': advertiser-id,
    'displayName': display-name,
    'entityStatus': 'ENTITY_STATUS_ACTIVE',
    'customBiddingAlgorithmType': 'SCRIPT_BASED'
}

# Create the custom bidding algorithm.
response = service.customBiddingAlgorithms().create(
    body=custom_bidding_algorithm_obj
).execute()

# Display the new custom bidding algorithm.
print(f'The following Custom Bidding Algorithm was created: {response}')

1.199

// Create a custom bidding algorithm object.
$customBiddingAlgorithm =
    new Google_Service_DisplayVideo_CustomBiddingAlgorithm();
$customBiddingAlgorithm->setAdvertiserId(advertiser-id);
$customBiddingAlgorithm->setDisplayName(display-name);
$customBiddingAlgorithm->setEntityStatus('ENTITY_STATUS_ACTIVE');
$customBiddingAlgorithm->setCustomBiddingAlgorithmType('SCRIPT_BASED');

// Create the custom bidding algorithm.
$result =
    $this->service->customBiddingAlgorithms->create($customBiddingAlgorithm);

// Display the new custom bidding algorithm name.
printf('Custom Bidding Algorithm %s was created.\n', $result['name']);

Quản lý quyền truy cập vào thuật toán

Một đối tác hoặc nhà quảng cáo có thể sở hữu thuật toán đặt giá thầu tuỳ chỉnh. Đối tác đó và bất kỳ nhà quảng cáo con nào được liệt kê trong trường sharedAdvertiserIds đều có thể truy cập và sửa đổi các thuật toán do đối tác sở hữu. Các thuật toán do nhà quảng cáo sở hữu có thể được nhà quảng cáo đó và đối tác mẹ của nhà quảng cáo sở hữu nhưng không thể chia sẻ với các nhà quảng cáo khác.

Nếu bạn chỉ sử dụng thuật toán cho một nhà quảng cáo, hãy chỉ định nhà quảng cáo đó làm chủ sở hữu thông qua trường advertiserId. Nếu không, hãy chỉ định đối tác mẹ của nhà quảng cáo làm chủ sở hữu thông qua trường partnerId và cấp cho nhà quảng cáo quyền truy cập bằng trường sharedAdvertiserIds.

Logic thuật toán tải lên

Tuỳ thuộc vào loại thuật toán đặt giá thầu tuỳ chỉnh, tiếp theo, bạn cần tạo một tập lệnh hoặc một đối tượng quy tắc để có thể cung cấp logic để thuật toán sử dụng.

Tải tập lệnh lên

Các thuật toán đặt giá thầu tuỳ chỉnh dựa trên tập lệnh sử dụng tập lệnh do người dùng cung cấp để đánh giá giá trị của một lượt hiển thị. Bạn có thể xem các mẫu tập lệnh đơn giản và danh sách các trường nâng cao có sẵn thông qua Trung tâm trợ giúp Display & Video 360.

Các phần sau đây hướng dẫn bạn cách thêm tập lệnh mới hoặc tập lệnh cập nhật vào thuật toán đặt giá thầu tuỳ chỉnh.

Truy xuất vị trí tài nguyên tập lệnh

Trước tiên, hãy truy xuất vị trí tài nguyên có sẵn trong tài nguyên thuật toán đặt giá thầu tuỳ chỉnh bằng phương thức customBiddingAlgorithms.uploadScript. Yêu cầu này trả về một đối tượng CustomBiddingScriptReftên tài nguyên. Bạn có thể tải tệp tập lệnh của mình lên vị trí do tên tài nguyên chỉ định. Sau đó, hãy sử dụng đối tượng tham chiếu tập lệnh đặt giá thầu tuỳ chỉnh để tạo tài nguyên tập lệnh.

Sau đây là ví dụ về cách truy xuất một vị trí tài nguyên hiện có:

Java

// Retrieve a usable custom bidding script
// reference.
CustomBiddingScriptRef scriptRef =
    service
        .customBiddingAlgorithms()
        .uploadScript(custom-bidding-algorithm-id)
        .setAdvertiserId(advertiser-id)
        .execute();

// Display the custom bidding script reference resource path.
System.out.printf(
    "The script can be uploaded to the following resource path: %s%n",
    scriptRef.getResourceName()
);

Python

# Retrieve a usable custom bidding script reference
# object.
custom_bidding_script_ref = service.customBiddingAlgorithms().uploadScript(
    customBiddingAlgorithmId=custom-bidding-algorithm-id,
    advertiserId=advertiser-id
).execute()

# Display the new custom bidding script reference object.
print('The following custom bidding script reference object was retrieved:'
      f'{custom_bidding_script_ref}')

1.199

// Set parent advertiser ID of custom bidding
// algorithm in optional parameters array for request.
$optParams = array('advertiserId' => advertiser-id);

// Retrieve a usable custom bidding script reference.
$scriptRefResponse = $this->service->customBiddingAlgorithms->uploadScript(
    custom-bidding-algorithm-id,
    $optParams
);

// Display the new custom bidding script reference object.
printf(
    'The script can be uploaded to the following resource path: %s\n',
    $scriptRefResponse->getResourceName()
);

Tải tệp tập lệnh lên

Sau khi truy xuất một vị trí tài nguyên có sẵn, hãy tải tệp tập lệnh của bạn lên vị trí đó trong hệ thống Display & Video 360 bằng phương thức media.upload. Phương thức này hỗ trợ một phương thức tải lên đơn giản yêu cầu tham số truy vấn uploadType=media.

Dưới đây là ví dụ về cách tải tệp tập lệnh lên với một đối tượng tham chiếu tập lệnh đặt giá thầu tuỳ chỉnh đã truy xuất:

Java

// Create media object.
GoogleBytestreamMedia media = new GoogleBytestreamMedia();
media.setResourceName(resource-name);

// Create input stream for the script file.
InputStreamContent scriptFileStream =
    new InputStreamContent(
        null, new FileInputStream(script-path));

// Create media.upload request.
Media.Upload uploadRequest =
        service
            .media()
            .upload(
                resource-name,
                media,
                scriptFileStream);

// Retrieve uploader from the request and set it to us a simple
// upload request.
MediaHttpUploader uploader = uploadRequest.getMediaHttpUploader();
uploader.setDirectUploadEnabled(true);

// Execute the upload using an Upload URL with the destination resource
// name.
uploader
    .upload(
        new GenericUrl(
            "https://displayvideo.googleapis.com/upload/media/"
                + resource-name));

Python

# Create a media upload object.
media = MediaFileUpload(script-path)

# Create upload request.
upload_request = service.media().upload(
    resourceName=resource-name, media_body=media)

# Override response handler to expect null response.
upload_request.postproc = HttpRequest.null_postproc

# Upload script to resource location given in retrieved custom bidding
# script reference object.
upload_request.execute()

1.199

// Create a media object.
$mediaBody = new Google_Service_DisplayVideo_GoogleBytestreamMedia();
$mediaBody->setResourceName(resource-name);

// Set parameters for upload request.
$optParams = array(
    'data' => file_get_contents(script-path),
    'uploadType' => 'media',
    'resourceName' => resource-name
);

// Upload script file to given resource location.
$this->service->media->upload(
    resource-name,
    $mediaBody,
    $optParams
);

cURL

curl --request POST 'https://displayvideo.googleapis.com/upload/media/resource-name?uploadType=media' 
  -H 'authorization: Bearer access-token'
  -H 'Content-Type: text/plain'
  --data-binary @script-path

Tạo đối tượng tập lệnh

Sau khi tải tệp tập lệnh lên, hãy tạo một tài nguyên tập lệnh đặt giá thầu tuỳ chỉnh bằng phương thức customBiddingAlgorithms.scripts.create. Đối tượng CustomBiddingScript được truyền trong yêu cầu chỉ được bao gồm đối tượng CustomBiddingScriptRef dưới dạng giá trị được chỉ định của trường script. Thao tác này sẽ liên kết tệp tập lệnh đã tải lên với tài nguyên tập lệnh mới.

Dưới đây là ví dụ về cách tạo tài nguyên tập lệnh:

Java

// Create the custom bidding script structure.
CustomBiddingScript customBiddingScript =
    new CustomBiddingScript()
        .setScript(custom-bidding-script-ref);

// Create the custom bidding script.
CustomBiddingScript response =
    service
        .customBiddingAlgorithms()
        .scripts()
        .create(custom-bidding-algorithm-id, customBiddingScript)
        .setAdvertiserId(advertiser-id)
        .execute();

// Display the new script resource name
System.out.printf(
    "The following script was created: %s%n",
    response.getName());

Python

# Create a custom bidding script object.
script_obj = {
    'script': custom-bidding-script-ref
}

# Create the custom bidding script.
response = service.customBiddingAlgorithms().scripts().create(
    customBiddingAlgorithmId=custom-bidding-algorithm-id,
    advertiserId=advertiser-id,
    body=script_obj).execute()

# Display the new custom bidding script object.
print(f'The following custom bidding script was created: {response}')

1.199

// Create the custom bidding script object.
$customBiddingScript =
    new Google_Service_DisplayVideo_CustomBiddingScript();
$customBiddingScript->setScript(custom-bidding-script-ref);

// Set parameters for create script request.
$optParams = array(
    'advertiserId' => advertiser-id
);

// Create the custom bidding script.
$result = $this->service->customBiddingAlgorithms_scripts->create(
    custom-bidding-algorithm-id,
    $customBiddingScript,
    $optParams
);

// Display the new script resource name.
printf('The following script was created: %s.\n', $result->getName());

Sau khi bạn tạo tài nguyên tập lệnh đặt giá thầu tuỳ chỉnh, Display & Video 360 sẽ xử lý tập lệnh đó để đảm bảo có thể sử dụng thành công tập lệnh đó để tính điểm lượt hiển thị. Truy xuất trạng thái của quá trình xử lý này thông qua trường state của đối tượng tập lệnh. Sau khi tập lệnh mới được chấp nhận, thuật toán đặt giá thầu tuỳ chỉnh sẽ bắt đầu sử dụng tập lệnh để tính điểm cho giá trị lượt hiển thị. Việc này xảy ra ngay lập tức, vì vậy, hãy đảm bảo bạn muốn cập nhật thuật toán trước khi tạo tài nguyên tập lệnh mới.

Quy tắc tải lên

Các thuật toán đặt giá thầu tuỳ chỉnh dựa trên quy tắc sử dụng logic được cung cấp trong đối tượng AlgorithmRules để đánh giá giá trị của một lượt hiển thị.

Các đối tượng AlgorithmRules được tải lên trong một tệp JSON, sau đó liên kết với một thuật toán đặt giá thầu tuỳ chỉnh thông qua đối tượng CustomBiddingAlgorithmRules.

Truy xuất vị trí tài nguyên quy tắc

Trước tiên, hãy truy xuất vị trí tài nguyên có sẵn trong tài nguyên thuật toán đặt giá thầu tuỳ chỉnh bằng phương thức customBiddingAlgorithms.uploadRules. Yêu cầu này trả về một đối tượng CustomBiddingAlgorithmsRulesReftên tài nguyên. Bạn có thể tải tệp quy tắc lên vị trí do tên tài nguyên chỉ định. Sau đó, hãy sử dụng đối tượng tham chiếu quy tắc của thuật toán đặt giá thầu tuỳ chỉnh để tạo tài nguyên quy tắc.

Sau đây là ví dụ về cách truy xuất một vị trí tài nguyên hiện có:

Java

// Create the custom bidding algorithm structure.
CustomBiddingAlgorithmRulesRef rulesRef =
    service
        .customBiddingAlgorithms()
        .uploadRules(custom-bidding-algorithm-id)
        .setAdvertiserId(advertiser-id)
        .execute();

System.out.printf(
    "The rules can be uploaded to the following resource path: %s%n",
    rulesRef.getResourceName()
);

Python

# Retrieve a usable custom bidding algorithm rules reference
# object.
custom_bidding_algorithm_rules_ref = service.customBiddingAlgorithms().uploadRules(
    customBiddingAlgorithmId=custom-bidding-algorithm-id,
    advertiserId=advertiser-id
).execute()

# Display the new custom bidding algorithm rules reference object.
print('The following custom bidding algorithm rules reference object was retrieved:'
      f' {custom_bidding_algorithm_rules_ref}')

1.199

// Set parent advertiser ID of custom bidding algorithm
// in optional parameters array for request.
$optParams = array('advertiserId' => advertiser-id);

// Retrieve a usable custom bidding algorithm rules reference.
$rulesRefResponse = $this->service->customBiddingAlgorithms->uploadRules(
    custom-bidding-algorithm-id,
    $optParams
);

// Display the new custom bidding algorithm rules reference object resource path.
printf(
    'The rules can be uploaded to the following resource path: %s\n',
    $rulesRefResponse->getResourceName()
);

Tải tệp AlgorithmRules lên

Sau khi truy xuất một vị trí tài nguyên có sẵn, hãy tải tệp quy tắc lên vị trí đó trong hệ thống Display & Video 360 bằng phương thức media.upload. Phương thức này hỗ trợ một phương thức tải lên đơn giản yêu cầu tham số truy vấn uploadType=media.

Dưới đây là ví dụ về cách tải tệp AlgorithmRules lên dựa trên một đối tượng tham chiếu quy tắc thuật toán đặt giá thầu tuỳ chỉnh đã truy xuất:

Java

// Create media object.
GoogleBytestreamMedia media = new GoogleBytestreamMedia();
media.setResourceName(resource-name);

// Create input stream for the rules file.
InputStreamContent rulesFileStream =
    new InputStreamContent(
        null, new FileInputStream(rules-file-path));

// Create media.upload request.
 Media.Upload uploadRequest =
    service
        .media()
        .upload(
            resource-name,
            media,
            rulesFileStream);

// Retrieve uploader from the request and set it to us a simple
// upload request.
MediaHttpUploader uploader = uploadRequest.getMediaHttpUploader();
uploader.setDirectUploadEnabled(true);

// Execute the upload using an Upload URL with the destination resource
// name.
uploader
    .upload(
        new GenericUrl(
            "https://displayvideo.googleapis.com/upload/media/"
                + resource-name));

Python

# Create a media upload object.
media = MediaFileUpload(rules-file-path)

# Create upload request.
upload_request = service.media().upload(
    resourceName=resource-name, media_body=media)

# Override response handler to expect null response.
upload_request.postproc = HttpRequest.null_postproc

# Upload rules file to resource location given in retrieved custom bidding
# algorithm rules reference object.
upload_request.execute()

1.199

// Create a media object.
$mediaBody = new Google_Service_DisplayVideo_GoogleBytestreamMedia();
$mediaBody->setResourceName(resource-name);

// Set parameters for upload request.
$optParams = array(
    'data' => file_get_contents(rules-file-path),
    'uploadType' => 'media',
    'resourceName' => resource-name
);

// Upload rules file to given resource location.
$this->service->media->upload(
    resource-name,
    $mediaBody,
    $optParams
);

cURL

curl --request POST 'https://displayvideo.googleapis.com/upload/media/resource-name?uploadType=media' 
  -H 'authorization: Bearer access-token'
  -H 'Content-Type: text/plain'
  --data-binary @rules-file-path

Tạo đối tượng quy tắc

Sau khi tải tệp JSON AlgorithmRules lên, hãy tạo một tài nguyên quy tắc thuật toán đặt giá thầu tuỳ chỉnh bằng phương thức customBiddingAlgorithms.rules.create. Đối tượng CustomBiddingAlgorithmRules được truyền trong yêu cầu chỉ nên bao gồm đối tượng CustomBiddingAlgorithmRulesRef dưới dạng giá trị được chỉ định của trường rules. Thao tác này sẽ liên kết tệp JSON AlgorithmRules đã tải lên với tài nguyên của các quy tắc mới.

Dưới đây là ví dụ về cách tạo tài nguyên quy tắc:

Java

// Create the custom bidding algorithm rules structure.
CustomBiddingAlgorithmRules customBiddingAlgorithmRules =
    new CustomBiddingAlgorithmRules()
        .setRules(custom-bidding-algorithm-rules-ref);

// Create the rules resource.
CustomBiddingAlgorithmRules response =
    service
        .customBiddingAlgorithms()
        .rules()
        .create(custom-bidding-algorithm-id, customBiddingAlgorithmRules)
        .setAdvertiserId(advertiser-id)
        .execute();

// Display the new rules resource name.
System.out.printf(
    "The following custom bidding algorithm rules object was created: %s%n",
    response.getName());

Python

# Create the custom bidding algorithm rules object.
rules_obj = {
    'rules': custom-bidding-algorithm-rules-ref
}

# Create the rules resource.
response = service.customBiddingAlgorithms().rules().create(
    customBiddingAlgorithmId=custom-bidding-algorithm-id,
    advertiserId=advertiser-id,
    body=rules_obj).execute()

# Display the new custom bidding algorithm rules object.
print(f'The following custom bidding algorithm rules resource was created: {response}')

1.199

// Create the custom bidding algorithm rules object.
$customBiddingAlgorithmRules =
    new Google_Service_DisplayVideo_CustomBiddingAlgorithmRules();
$customBiddingAlgorithmRules->setRules(custom-bidding-algorithm-rules-ref);

// Set parameters for create rules request.
$optParams = array(
    'advertiserId' => advertiser-id
);

// Create the custom bidding algorithm rules resource.
$result = $this->service->customBiddingAlgorithms_rules->create(
    custom-bidding-algorithm-id,
    $customBiddingAlgorithmRules,
    $optParams
);

// Display the new custom bidding algorithm rules resource name.
printf('The following rules resource was created: %s.\n', $result->getName());

Sau khi bạn tạo tài nguyên quy tắc, Display & Video 360 sẽ xử lý tập hợp quy tắc đó để đảm bảo bạn có thể sử dụng thành công tập hợp quy tắc đó để tính điểm lượt hiển thị. Truy xuất trạng thái xử lý này thông qua trường state của đối tượng quy tắc. Sau khi các quy tắc mới được chấp nhận, thuật toán đặt giá thầu tuỳ chỉnh sẽ bắt đầu sử dụng các quy tắc để tính điểm ngay lập tức các giá trị lượt hiển thị.

Nếu các quy tắc bị từ chối, hãy truy xuất lý do từ chối trong error của đối tượng quy tắc. Trong trường hợp bị từ chối, hãy cập nhật đối tượng AlgorithmRules để khắc phục lỗi và lặp lại quá trình tải lên, bắt đầu từ việc truy xuất đối tượng tham chiếu quy tắc.

Chỉ định thuật toán đặt giá thầu tuỳ chỉnh

Sau khi tạo thuật toán đặt giá thầu tuỳ chỉnh, tải logic được chấp nhận lên và đáp ứng các yêu cầu cần thiết, bạn có thể chỉ định thuật toán đặt giá thầu tuỳ chỉnh cho chiến lược đặt giá thầu của một mục hàng hoặc đơn đặt hàng quảng cáo.

Bạn có thể sử dụng thuật toán đặt giá thầu tuỳ chỉnh trong chiến lược giá thầu tối đa hoá mức chi tiêumục tiêu hiệu suất bằng cách chỉ định BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGOmã thuật toán đặt giá thầu tuỳ chỉnh vào các trường performanceGoalTypecustomBiddingAlgorithmId tương ứng. Tuỳ thuộc vào chiến lược giá thầu, các thông số giá thầu khác có thể có sẵn hoặc bắt buộc.

Dưới đây là ví dụ về cách cập nhật một mục hàng để sử dụng chiến lược giá thầu tối đa hoá chi tiêu với một thuật toán đặt giá thầu tuỳ chỉnh nhất định:

Java

// Create the line item structure.
LineItem lineItem = new LineItem();

// Create and set the bidding strategy structure.
BiddingStrategy biddingStrategy = new BiddingStrategy();
MaximizeSpendBidStrategy maxSpendBidStrategy =
    new MaximizeSpendBidStrategy()
        .setPerformanceGoalType(
            "BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO")
        .setCustomBiddingAlgorithmId(custom-bidding-algorithm-id);
biddingStrategy.setMaximizeSpendAutoBid(maxSpendBidStrategy);
lineItem.setBidStrategy(biddingStrategy);

// Configure the patch request and set update mask to only update
// the bid strategy.
LineItems.Patch request =
    service
        .advertisers()
        .lineItems()
        .patch(advertiser-id, line-item-id, lineItem)
        .setUpdateMask("bidStrategy");

// Update the line item.
LineItem response = request.execute();

// Display the custom bidding algorithm ID used in the new
// bid strategy.
System.out.printf(
    "LineItem %s now has a bid strategy utilizing custom "
        + "bidding algorithm %s%n",
    response.getName(),
    response
        .getBidStrategy()
        .getMaximizeSpendAutoBid()
        .getCustomBiddingAlgorithmId());

Python

# Create the new bid strategy object.
bidding_strategy = {
    'maximizeSpendAutoBid': {
        'performanceGoalType':
            'BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO',
        'customBiddingAlgorithmId': custom-bidding-algorithm-id
    }
}

# Create a line item object assigning the new bid strategy.
line_item_obj = {'bidStrategy': bidding_strategy}

# Update the line item with a new bid strategy.
response = service.advertisers().lineItems().patch(
    advertiserId=advertiser-id,
    lineItemId=line-item-id,
    updateMask='bidStrategy',
    body=line_item_obj).execute()

# Display the line item's new bid strategy
print(f'Line Item {response["name"]} is now using the following bid'
     f' strategy: {response["bidStrategy"]}.')

1.199

// Create the line item structure.
$lineItem = new Google_Service_DisplayVideo_LineItem();

// Create and set the bidding strategy structure.
$biddingStrategy =  new Google_Service_DisplayVideo_BiddingStrategy();
$maximizeSpendBidStrategy =
    new Google_Service_DisplayVideo_MaximizeSpendBidStrategy();
$maximizeSpendBidStrategy->setPerformanceGoalType(
    'BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO'
);
$maximizeSpendBidStrategy->setCustomBiddingAlgorithmId(
    custom-bidding-algorithm-id
);
$biddingStrategy->setMaximizeSpendAutoBid($maximizeSpendBidStrategy);
$lineItem->setBidStrategy($biddingStrategy);

// Set update mask.
$optParams = array('updateMask' => 'bidStrategy');

// Update the line item.
$result = $this->service->advertisers_lineItems->patch(
    advertiser-id,
    line-item-id,
    $lineItem,
    $optParams
);

// Display the custom bidding algorithm ID used in the new bid strategy.
printf(
    'Line Item %s now has a bid strategy utilizing custom bidding algorithm %s.\n',
    $result['name'],
    $result['bidStrategy']['maximizeSpendBidStrategy']['customBiddingAlgorithmId']
);