カスタム入札の実装

[ディスプレイとVideo 360 API: カスタム入札を管理 あります。カスタム入札アルゴリズムを作成し、アップロードと検証を行うことができます。 入札機能としてリソースに特定のアルゴリズムを 説明します。

このページでは、カスタム入札アルゴリズムを作成、更新、割り当てする方法について説明します。 ディスプレイ &ビデオ 360 でVideo 360 API。各セクションにコードサンプルがあります。

カスタム入札アルゴリズムを作成する

CustomBiddingAlgorithm オブジェクトは、個々のオブジェクトを表す 入札戦略で使用するために広告申込情報に割り当てることができるアルゴリズムです。この アルゴリズムの詳細が格納されています。 customBiddingAlgorithmType entityStatuscustomBiddingAlgorithmState。新しい アルゴリズムの子リソースとしての CustomBiddingScript オブジェクト 使用できます。

スクリプトベースのカスタム入札の作成方法の例 アルゴリズム:

Python

# Create a custom bidding algorithm object.
custom_bidding_algorithm_obj = {
    'advertiserId': advertiser-id,
    'displayName': display-name,
    'entityStatus': 'ENTITY_STATUS_ACTIVE',
    'customBiddingAlgorithmType': 'SCRIPT_BASED'
}

# Create the custom bidding algorithm.
response = service.customBiddingAlgorithms().create(
    body=algorithm_obj
).execute()

# Display the new custom bidding algorithm.
print(f'The following Custom Bidding Algorithm was created: {response}')

アルゴリズムのアクセスを管理する

カスタム入札アルゴリズムは、パートナーまたは広告主が所有できます。アルゴリズム そのパートナーとすべての子は、そのパートナーが所有するコンテンツにアクセスし、変更できます。 sharedAdvertiserIds フィールドに指定されている広告主。 広告主が所有するアルゴリズムは、その広告主からアクセスして変更できます。 広告主とその親パートナーと共有され、他の広告主と共有することはできません。

単一の広告主に対してのみアルゴリズムを使用する場合は、 advertiserId で広告主を所有者として指定します。 それ以外の場合は、広告主の親パートナーを partnerId フィールドを指定し、 sharedAdvertiserIds フィールド。

スクリプトをアップロードする

カスタム入札アルゴリズムを作成したら、そのアルゴリズム用のスクリプトを作成します。 使用できます。スクリプトベースのカスタム入札アルゴリズムでは、ユーザー提供の スクリプトを使用してインプレッションの価値を評価します。 シンプルなスクリプトのサンプルと 詳細フィールドディスプレイと動画 360 ヘルプセンターをご覧ください。

以降のセクションでは、新しいスクリプトまたは更新されたスクリプトをカスタム 入札アルゴリズム

スクリプト リソースのロケーションを取得する

まず、カスタム入札で利用可能なリソース ロケーションを取得します。 アルゴリズム リソースです。 customBiddingAlgorithms.uploadScript メソッドを使用します。この リクエストは、次の値を含む CustomBiddingScriptRef オブジェクトを返します。 リソース名。Google Chat では 指定した場所にスクリプト ファイルをアップロードします。 指定します。次に、カスタム入札スクリプトの参照オブジェクトを使用して、 スクリプト リソースを作成します

使用可能なリソースを取得する方法の例を次に示します。 location:

Python

# Retrieve a usable custom bidding script reference
# object.
custom_bidding_script_ref = service.customBiddingAlgorithms().uploadScript(
    customBiddingAlgorithmId=custom-bidding-algorithm-id,
    advertiserId=advertiser-id
).execute()

# Display the new custom bidding script reference object.
print('The following custom bidding script reference object was retrieved:'
      f'{custom_bidding_script_ref}')

スクリプト ファイルをアップロードする

使用可能なリソースのロケーションを取得したら、そこにスクリプト ファイルをアップロードします。 ディスプレイ &ビデオ 360 で動画 360 システム media.upload メソッドを使用します。このメソッドは、 シンプル アップロード(クエリ パラメータが必要) uploadType=media

これは、特定の条件下でスクリプト ファイルをアップロードする方法の 取得したカスタム入札スクリプトの参照オブジェクト:

Python

# Create a media upload object.
media = MediaFileUpload(script-path)

# Create upload request.
upload_request = service.media().upload(
    resourceName=resource-name, media_body=media)

# Override response handler to expect null response.
upload_request.postproc = HttpRequest.null_postproc

# Upload script to resource location given in retrieved custom bidding
# script reference object.
upload_request.execute()

スクリプト オブジェクトを作成する

スクリプト ファイルをアップロードしたら、 customBiddingAlgorithms.scripts.create メソッド「 リクエストで渡される CustomBiddingScript オブジェクトは、 割り当てられた値として CustomBiddingScriptRef オブジェクトを含める script フィールドの値。これにより、アップロードされたアセットと 新しいスクリプト リソースに置き換えます。

スクリプト ファイルの作成例を次に示します。

Python

# Create a custom bidding script object.
script_obj = {
    'script': custom-bidding-script-ref
}

# Create the custom bidding script.
response = service.customBiddingAlgorithms().scripts().create(
    customBiddingAlgorithmId=custom-bidding-algorithm-id,
    advertiserId=advertiser-id,
    body=script_obj).execute()

# Display the new custom bidding script object.
print(f'The following custom bidding script was created: {response}')

カスタム入札スクリプトのリソースを作成すると、ディスプレイ &ビデオ 360 で動画 360 は インプレッションのスコア付けに使用できることを確認します。 スクリプト オブジェクトの state フィールド。新しいスクリプトが承認されると、カスタム 入札アルゴリズムが、スクリプトを使用してインプレッション値のスコア付けを開始します。この 更新は直ちに行われます。更新が終わる前にアルゴリズムを 新しいスクリプト リソースを作成します。

カスタム入札アルゴリズムの割り当て

カスタム入札アルゴリズムを作成したら、承認済みのスクリプトをアップロードして、要件を満たします。 必要な要件を満たしたら、カスタムのアラートを 入札アルゴリズムを広告申込情報または広告掲載オーダーの入札戦略にマッピングします。

カスタム入札アルゴリズムは 費用を最大化し 「BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO」を割り当てることで、掲載結果目標の入札戦略を最適化できます カスタム入札アルゴリズム IDperformanceGoalType および customBiddingAlgorithmId フィールド。 入札戦略によっては、他の入札パラメータも使用できます。 必要ありません。

「新規顧客の獲得」目標を使用するように広告申込情報を更新する例 特定のカスタム入札アルゴリズムを適用した場合の費用の入札戦略:

Python

# Create the new bid strategy object.
bidding_strategy = {
    'maximizeSpendAutoBid': {
        'performanceGoalType':
            'BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO',
        'customBiddingAlgorithmId': custom-bidding-algorithm-id
    }
}

# Create a line item object assigning the new bid strategy.
line_item_obj = {'bidStrategy': bidding_strategy}

# Update the line item with a new bid strategy.
response = service.advertisers().lineItems().patch(
    advertiserId=advertiser-id,
    lineItemId=line-item-id,
    updateMask='bidStrategy',
    body=line_item_obj).execute()

# Display the line item's new bid strategy
print(f'Line Item {response["name"]} is now using the following bid'
     f' strategy: {response["bidStrategy"]}.')