Display & Video 360 API की मदद से, कस्टम बिडिंग को लागू करने की प्रोसेस को पूरी तरह से मैनेज किया जा सकता है. कस्टम बिडिंग एल्गोरिदम बनाए जा सकते हैं, अलग-अलग स्क्रिप्ट अपलोड की जा सकती हैं, और बिडिंग की रणनीति के तौर पर किसी संसाधन को कोई खास एल्गोरिदम असाइन किया जा सकता है.
इस पेज पर, Display & Video 360 API की मदद से कस्टम बिडिंग एल्गोरिदम बनाने, अपडेट करने, और असाइन करने का तरीका बताया गया है. हर सेक्शन में एक कोड सैंपल दिया गया है.
कस्टम बिडिंग एल्गोरिदम बनाना
CustomBiddingAlgorithm
ऑब्जेक्ट, किसी अलग एल्गोरिदम को दिखाता है. इस एल्गोरिदम को बिडिंग की रणनीति में इस्तेमाल करने के लिए, किसी लाइन आइटम को असाइन किया जा सकता है. इस ऑब्जेक्ट में एल्गोरिदम की जानकारी होती है. जैसे, customBiddingAlgorithmType
और entityStatus
. साथ ही, विज्ञापन देने वाले हर व्यक्ति या कंपनी के जनरेट किए गए मॉडल के लिए, readinessState
और suspensionState
की जानकारी भी होती है. एल्गोरिदम के इस्तेमाल के लिए, CustomBiddingScript
और CustomBiddingAlgorithmRules
ऑब्जेक्ट को चाइल्ड रिसॉर्स के तौर पर बनाया जा सकता है.
स्क्रिप्ट पर आधारित कस्टम बिडिंग एल्गोरिदम बनाने का उदाहरण यहां दिया गया है:
Java
// Create the custom bidding algorithm structure.
CustomBiddingAlgorithm customBiddingAlgorithm =
new CustomBiddingAlgorithm()
.setAdvertiserId(advertiser-id)
.setDisplayName(display-name)
.setEntityStatus("ENTITY_STATUS_ACTIVE")
.setCustomBiddingAlgorithmType("SCRIPT_BASED");
// Configure the create request.
CustomBiddingAlgorithms.Create request =
service.customBiddingAlgorithms().create(customBiddingAlgorithm);
// Create the custom bidding algorithm.
CustomBiddingAlgorithm response = request.execute();
// Display the new custom bidding algorithm name.
System.out.printf(
"Custom bidding algorithm %s was created.%n",
response.getName()
);
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=custom_bidding_algorithm_obj
).execute()
# Display the new custom bidding algorithm.
print(f'The following Custom Bidding Algorithm was created: {response}')
PHP
// Create a custom bidding algorithm object.
$customBiddingAlgorithm =
new Google_Service_DisplayVideo_CustomBiddingAlgorithm();
$customBiddingAlgorithm->setAdvertiserId(advertiser-id);
$customBiddingAlgorithm->setDisplayName(display-name);
$customBiddingAlgorithm->setEntityStatus('ENTITY_STATUS_ACTIVE');
$customBiddingAlgorithm->setCustomBiddingAlgorithmType('SCRIPT_BASED');
// Create the custom bidding algorithm.
$result =
$this->service->customBiddingAlgorithms->create($customBiddingAlgorithm);
// Display the new custom bidding algorithm name.
printf('Custom Bidding Algorithm %s was created.\n', $result['name']);
एल्गोरिदम का ऐक्सेस मैनेज करना
कस्टम बिडिंग एल्गोरिदम का मालिकाना हक, किसी पार्टनर या विज्ञापन देने वाले के पास हो सकता है. किसी पार्टनर के मालिकाना हक वाले एल्गोरिदम को, उस पार्टनर और sharedAdvertiserIds
फ़ील्ड में मौजूद किसी भी चाइल्ड विज्ञापन देने वाले के ज़रिए ऐक्सेस और बदला जा सकता है.
विज्ञापन देने वाले व्यक्ति या कंपनी के मालिकाना हक वाले एल्गोरिदम को, वह व्यक्ति या कंपनी और उसका पैरंट पार्टनर ऐक्सेस कर सकता है और उनमें बदलाव कर सकता है. हालांकि, उन्हें अन्य विज्ञापन देने वालों के साथ शेयर नहीं किया जा सकता.
अगर एल्गोरिदम का इस्तेमाल सिर्फ़ किसी एक विज्ञापन देने वाले के लिए किया जा रहा है, तो advertiserId
फ़ील्ड की मदद से, विज्ञापन देने वाले को मालिक के तौर पर असाइन करें.
इसके अलावा, विज्ञापन देने वाले के पैरंट पार्टनर को partnerId
फ़ील्ड की मदद से, मालिकाना हक असाइन करें. साथ ही, विज्ञापन देने वालों को sharedAdvertiserIds
फ़ील्ड की मदद से ऐक्सेस दें.
एल्गोरिदम लॉजिक अपलोड करना
कस्टम बिडिंग एल्गोरिदम के टाइप के आधार पर, आपको अगले चरण में स्क्रिप्ट या नियम ऑब्जेक्ट बनाना होगा. इसमें, एल्गोरिदम के इस्तेमाल के लिए लॉजिक दिया जा सकता है.
स्क्रिप्ट अपलोड करना
स्क्रिप्ट पर आधारित कस्टम बिडिंग एल्गोरिदम, उपयोगकर्ता की दी गई स्क्रिप्ट का इस्तेमाल करके इंप्रेशन की वैल्यू का आकलन करते हैं. साधारण स्क्रिप्ट के सैंपल और बेहतर फ़ील्ड की सूची, Display & Video 360 के सहायता केंद्र पर उपलब्ध है.
नीचे दिए गए सेक्शन में, कस्टम बिडिंग एल्गोरिदम में नई या अपडेट की गई स्क्रिप्ट जोड़ने का तरीका बताया गया है.
स्क्रिप्ट के संसाधन की जगह की जानकारी पाना
सबसे पहले, customBiddingAlgorithms.uploadScript
तरीके का इस्तेमाल करके, कस्टम बिडिंग एल्गोरिदम रिसॉर्स में उपलब्ध रिसॉर्स की जगह वापस पाएं. यह अनुरोध, संसाधन के नाम के साथ CustomBiddingScriptRef
ऑब्जेक्ट दिखाता है. अपनी स्क्रिप्ट फ़ाइल को उस जगह पर अपलोड किया जा सकता है जिसे संसाधन के नाम से तय किया गया है. इसके बाद, कस्टम बिडिंग स्क्रिप्ट रेफ़रंस ऑब्जेक्ट का इस्तेमाल करके,
अपना स्क्रिप्ट संसाधन बनाएं.
उपलब्ध संसाधन की जगह को वापस पाने का तरीका यहां बताया गया है:
Java
// Retrieve a usable custom bidding script
// reference.
CustomBiddingScriptRef scriptRef =
service
.customBiddingAlgorithms()
.uploadScript(custom-bidding-algorithm-id)
.setAdvertiserId(advertiser-id)
.execute();
// Display the custom bidding script reference resource path.
System.out.printf(
"The script can be uploaded to the following resource path: %s%n",
scriptRef.getResourceName()
);
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}')
PHP
// Set parent advertiser ID of custom bidding
// algorithm in optional parameters array for request.
$optParams = array('advertiserId' => advertiser-id);
// Retrieve a usable custom bidding script reference.
$scriptRefResponse = $this->service->customBiddingAlgorithms->uploadScript(
custom-bidding-algorithm-id,
$optParams
);
// Display the new custom bidding script reference object.
printf(
'The script can be uploaded to the following resource path: %s\n',
$scriptRefResponse->getResourceName()
);
स्क्रिप्ट फ़ाइल अपलोड करना
उपलब्ध संसाधन की जगह का पता लगाने के बाद, अपनी स्क्रिप्ट फ़ाइल को Display & Video 360 सिस्टम में उस जगह पर अपलोड करें. इसके लिए, media.upload
तरीका अपनाएं. इस तरीके से, सामान्य अपलोड किया जा सकता है. इसके लिए, क्वेरी पैरामीटर uploadType=media
की ज़रूरत होती है.
यहां, कस्टम बिडिंग स्क्रिप्ट के रेफ़रंस ऑब्जेक्ट को वापस लाने के बाद, स्क्रिप्ट फ़ाइल अपलोड करने का उदाहरण दिया गया है:
Java
// Create media object.
GoogleBytestreamMedia media = new GoogleBytestreamMedia();
media.setResourceName(resource-name);
// Create input stream for the script file.
InputStreamContent scriptFileStream =
new InputStreamContent(
null, new FileInputStream(script-path));
// Create media.upload request.
Media.Upload uploadRequest =
service
.media()
.upload(
resource-name,
media,
scriptFileStream);
// Retrieve uploader from the request and set it to us a simple
// upload request.
MediaHttpUploader uploader = uploadRequest.getMediaHttpUploader();
uploader.setDirectUploadEnabled(true);
// Execute the upload using an Upload URL with the destination resource
// name.
uploader
.upload(
new GenericUrl(
"https://displayvideo.googleapis.com/upload/media/"
+ resource-name));
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()
PHP
// Create a media object.
$mediaBody = new Google_Service_DisplayVideo_GoogleBytestreamMedia();
$mediaBody->setResourceName(resource-name);
// Set parameters for upload request.
$optParams = array(
'data' => file_get_contents(script-path),
'uploadType' => 'media',
'resourceName' => resource-name
);
// Upload script file to given resource location.
$this->service->media->upload(
resource-name,
$mediaBody,
$optParams
);
cURL
curl --request POST 'https://displayvideo.googleapis.com/upload/media/resource-name?uploadType=media'
-H 'authorization: Bearer access-token'
-H 'Content-Type: text/plain'
--data-binary @script-path
स्क्रिप्ट ऑब्जेक्ट बनाना
स्क्रिप्ट फ़ाइल अपलोड होने के बाद, customBiddingAlgorithms.scripts.create
तरीके का इस्तेमाल करके कस्टम बिडिंग स्क्रिप्ट संसाधन बनाएं. अनुरोध में पास किए गए CustomBiddingScript
ऑब्जेक्ट में, सिर्फ़ CustomBiddingScriptRef
ऑब्जेक्ट को script
फ़ील्ड की असाइन की गई वैल्यू के तौर पर शामिल किया जाना चाहिए. इससे, अपलोड की गई स्क्रिप्ट फ़ाइल को नए स्क्रिप्ट रिसॉर्स से जोड़ा जाता है.
स्क्रिप्ट रिसॉर्स बनाने का उदाहरण यहां दिया गया है:
Java
// Create the custom bidding script structure.
CustomBiddingScript customBiddingScript =
new CustomBiddingScript()
.setScript(custom-bidding-script-ref);
// Create the custom bidding script.
CustomBiddingScript response =
service
.customBiddingAlgorithms()
.scripts()
.create(custom-bidding-algorithm-id, customBiddingScript)
.setAdvertiserId(advertiser-id)
.execute();
// Display the new script resource name
System.out.printf(
"The following script was created: %s%n",
response.getName());
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}')
PHP
// Create the custom bidding script object.
$customBiddingScript =
new Google_Service_DisplayVideo_CustomBiddingScript();
$customBiddingScript->setScript(custom-bidding-script-ref);
// Set parameters for create script request.
$optParams = array(
'advertiserId' => advertiser-id
);
// Create the custom bidding script.
$result = $this->service->customBiddingAlgorithms_scripts->create(
custom-bidding-algorithm-id,
$customBiddingScript,
$optParams
);
// Display the new script resource name.
printf('The following script was created: %s.\n', $result->getName());
कस्टम बिडिंग स्क्रिप्ट का संसाधन बनाने के बाद, Display & Video 360 स्क्रिप्ट को प्रोसेस करता है, ताकि यह पक्का किया जा सके कि इंप्रेशन को स्कोर करने के लिए इसका इस्तेमाल किया जा सकता है.
स्क्रिप्ट ऑब्जेक्ट के state
फ़ील्ड की मदद से, प्रोसेसिंग की स्थिति देखें. नई स्क्रिप्ट स्वीकार होने के बाद, कस्टम बिडिंग एल्गोरिद्म, इंप्रेशन वैल्यू को स्कोर करने के लिए स्क्रिप्ट का इस्तेमाल शुरू कर देता है. यह तुरंत होता है. इसलिए, नया स्क्रिप्ट संसाधन बनाने से पहले, पक्का करें कि आपको एल्गोरिदम अपडेट करना है.
अपलोड करने के नियम
नियमों पर आधारित कस्टम बिडिंग एल्गोरिदम, किसी इंप्रेशन की वैल्यू का आकलन करने के लिए, AlgorithmRules
ऑब्जेक्ट में दिए गए लॉजिक का इस्तेमाल करते हैं.
AlgorithmRules
ऑब्जेक्ट, JSON फ़ाइल में अपलोड किए जाते हैं. इसके बाद, इन्हें CustomBiddingAlgorithmRules
ऑब्जेक्ट की मदद से कस्टम बिडिंग एल्गोरिदम से जोड़ा जाता है.
नियमों के संसाधन की जगह की जानकारी पाना
सबसे पहले, customBiddingAlgorithms.uploadRules
तरीके का इस्तेमाल करके, कस्टम बिडिंग एल्गोरिदम रिसॉर्स में उपलब्ध रिसॉर्स की जगह वापस पाएं. इस अनुरोध से, संसाधन का नाम वाला CustomBiddingAlgorithmsRulesRef
ऑब्जेक्ट मिलता है. संसाधन के नाम से तय की गई जगह पर, नियमों की फ़ाइल अपलोड की जा सकती है. इसके बाद, अपने नियमों का संसाधन बनाने के लिए, कस्टम बिडिंग एल्गोरिदम के नियमों के रेफ़रंस ऑब्जेक्ट का इस्तेमाल करें.
उपलब्ध संसाधन की जगह को वापस पाने का तरीका यहां बताया गया है:
Java
// Create the custom bidding algorithm structure.
CustomBiddingAlgorithmRulesRef rulesRef =
service
.customBiddingAlgorithms()
.uploadRules(custom-bidding-algorithm-id)
.setAdvertiserId(advertiser-id)
.execute();
System.out.printf(
"The rules can be uploaded to the following resource path: %s%n",
rulesRef.getResourceName()
);
Python
# Retrieve a usable custom bidding algorithm rules reference
# object.
custom_bidding_algorithm_rules_ref = service.customBiddingAlgorithms().uploadRules(
customBiddingAlgorithmId=custom-bidding-algorithm-id,
advertiserId=advertiser-id
).execute()
# Display the new custom bidding algorithm rules reference object.
print('The following custom bidding algorithm rules reference object was retrieved:'
f' {custom_bidding_algorithm_rules_ref}')
PHP
// Set parent advertiser ID of custom bidding algorithm
// in optional parameters array for request.
$optParams = array('advertiserId' => advertiser-id);
// Retrieve a usable custom bidding algorithm rules reference.
$rulesRefResponse = $this->service->customBiddingAlgorithms->uploadRules(
custom-bidding-algorithm-id,
$optParams
);
// Display the new custom bidding algorithm rules reference object resource path.
printf(
'The rules can be uploaded to the following resource path: %s\n',
$rulesRefResponse->getResourceName()
);
AlgorithmRules
फ़ाइल अपलोड करना
उपलब्ध संसाधन की जगह का पता लगाने के बाद, अपनी नियम फ़ाइल को Display & Video 360 सिस्टम में उस जगह पर अपलोड करें. इसके लिए, media.upload
तरीका अपनाएं. इस तरीके से, सामान्य अपलोड किया जा सकता है. इसके लिए, क्वेरी पैरामीटर uploadType=media
की ज़रूरत होती है.
यहां उदाहरण के तौर पर, AlgorithmRules
फ़ाइल को अपलोड करने का तरीका बताया गया है. इसके लिए, पहले बिडिंग के लिए कस्टम एल्गोरिदम के नियमों का रेफ़रंस ऑब्जेक्ट वापस पाना होगा:
Java
// Create media object.
GoogleBytestreamMedia media = new GoogleBytestreamMedia();
media.setResourceName(resource-name);
// Create input stream for the rules file.
InputStreamContent rulesFileStream =
new InputStreamContent(
null, new FileInputStream(rules-file-path));
// Create media.upload request.
Media.Upload uploadRequest =
service
.media()
.upload(
resource-name,
media,
rulesFileStream);
// Retrieve uploader from the request and set it to us a simple
// upload request.
MediaHttpUploader uploader = uploadRequest.getMediaHttpUploader();
uploader.setDirectUploadEnabled(true);
// Execute the upload using an Upload URL with the destination resource
// name.
uploader
.upload(
new GenericUrl(
"https://displayvideo.googleapis.com/upload/media/"
+ resource-name));
Python
# Create a media upload object.
media = MediaFileUpload(rules-file-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 rules file to resource location given in retrieved custom bidding
# algorithm rules reference object.
upload_request.execute()
PHP
// Create a media object.
$mediaBody = new Google_Service_DisplayVideo_GoogleBytestreamMedia();
$mediaBody->setResourceName(resource-name);
// Set parameters for upload request.
$optParams = array(
'data' => file_get_contents(rules-file-path),
'uploadType' => 'media',
'resourceName' => resource-name
);
// Upload rules file to given resource location.
$this->service->media->upload(
resource-name,
$mediaBody,
$optParams
);
cURL
curl --request POST 'https://displayvideo.googleapis.com/upload/media/resource-name?uploadType=media'
-H 'authorization: Bearer access-token'
-H 'Content-Type: text/plain'
--data-binary @rules-file-path
नियमों का ऑब्जेक्ट बनाना
AlgorithmRules
JSON फ़ाइल अपलोड होने के बाद, बिडिंग एल्गोरिदम के लिए कस्टम नियम वाला संसाधन बनाएं. इसके लिए, customBiddingAlgorithms.rules.create
तरीका अपनाएं. अनुरोध में पास किए गए CustomBiddingAlgorithmRules
ऑब्जेक्ट में, rules
फ़ील्ड की असाइन की गई वैल्यू के तौर पर सिर्फ़ CustomBiddingAlgorithmRulesRef
ऑब्जेक्ट शामिल होना चाहिए. इससे, अपलोड की गई AlgorithmRules
JSON फ़ाइल को नए नियमों वाले रिसॉर्स से जोड़ा जाता है.
नियमों का संसाधन बनाने का उदाहरण यहां दिया गया है:
Java
// Create the custom bidding algorithm rules structure.
CustomBiddingAlgorithmRules customBiddingAlgorithmRules =
new CustomBiddingAlgorithmRules()
.setRules(custom-bidding-algorithm-rules-ref);
// Create the rules resource.
CustomBiddingAlgorithmRules response =
service
.customBiddingAlgorithms()
.rules()
.create(custom-bidding-algorithm-id, customBiddingAlgorithmRules)
.setAdvertiserId(advertiser-id)
.execute();
// Display the new rules resource name.
System.out.printf(
"The following custom bidding algorithm rules object was created: %s%n",
response.getName());
Python
# Create the custom bidding algorithm rules object.
rules_obj = {
'rules': custom-bidding-algorithm-rules-ref
}
# Create the rules resource.
response = service.customBiddingAlgorithms().rules().create(
customBiddingAlgorithmId=custom-bidding-algorithm-id,
advertiserId=advertiser-id,
body=rules_obj).execute()
# Display the new custom bidding algorithm rules object.
print(f'The following custom bidding algorithm rules resource was created: {response}')
PHP
// Create the custom bidding algorithm rules object.
$customBiddingAlgorithmRules =
new Google_Service_DisplayVideo_CustomBiddingAlgorithmRules();
$customBiddingAlgorithmRules->setRules(custom-bidding-algorithm-rules-ref);
// Set parameters for create rules request.
$optParams = array(
'advertiserId' => advertiser-id
);
// Create the custom bidding algorithm rules resource.
$result = $this->service->customBiddingAlgorithms_rules->create(
custom-bidding-algorithm-id,
$customBiddingAlgorithmRules,
$optParams
);
// Display the new custom bidding algorithm rules resource name.
printf('The following rules resource was created: %s.\n', $result->getName());
नियमों का संसाधन बनाने के बाद, Display & Video 360 नियमों का सेट प्रोसेस करता है, ताकि यह पक्का किया जा सके कि इंप्रेशन को स्कोर करने के लिए इसका इस्तेमाल किया जा सकता है. नियम ऑब्जेक्ट के state
फ़ील्ड की मदद से, इस प्रोसेस की स्थिति पाएं.
नए नियमों को स्वीकार करने के बाद, कस्टम बिडिंग एल्गोरिदम, इंप्रेशन वैल्यू को तुरंत स्कोर करने के लिए नियमों का इस्तेमाल करना शुरू कर देता है.
अगर नियम अस्वीकार कर दिए जाते हैं, तो नियम ऑब्जेक्ट के error
से अस्वीकार होने की वजह देखें. अगर आपका अनुरोध अस्वीकार कर दिया जाता है, तो गड़बड़ी को ठीक करने के लिए अपने AlgorithmRules
ऑब्जेक्ट को अपडेट करें. इसके बाद, नियमों के रेफ़रंस ऑब्जेक्ट को फिर से पाने से शुरू करके, अपलोड की प्रोसेस को दोहराएं.
कस्टम बिडिंग एल्गोरिदम असाइन करना
कस्टम बिडिंग एल्गोरिदम बनाने, स्वीकार किए गए लॉजिक को अपलोड करने, और ज़रूरी शर्तें पूरी करने के बाद, अपने कस्टम बिडिंग एल्गोरिदम को किसी लाइन आइटम या इंसर्शन ऑर्डर की बिडिंग की रणनीति को असाइन किया जा सकता है.
खर्च बढ़ाएं और परफ़ॉर्मेंस लक्ष्य बिडिंग की रणनीतियों में कस्टम बिडिंग एल्गोरिदम का इस्तेमाल किया जा सकता है. इसके लिए, BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO
और कस्टम बिडिंग एल्गोरिदम आईडी को performanceGoalType
और customBiddingAlgorithmId
फ़ील्ड में असाइन करें.
बिडिंग की रणनीति के आधार पर, बिड के अन्य पैरामीटर उपलब्ध हो सकते हैं या ज़रूरी हो सकते हैं.
यहां दिए गए उदाहरण में, किसी कस्टम बिडिंग एल्गोरिदम के साथ, खर्च बढ़ाने के लिए बिडिंग की रणनीति का इस्तेमाल करने के लिए, लाइन आइटम को अपडेट करने का तरीका बताया गया है:
Java
// Create the line item structure.
LineItem lineItem = new LineItem();
// Create and set the bidding strategy structure.
BiddingStrategy biddingStrategy = new BiddingStrategy();
MaximizeSpendBidStrategy maxSpendBidStrategy =
new MaximizeSpendBidStrategy()
.setPerformanceGoalType(
"BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO")
.setCustomBiddingAlgorithmId(custom-bidding-algorithm-id);
biddingStrategy.setMaximizeSpendAutoBid(maxSpendBidStrategy);
lineItem.setBidStrategy(biddingStrategy);
// Configure the patch request and set update mask to only update
// the bid strategy.
LineItems.Patch request =
service
.advertisers()
.lineItems()
.patch(advertiser-id, line-item-id, lineItem)
.setUpdateMask("bidStrategy");
// Update the line item.
LineItem response = request.execute();
// Display the custom bidding algorithm ID used in the new
// bid strategy.
System.out.printf(
"LineItem %s now has a bid strategy utilizing custom "
+ "bidding algorithm %s%n",
response.getName(),
response
.getBidStrategy()
.getMaximizeSpendAutoBid()
.getCustomBiddingAlgorithmId());
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"]}.')
PHP
// Create the line item structure.
$lineItem = new Google_Service_DisplayVideo_LineItem();
// Create and set the bidding strategy structure.
$biddingStrategy = new Google_Service_DisplayVideo_BiddingStrategy();
$maximizeSpendBidStrategy =
new Google_Service_DisplayVideo_MaximizeSpendBidStrategy();
$maximizeSpendBidStrategy->setPerformanceGoalType(
'BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO'
);
$maximizeSpendBidStrategy->setCustomBiddingAlgorithmId(
custom-bidding-algorithm-id
);
$biddingStrategy->setMaximizeSpendAutoBid($maximizeSpendBidStrategy);
$lineItem->setBidStrategy($biddingStrategy);
// Set update mask.
$optParams = array('updateMask' => 'bidStrategy');
// Update the line item.
$result = $this->service->advertisers_lineItems->patch(
advertiser-id,
line-item-id,
$lineItem,
$optParams
);
// Display the custom bidding algorithm ID used in the new bid strategy.
printf(
'Line Item %s now has a bid strategy utilizing custom bidding algorithm %s.\n',
$result['name'],
$result['bidStrategy']['maximizeSpendBidStrategy']['customBiddingAlgorithmId']
);