您可以使用多媒體和Video 360 API:管理自訂出價 。您可以建立自訂出價演算法、上傳並驗證 建立個別指令碼,然後指派特定演算法給資源做為出價 策略。
本頁面說明如何建立、更新及指派自訂出價演算法 多媒體廣告和Video 360 API。各節都提供程式碼範例。
建立自訂出價演算法
CustomBiddingAlgorithm 物件代表個人
演算法可以指派給委刊項在其出價策略中使用。這個
物件含有演算法的詳細資料,例如
customBiddingAlgorithmType、
entityStatus和
customBiddingAlgorithmState。您可以建立
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 欄位。
上傳指令碼
建立自訂出價演算法後,請為該演算法建立指令碼 編碼器-解碼器架構以指令碼為基礎的自訂出價演算法會使用使用者提供的內容 指令碼:評估曝光價值。 簡單指令碼的範例和 進階欄位的 多媒體和Video 360 說明中心。
以下章節說明如何將全新或更新的指令碼新增至自訂 出價演算法。
擷取指令碼資源位置
首先,擷取自訂出價下的可用資源位置
演算法資源
customBiddingAlgorithms.uploadScript 方法,增加圍繞地圖邊緣的邊框間距。這個
要求會傳回 CustomBiddingScriptRef 物件,其中包含
「資源名稱」。你可以
將指令碼檔案上傳到
資源名稱。接著,您可以使用自訂出價指令碼參照物件
建立指令碼資源。
以下範例說明如何擷取可用資源 位置:
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}')
上傳指令碼檔案
擷取可用的資源位置後,請將指令碼檔案上傳至該位置
多媒體廣告位置和而
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 會處理
指令碼,藉此確保指令碼可以成功為曝光評分。
使用指令碼物件的
state 欄位。接受新的指令碼後
出價演算法會開始使用指令碼計算曝光價值。這個
因此,請務必提前更新演算法
建立新的指令碼資源
指派自訂出價演算法
建立自訂出價演算法後,上傳系統接受的指令碼,並達成 必要條件,可讓您指派自訂 委刊項或廣告訂單出價策略的出價演算法。
自訂出價演算法可用於
盡量提高支出並
指派「BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO」來指定成效目標出價策略
和自訂出價演算法 ID
performanceGoalType和
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"]}.')