Criar um algoritmo de lances personalizados

Um algoritmo de lances personalizados é criado com base na lógica de lances definida por o usuário. Atribua o algoritmo a um item de linha usando a estratégia de lances. Ao dar lances no inventário de anúncios, o item de linha vai usar essa lógica personalizada.

Primeiro, escolha um tipo de algoritmo e crie o recurso de algoritmo.

Escolher um tipo de algoritmo de lances personalizados

O tipo de algoritmo determina como a lógica de lances é definida no algoritmo.

Escolha um dos seguintes tipos que podem ser criados pela API Display &Video 360:

  • SCRIPT_BASED: lógica definida por um script enviado. O script é um arquivo de texto que usa a sintaxe básica do Python.
  • RULE_BASED: lógica definida por um conjunto de regras enviado. O conjunto de regras é um arquivo JSON AlgorithmRules enviado.

Criar o recurso CustomBiddingAlgorithm

Use uma solicitação create para criar um algoritmo de lances personalizados.

Um anunciante ou parceiro pode ser o owner de um algoritmo. Se o algoritmo for de um anunciante, ele só poderá ser usado por campanhas de publicidade desse anunciante. Se o algoritmo for de um parceiro, ele só poderá ser usado por anunciantes com quem ele for compartilhado intencionalmente.

Saiba como criar um algoritmo de lances personalizados:

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