Creare un algoritmo di offerte personalizzate

Un algoritmo di offerta personalizzata è creato a partire dalla logica di offerta definita dall'utente. Assegnarla a un elemento pubblicitario tramite la strategia di offerta. Quando fai un'offerta per l'inventario pubblicitario, l'elemento pubblicitario utilizzerà la logica personalizzata.

Innanzitutto, scegli un tipo di algoritmo e crea la risorsa algoritmo.

Scegliere un tipo di algoritmo di offerte personalizzate

Il tipo di algoritmo determina il modo in cui viene definita la logica di offerta nell'algoritmo.

Scegli uno dei seguenti tipi che possono essere creati tramite l'API Display & Video 360:

  • SCRIPT_BASED: logica impostata da uno script caricato. Lo script è un file di testo che utilizza la sintassi Python di base.
  • RULE_BASED: logica impostata da un insieme di regole caricato. Il set di regole è un file JSON AlgorithmRules caricato.

Crea risorsa CustomBiddingAlgorithm

Utilizza una richiesta create per creare un algoritmo di offerta personalizzata.

Un inserzionista o un partner può essere il owner di un algoritmo. Se di proprietà di un inserzionista, può essere utilizzato solo dalle campagne pubblicitarie di quell'inserzionista. Se è di proprietà di un partner, può essere utilizzato solo dagli inserzionisti con cui è stato condiviso intenzionalmente.

Ecco come creare un algoritmo di offerta personalizzata:

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