Tworzenie algorytmu ustalania stawek niestandardowych

Algorytm ustalania stawek niestandardowych jest tworzony na podstawie logiki ustalania stawek zdefiniowanej przez użytkownika. Przypisz go do elementu zamówienia za pomocą strategii ustalania stawek. Podczas ustalania stawek za zasoby reklamowe element zamówienia będzie korzystać z tej logiki niestandardowej.

Najpierw wybierz typ algorytmu i utwórz zasób algorytmu.

Wybieranie typu algorytmu ustalania stawek niestandardowych

Typ algorytmu określa, jak logika ustalania stawek jest definiowana w algorytmie.

Wybierz jeden z tych typów, które można utworzyć za pomocą interfejsu Display &Video 360 API:

  • SCRIPT_BASED: logika ustawiona przez przesłany skrypt. Skrypt to plik tekstowy, który używa podstawowej składni Pythona.
  • RULE_BASED: logika ustawiona przez przesłany zestaw reguł. Zestaw reguł to przesłany AlgorithmRules plik JSON.

Tworzenie zasobu CustomBiddingAlgorithm

Aby utworzyć algorytm ustalania stawek niestandardowych, użyj żądania create.

`Właścicielem` algorytmu może być reklamodawca lub partner.owner Jeśli właścicielem jest reklamodawca, algorytm może być używany tylko w kampaniach reklamowych tego reklamodawcy. Jeśli właścicielem jest partner, algorytm może być używany tylko przez reklamodawców z którymi został udostępniony.

Oto jak utworzyć algorytm ustalania stawek niestandardowych:

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']);