يمكن ضبط عروض الأسعار على مستويات مختلفة من التسلسل الهرمي للحملة: الحملة أو المجموعة الإعلانية أو معيار المجموعة الإعلانية. عرض السعر الذي يتم تحديده على مستوى أدنى يلغي عروض الأسعار التي يتم تحديدها على مستويات أعلى. على سبيل المثال، يؤدي عرض السعر المحدّد لمجموعة إعلانية فردية ضمن حملة إلى إلغاء عرض السعر الخاص باستراتيجية عروض الأسعار على مستوى الحملة.
تحديث عروض الأسعار
يمكن ضبط عروض أسعار متعددة من أنواع مختلفة في الوقت نفسه، على سبيل المثال، يمكن ضبط كل من cpc_bid_micros وcpm_bid_micros، ولكن يتم استخدام عرض السعر ذي الصلة بنوع استراتيجية عروض الأسعار المحدّد فقط.
عند تعديل عروض الأسعار، يجب تضمين عروض الأسعار التي تريد تعديلها فقط. ستعدّل "إعلانات Google" عروض الأسعار هذه بدون تغيير عروض الأسعار الأخرى أو إضافة عروض أسعار أو إزالتها.
يعدّل مثال الرمز البرمجي التالي عرض سعر النقرة لمجموعة إعلانية حالية:
جافا
public static void main(String[] args) { UpdateAdGroupParams params = new UpdateAdGroupParams(); if (!params.parseArguments(args)) { // Either pass the required parameters for this example on the command line, or insert them // into the code here. See the parameter class definition above for descriptions. params.customerId = Long.parseLong("INSERT_CUSTOMER_ID_HERE"); params.adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE"); params.cpcBidMicroAmount = Long.parseLong("INSERT_CPC_BID_MICRO_AMOUNT_HERE"); } GoogleAdsClient googleAdsClient = null; try { googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build(); } catch (FileNotFoundException fnfe) { System.err.printf( "Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe); System.exit(1); } catch (IOException ioe) { System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe); System.exit(1); } try { new UpdateAdGroup() .runExample( googleAdsClient, params.customerId, params.adGroupId, params.cpcBidMicroAmount); } catch (GoogleAdsException gae) { // GoogleAdsException is the base class for most exceptions thrown by an API request. // Instances of this exception have a message and a GoogleAdsFailure that contains a // collection of GoogleAdsErrors that indicate the underlying causes of the // GoogleAdsException. System.err.printf( "Request ID %s failed due to GoogleAdsException. Underlying errors:%n", gae.getRequestId()); int i = 0; for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) { System.err.printf(" Error %d: %s%n", i++, googleAdsError); } System.exit(1); } }
#C
public void Run(GoogleAdsClient client, long customerId, long adGroupId, long? cpcBidMicroAmount) { AdGroupServiceClient adGroupService = client.GetService(Services.V25.AdGroupService); // Create an ad group with the specified ID. AdGroup adGroup = new AdGroup(); adGroup.ResourceName = ResourceNames.AdGroup(customerId, adGroupId); // Pause the ad group. adGroup.Status = AdGroupStatusEnum.Types.AdGroupStatus.Paused; // Update the CPC bid if specified. if (cpcBidMicroAmount != null) { adGroup.CpcBidMicros = cpcBidMicroAmount.Value; } // Create the operation. AdGroupOperation operation = new AdGroupOperation() { Update = adGroup, UpdateMask = FieldMasks.AllSetFieldsOf(adGroup) }; try { // Update the ad group. MutateAdGroupsResponse retVal = adGroupService.MutateAdGroups( customerId.ToString(), new AdGroupOperation[] { operation }); // Display the results. MutateAdGroupResult adGroupResult = retVal.Results[0]; Console.WriteLine($"Ad group with resource name '{adGroupResult.ResourceName}' " + "was updated."); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
PHP
public static function runExample( GoogleAdsClient $googleAdsClient, int $customerId, int $adGroupId, $bidMicroAmount ) { // Creates an ad group object with the specified resource name and other changes. $adGroup = new AdGroup([ 'resource_name' => ResourceNames::forAdGroup($customerId, $adGroupId), 'cpc_bid_micros' => $bidMicroAmount, 'status' => AdGroupStatus::PAUSED ]); // Constructs an operation that will update the ad group with the specified resource name, // using the FieldMasks utility to derive the update mask. This mask tells the Google Ads // API which attributes of the ad group you want to change. $adGroupOperation = new AdGroupOperation(); $adGroupOperation->setUpdate($adGroup); $adGroupOperation->setUpdateMask(FieldMasks::allSetFieldsOf($adGroup)); // Issues a mutate request to update the ad group. $adGroupServiceClient = $googleAdsClient->getAdGroupServiceClient(); $response = $adGroupServiceClient->mutateAdGroups(MutateAdGroupsRequest::build( $customerId, [$adGroupOperation] )); // Prints the resource name of the updated ad group. /** @var AdGroup $updatedAdGroup */ $updatedAdGroup = $response->getResults()[0]; printf( "Updated ad group with resource name: '%s'%s", $updatedAdGroup->getResourceName(), PHP_EOL ); }
Python
def main( client: GoogleAdsClient, customer_id: str, ad_group_id: str, cpc_bid_micro_amount: int, ) -> None: ad_group_service: AdGroupServiceClient = client.get_service( "AdGroupService" ) # Create ad group operation. ad_group_operation: AdGroupOperation = client.get_type("AdGroupOperation") ad_group: AdGroup = ad_group_operation.update ad_group.resource_name = ad_group_service.ad_group_path( customer_id, ad_group_id ) ad_group.status = client.enums.AdGroupStatusEnum.PAUSED ad_group.cpc_bid_micros = cpc_bid_micro_amount client.copy_from( ad_group_operation.update_mask, protobuf_helpers.field_mask(None, ad_group._pb), ) operations: List[AdGroupAdOperation] = [ad_group_operation] # Update the ad group. ad_group_response: MutateAdGroupsResponse = ( ad_group_service.mutate_ad_groups( customer_id=customer_id, operations=operations, ) ) print(f"Updated ad group {ad_group_response.results[0].resource_name}.")
Ruby
def update_ad_group(customer_id, ad_group_id, bid_micro_amount) # GoogleAdsClient will read a config file from # ENV['HOME']/google_ads_config.rb when called without parameters client = Google::Ads::GoogleAds::GoogleAdsClient.new resource_name = client.path.ad_group(customer_id, ad_group_id) operation = client.operation.update_resource.ad_group(resource_name) do |ag| ag.status = :PAUSED ag.cpc_bid_micros = bid_micro_amount end response = client.service.ad_group.mutate_ad_groups( customer_id: customer_id, operations: [operation], ) puts "Ad group with resource name = '#{response.results.first.resource_name}' was updated." end
Perl
sub update_ad_group { my ($api_client, $customer_id, $ad_group_id, $cpc_bid_micro_amount) = @_; # Create an ad group with the proper resource name and any other changes. my $ad_group = Google::Ads::GoogleAds::V25::Resources::AdGroup->new({ resourceName => Google::Ads::GoogleAds::V25::Utils::ResourceNames::ad_group( $customer_id, $ad_group_id ), status => PAUSED, cpcBidMicros => $cpc_bid_micro_amount }); # Create an ad group operation for update, using the FieldMasks utility to # derive the update mask. my $ad_group_operation = Google::Ads::GoogleAds::V25::Services::AdGroupService::AdGroupOperation-> new({ update => $ad_group, updateMask => all_set_fields_of($ad_group)}); # Update the ad group. my $ad_groups_response = $api_client->AdGroupService()->mutate({ customerId => $customer_id, operations => [$ad_group_operation]}); printf "Updated ad group with resource name: '%s'.\n", $ad_groups_response->{results}[0]{resourceName}; return 1; }
curl
إزالة عروض الأسعار
لإزالة عرض سعر بديل (على سبيل المثال، cpc_bid_micros في AdGroupCriterion)، أرسِل عملية تعديل حيث يتم ترك حقل عرض السعر بدون ضبط في عنصر المورد (أو يتم ضبطه على null في JSON) ويتم تضمين مسار حقل عرض السعر بشكل صريح في update_mask (FieldMask) للعملية.
سمات معايير "الشبكة الإعلانية"
بالنسبة إلى الإعلانات التي يتم عرضها على "شبكة Google الإعلانية"، هناك عدد من السمات المختلفة التي يمكن ضبط عرض أسعار المجموعة الإعلانية لها. في حال ضبط عروض أسعار متعدّدة في سمات مختلفة، يمكن استخدام الحقل display_custom_bid_dimension لتحديد السمة التي يجب استخدامها لعروض الأسعار المطلقة. تستخدِم الإعلانات على "شبكة البحث" دائمًا عروض أسعار الكلمات الرئيسية.
يمكنك أيضًا ضبط تعديل عرض الأسعار ليتم استخدامه عندما لا يكون المعيار في سمة عرض أسعار مطلقة. يمكن الوصول إليه باستخدام الحقل bid_modifier لمعيار المجموعة الإعلانية.