নীচে একটি উদাহরণ দেওয়া হল যে কীভাবে একটি MutateOperation
তৈরি করা যায় যা একটি স্মার্ট প্রচারাভিযানের জন্য একটি নতুন CampaignBudget
তৈরি করে৷ এই ক্রিয়াকলাপটি একটি স্মার্ট প্রচারাভিযান তৈরি করার জন্য প্রয়োজনীয় অন্যান্য সংস্থাগুলির সাথে একটি একক মিউটেট অনুরোধে ব্যবহার করা হবে৷
স্মার্ট ক্যাম্পেইন বাজেটের জন্য মূল প্রয়োজনীয়তা:
- একটি স্মার্ট ক্যাম্পেইন বাজেট একাধিক ক্যাম্পেইনের সাথে শেয়ার করা যাবে না।
-
type
অবশ্যইBudgetTypeEnum.SMART_CAMPAIGN
এ সেট করতে হবে।
জাভা
private MutateOperation createCampaignBudgetOperation(long customerId, long dailyBudgetMicros) { MutateOperation.Builder builder = MutateOperation.newBuilder(); builder .getCampaignBudgetOperationBuilder() .getCreateBuilder() .setName("Smart campaign budget " + CodeSampleHelper.getShortPrintableDateTime()) .setDeliveryMethod(BudgetDeliveryMethod.STANDARD) // A budget used for Smart campaigns must have the type SMART_CAMPAIGN. .setType(BudgetType.SMART_CAMPAIGN) // The suggested budget amount from the SmartCampaignSuggestService is for a _daily_ budget. // We don't need to specify that here, because the budget period already defaults to DAILY. .setAmountMicros(dailyBudgetMicros) // Sets a temporary ID in the budget's resource name so it can be referenced by the campaign // in later steps. .setResourceName(ResourceNames.campaignBudget(customerId, BUDGET_TEMPORARY_ID)); return builder.build(); }
সি#
/// <summary> /// Creates a MutateOperation that creates a new CampaignBudget. /// A temporary ID will be assigned to this campaign budget so that it can be referenced by /// other objects being created in the same Mutate request. /// </summary> /// <param name="customerId">The Google Ads customer ID.</param> /// <param name="suggestedBudgetAmount">A daily amount budget in micros.</param> /// <returns>A MutateOperation that creates a CampaignBudget</returns> private MutateOperation CreateCampaignBudgetOperation(long customerId, long suggestedBudgetAmount) { return new MutateOperation { CampaignBudgetOperation = new CampaignBudgetOperation { Create = new CampaignBudget { Name = $"Smart campaign budget #{ExampleUtilities.GetRandomString()}", // A budget used for Smart campaigns must have the type SMART_CAMPAIGN. Type = BudgetType.SmartCampaign, // The suggested budget amount from the SmartCampaignSuggestService is a // daily budget. We don't need to specify that here, because the budget // period already defaults to DAILY. AmountMicros = suggestedBudgetAmount, // Set a temporary ID in the budget's resource name so it can be referenced // by the campaign in later steps. ResourceName = ResourceNames.CampaignBudget( customerId, BUDGET_TEMPORARY_ID) } } }; }
পিএইচপি
private static function createCampaignBudgetOperation( int $customerId, int $suggestedBudgetAmount ): MutateOperation { // Creates the campaign budget object. $campaignBudget = new CampaignBudget([ 'name' => "Smart campaign budget #" . Helper::getPrintableDatetime(), // A budget used for Smart campaigns must have the type SMART_CAMPAIGN. 'type' => BudgetType::SMART_CAMPAIGN, // The suggested budget amount from the SmartCampaignSuggestService is a daily budget. // We don't need to specify that here, because the budget period already defaults to // DAILY. 'amount_micros' => $suggestedBudgetAmount, // Sets a temporary ID in the budget's resource name so it can be referenced by the // campaign in later steps. 'resource_name' => ResourceNames::forCampaignBudget($customerId, self::BUDGET_TEMPORARY_ID) ]); // Creates the MutateOperation that creates the campaign budget. return new MutateOperation([ 'campaign_budget_operation' => new CampaignBudgetOperation([ 'create' => $campaignBudget ]) ]); }
পাইথন
def create_campaign_budget_operation( client, customer_id, suggested_budget_amount ): """Creates a MutateOperation that creates a new CampaignBudget. A temporary ID will be assigned to this campaign budget so that it can be referenced by other objects being created in the same Mutate request. Args: client: an initialized GoogleAdsClient instance. customer_id: a client customer ID. suggested_budget_amount: a numeric daily budget amount in micros. Returns: a MutateOperation that creates a CampaignBudget. """ mutate_operation = client.get_type("MutateOperation") campaign_budget_operation = mutate_operation.campaign_budget_operation campaign_budget = campaign_budget_operation.create campaign_budget.name = f"Smart campaign budget #{uuid4()}" # A budget used for Smart campaigns must have the type SMART_CAMPAIGN. # Note that the field name "type_" is an implementation detail in Python, # the field's actual name is "type". campaign_budget.type_ = client.enums.BudgetTypeEnum.SMART_CAMPAIGN # The suggested budget amount from the SmartCampaignSuggestService is # a daily budget. We don't need to specify that here, because the budget # period already defaults to DAILY. campaign_budget.amount_micros = suggested_budget_amount # Set a temporary ID in the budget's resource name so it can be referenced # by the campaign in later steps. campaign_budget.resource_name = client.get_service( "CampaignBudgetService" ).campaign_budget_path(customer_id, _BUDGET_TEMPORARY_ID) return mutate_operation
রুবি
# Creates a mutate_operation that creates a new campaign_budget. # A temporary ID will be assigned to this campaign budget so that it can be # referenced by other objects being created in the same mutate request. def create_campaign_budget_operation( client, customer_id, suggested_budget_amount) mutate_operation = client.operation.mutate do |m| m.campaign_budget_operation = client.operation.create_resource.campaign_budget do |cb| cb.name = "Smart campaign budget ##{(Time.new.to_f * 1000).to_i}" # A budget used for Smart campaigns must have the type SMART_CAMPAIGN. cb.type = :SMART_CAMPAIGN # The suggested budget amount from the smart_campaign_suggest_service is # a daily budget. We don't need to specify that here, because the budget # period already defaults to DAILY. cb.amount_micros = suggested_budget_amount # Sets a temporary ID in the budget's resource name so it can be referenced # by the campaign in later steps. cb.resource_name = client.path.campaign_budget(customer_id, BUDGET_TEMPORARY_ID) end end mutate_operation end
পার্ল
# Creates a MutateOperation that creates a new CampaignBudget. # A temporary ID will be assigned to this campaign budget so that it can be # referenced by other objects being created in the same Mutate request. sub _create_campaign_budget_operation { my ($customer_id, $suggested_budget_amount) = @_; return Google::Ads::GoogleAds::V17::Services::GoogleAdsService::MutateOperation-> new({ campaignBudgetOperation => Google::Ads::GoogleAds::V17::Services::CampaignBudgetService::CampaignBudgetOperation ->new({ create => Google::Ads::GoogleAds::V17::Resources::CampaignBudget->new({ name => "Smart campaign budget #" . uniqid(), # A budget used for Smart campaigns must have the type SMART_CAMPAIGN. type => Google::Ads::GoogleAds::V17::Enums::BudgetTypeEnum::SMART_CAMPAIGN, # The suggested budget amount from the SmartCampaignSuggestService is # a daily budget. We don't need to specify that here, because the # budget period already defaults to DAILY. amountMicros => $suggested_budget_amount, # Set a temporary ID in the budget's resource name so it can be # referenced by the campaign in later steps. resourceName => Google::Ads::GoogleAds::V17::Utils::ResourceNames::campaign_budget( $customer_id, BUDGET_TEMPORARY_ID )})})}); }