Cómo crear un algoritmo de ofertas personalizadas

Un algoritmo de ofertas personalizadas se compila a partir de la lógica de ofertas definida por el usuario. Asignarla a una línea de pedido a través de su estrategia de ofertas Cuando se realicen ofertas por el inventario de anuncios, la línea de pedido usará esa lógica personalizada.

Primero, elige un tipo de algoritmo y crea el recurso del algoritmo.

Elige un tipo de algoritmo de ofertas personalizadas

El tipo de algoritmo determina cómo se define la lógica de ofertas en el algoritmo.

Elige uno de los siguientes tipos que se pueden crear a través de la API de Display & Video 360:

  • SCRIPT_BASED: Es la lógica establecida por una secuencia de comandos subida. La secuencia de comandos es un archivo de texto que usa la sintaxis básica de Python.
  • RULE_BASED: Es la lógica establecida por un conjunto de reglas subido. El conjunto de reglas es un archivo JSON AlgorithmRules subido.

Crea el recurso CustomBiddingAlgorithm

Usa una solicitud create para crear un algoritmo de ofertas personalizadas.

Tanto un anunciante como un socio pueden ser el owner de un algoritmo. Si es propiedad de un anunciante, solo se puede usar en las campañas publicitarias de ese anunciante. Si es propiedad de un socio, solo pueden usarlo los anunciantes con los que se compartió intencionalmente.

Sigue estos pasos para crear un algoritmo de ofertas personalizadas:

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