Asigna el algoritmo

Asigna el algoritmo a un recurso una vez que esté listo.

Verifica si el algoritmo está listo

Un modelo de algoritmo debe entrenarse con una cantidad mínima de datos antes de estar listo.

Los algoritmos entrenan un modelo para cada anunciante que puede usarlos. Los modelos se entrenan con los datos de impresiones existentes. El entrenamiento de un modelo puede tardar de 1 a 3 días después de que el anunciante cumpla con los requisitos de datos.

Recupera la preparación de cada modelo del algoritmo. El objeto ReadinessState determina los próximos pasos:

ReadinessState
READINESS_STATE_NO_VALID_SCRIPT No hay ninguna secuencia de comandos válida. Sube un nuevo archivo de secuencia de comandos o de reglas.
READINESS_STATE_EVALUATION_FAILURE No hay ningún guion que se pueda evaluar en el tiempo asignado. Sube un nuevo archivo de secuencia de comandos o de reglas.
READINESS_STATE_INSUFFICIENT_DATA No hay suficientes datos disponibles en la cuenta del anunciante para entrenar el modelo. Sigue publicando campañas en la cuenta del anunciante para cumplir con los requisitos mínimos de datos.
READINESS_STATE_TRAINING El modelo se está entrenando con datos existentes y no está listo para la entrega. Espera entre 12 y 24 horas antes de verificar si el modelo está listo para la entrega.
READINESS_STATE_ACTIVE El modelo está completamente entrenado y listo para asignarse a las campañas del anunciante.

Asigna el algoritmo a la línea de pedido

Se utiliza un algoritmo para medir y ajustar el rendimiento de las ofertas. Se puede usar con estrategias de ofertas que se optimizan para invertir todo el presupuesto o alcanzar un objetivo. En estos casos, el tipo de objetivo de rendimiento de la estrategia sería BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO.

Sigue estos pasos para actualizar un concepto de línea y usar un algoritmo con una estrategia de ofertas que se optimice para invertir todo el presupuesto:

Java

// Provide the ID of the advertiser that owns the parent algorithm.
long advertiserId = advertiser-id;

// Provide the ID of the parent algorithm.
long algorithmId = algorithm-id;

// Provide the ID of the line item to assign the algorithm to.
long lineItemId = line-item-id;

// Create the line item structure.
LineItem lineItem =
    new LineItem()
        .setBidStrategy(
            new BiddingStrategy()
                .setMaximizeSpendAutoBid(
                    new MaximizeSpendBidStrategy()
                        .setPerformanceGoalType(
                            "BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO")
                        .setCustomBiddingAlgorithmId(algorithmId)));

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

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

// Display the new algorithm ID used by the line item.
System.out.printf(
    "Line item %s now uses algorithm ID %s in its bidding strategy.",
    response.getName(),
    response.getBidStrategy().getMaximizeSpendAutoBid().getCustomBiddingAlgorithmId());

Python

# Provide the parent advertiser ID of the line item and creative.
advertiser_id = advertiser-id

# Provide the ID of the creative to assign.
algorithm_id = algorithm-id

# Provide the ID of the line item to assign the creative to.
line_item_id = line-item-id

# Build bidding strategy object.
bidding_strategy_obj = {
    "maximizeSpendAutoBid": {
        "performanceGoalType": (
            "BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO"
        ),
        "customBiddingAlgorithmId": algorithm_id,
    }
}

# Build line item object.
line_item_obj = {"bidStrategy": bidding_strategy_obj}

# Build and execute request.
line_item_resp = (
    service.advertisers()
    .lineItems()
    .patch(
        advertiserId=advertiser_id,
        lineItemId=line_item_id,
        updateMask="bidStrategy",
        body=line_item_obj,
    )
    .execute()
)

# Print the algorithm ID now assigned to the line item.
print(
    f'Line Item {line_item_resp["name"]} now uses algorithm ID'
    f' {line_item_resp["bidStrategy"]["maximizeSpendAutoBid"]["customBiddingAlgorithmId"]}'
    " in its bidding strategy."
)

PHP

// Provide the ID of the advertiser that owns the parent algorithm.
$advertiserId = advertiser-id;

// Provide the ID of the parent algorithm.
$algorithmId = algorithm-id;

// Provide the ID of the line item to assign the algorithm to.
$lineItemId = line-item-id;

// Create the bidding strategy structure.
$maxSpendBidStrategy = new Google_ServiceDisplayVideo_MaximizeSpendBidStrategy();
$maxSpendBidStrategy->setPerformanceGoalType('BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO');
$maxSpendBidStrategy->setCustomBiddingAlgorithmId($algorithmId);
$biddingStrategy = new Google_ServiceDisplayVideo_BiddingStrategy();
$biddingStrategy->setMaximizeSpendAutoBid($maxSpendBidStrategy);

// Create the line item structure.
$lineItem = new Google_Service_DisplayVideo_LineItem();
$lineItem->setBidStrategy($biddingStrategy);
$optParams = array('updateMask' => 'bidStrategy');

// Call the API, updating the bid strategy for the identified line
// item.
try {
    $result = $this->service->advertisers_lineItems->patch(
        $advertiserId,
        $lineItemId,
        $lineItem,
        $optParams
    );
} catch (\Exception $e) {
    $this->renderError($e);
    return;
}

printf(
    '<p>Line Item %s now uses algorithm ID %s in its bid strategy.</p>',
    $result['name'],
    $result['bidStrategy']['maximizeSpendAutoBid']['customBiddingAlgorithmId']
);