自定义出价算法是根据 用户定义的出价逻辑构建的。通过订单项的出价策略将其分配给订单项。然后,订单项在对广告资源出价时将使用该自定义逻辑。
选择自定义出价算法类型
算法类型决定了如何在 算法中定义出价逻辑。
选择以下可通过 Display &Video 360 API 创建的类型之一:
SCRIPT_BASED:由上传的脚本设置的逻辑。该脚本是一个使用基本 Python 语法的文本文件。RULE_BASED:由上传的规则集设置的逻辑。该规则集是 一个上传的AlgorithmRulesJSON 文件。
创建 CustomBiddingAlgorithm 资源
使用 create 请求创建自定义出价算法。
广告客户或合作伙伴都可以是owner an
算法。如果算法归广告客户所有,则只能由该广告客户名下的广告系列使用。如果算法归合作伙伴所有,则只能由合作伙伴有意与之共享的广告客户使用。
以下是创建自定义出价算法的方法:
Java
// Provide the ID of the advertiser that will own the algorithm. long advertiserId = advertiser-id; // Provide the display name of the algorithm. String displayName = display-name; // Provide the type of custom bidding algorithm. String customBiddingAlgorithmType = custom-bidding-algorithm-type; // Create the custom bidding algorithm structure. CustomBiddingAlgorithm algorithm = new CustomBiddingAlgorithm() .setAdvertiserId(advertiserId) .setDisplayName(displayName) .setEntityStatus("ENTITY_STATUS_ACTIVE") .setCustomBiddingAlgorithmType(customBiddingAlgorithmType); // Create the algorithm. CustomBiddingAlgorithm response = service.customBiddingAlgorithms().create(algorithm).execute(); // Display the new custom bidding algorithm ID. System.out.printf( "Custom Bidding Algorithm was created with the ID %s.", response.getCustomBiddingAlgorithmId());
Python
# Provide the ID of the advertiser that will own the algorithm. advertiser_id = advertiser-id # Provide the display name of the algorithm. display_name = display-name # Provide the type of custom bidding algorithm. custom_bidding_algo_type = custom-bidding-algorithm-type # Build CustomBiddingAlgorithm object. custom_bidding_algorithm_obj = { "advertiserId": advertiser_id, "displayName": display_name, "entityStatus": "ENTITY_STATUS_ACTIVE", "customBiddingAlgorithmType": custom_bidding_algo_type, } # Build and execute request. algorithm_response = ( service.customBiddingAlgorithms() .create(body=custom_bidding_algorithm_obj) .execute() ) # Print ID of new custom bidding algorithm. print( "Custom bidding algorithm was created with ID " f'{algorithm_response["customBiddingAlgorithmId"]}.' )
PHP
// Provide the ID of the advertiser that will own the algorithm. $advertiserId = advertiser-id; // Provide the display name of the algorithm. $displayName = display-name; // Provide the type of custom bidding algorithm. $customBiddingAlgorithmType = custom-bidding-algorithm-type; // Create the custom bidding algorithm structure. $algorithm = new Google_Service_DisplayVideo_CustomBiddingAlgorithm(); $algorithm->setAdvertiserId($advertiserId); $algorithm->setDisplayName($displayName); $algorithm->setEntityStatus('ENTITY_STATUS_ACTIVE'); $algorithm->setCustomBiddingAlgorithmType($customBiddingAlgorithmType); // Call the API, creating the advertiser. try { $result = $this->service->customBiddingAlgorithms->create($algorithm); } catch (\Exception $e) { $this->renderError($e); return; } // Print ID of new custom bidding algorithm. printf('<p>Custom Bidding Algorithm was created with the ID %s.</p>', $result['customBiddingAlgorithmId']);