يتم إنشاء خوارزمية عروض أسعار مخصّصة من منطق عروض الأسعار الذي يحدّده المستخدم. يمكنك تعيينها إلى عنصر حملة من خلال استراتيجية عروض الأسعار. عند تقديم عروض أسعار على مساحات إعلانية متاحة، سيستخدم البند الإعلاني بعد ذلك هذا المنطق المخصّص.
أولاً، اختَر نوع خوارزمية وأنشِئ مرجع الخوارزمية.
اختيار نوع خوارزمية عروض أسعار مخصّصة
يحدد نوع الخوارزمية طريقة تحديد منطق عروض الأسعار في الخوارزمية.
اختَر أحد الأنواع التالية التي يمكن إنشاؤها من خلال واجهة برمجة التطبيقات الخاصة بـ "مساحة العرض والفيديو 360":
SCRIPT_BASED: منطق تم ضبطه بواسطة نص برمجي تم تحميله. النص البرمجي هو ملف نصي يستخدم بنية Python الأساسية.RULE_BASED: منطق تم ضبطه بواسطة مجموعة قواعد تم تحميلها مجموعة القواعد هي ملفAlgorithmRulesJSON تم تحميله.
إنشاء مورد CustomBiddingAlgorithm
استخدِم طلب create لإنشاء خوارزمية عروض أسعار مخصّصة.
يمكن أن يكون المعلِن أو الشريك owner لخوارزمية. إذا كان الحساب مملوكًا لأحد المعلِنين، لا يمكن استخدامه إلا في الحملات الإعلانية التابعة لهذا المعلِن. إذا كان الجمهور مملوكًا لشريك، لا يمكن للمعلنين استخدامه إلا إذا تم مشاركته معهم عن قصد.
في ما يلي كيفية إنشاء خوارزمية عروض أسعار مخصّصة:
جافا
// 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']);