/// <summary>
        /// Creates the portfolio bidding strategy.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="name">The bidding strategy name.</param>
        /// <param name="bidCeiling">The bid ceiling amount in micros.</param>
        /// <param name="spendTarget">The spend target in micros.</param>
        /// <returns>The bidding strategy resource name.</returns>
        private string CreatePortfolioBiddingStrategy(GoogleAdsClient client,
                                                      long customerId, string name, long bidCeiling, long spendTarget)
        {
            // Get the BiddingStrategyService.
            BiddingStrategyServiceClient biddingStrategyService = client.GetService(
                Services.V1.BiddingStrategyService);

            // Create a portfolio bidding strategy.
            BiddingStrategy biddingStrategy = new BiddingStrategy()
            {
                Name = name,

                TargetSpend = new TargetSpend()
                {
                    // Optionally set additional bidding scheme parameters.
                    CpcBidCeilingMicros = bidCeiling,
                    TargetSpendMicros   = spendTarget
                }
            };

            // Create operation.
            BiddingStrategyOperation biddingOperation = new BiddingStrategyOperation()
            {
                Create = biddingStrategy
            };

            // Create the portfolio bidding strategy.
            MutateBiddingStrategiesResponse biddingResponse =
                biddingStrategyService.MutateBiddingStrategies(
                    customerId.ToString(), new BiddingStrategyOperation[] { biddingOperation });

            return(biddingResponse.Results[0].ResourceName);
        }
 /// <summary>Snippet for MutateBiddingStrategies</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateBiddingStrategies()
 {
     // Create client
     BiddingStrategyServiceClient biddingStrategyServiceClient = BiddingStrategyServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <BiddingStrategyOperation> operations = new BiddingStrategyOperation[]
     {
         new BiddingStrategyOperation(),
     };
     // Make the request
     MutateBiddingStrategiesResponse response = biddingStrategyServiceClient.MutateBiddingStrategies(customerId, operations);
 }
Example #3
0
 /// <summary>Snippet for MutateBiddingStrategies</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateBiddingStrategiesRequestObject()
 {
     // Create client
     BiddingStrategyServiceClient biddingStrategyServiceClient = BiddingStrategyServiceClient.Create();
     // Initialize request argument(s)
     MutateBiddingStrategiesRequest request = new MutateBiddingStrategiesRequest
     {
         CustomerId = "",
         Operations =
         {
             new BiddingStrategyOperation(),
         },
         PartialFailure = false,
         ValidateOnly   = false,
     };
     // Make the request
     MutateBiddingStrategiesResponse response = biddingStrategyServiceClient.MutateBiddingStrategies(request);
 }
 /// <summary>Snippet for MutateBiddingStrategies</summary>
 public void MutateBiddingStrategiesRequestObject()
 {
     // Snippet: MutateBiddingStrategies(MutateBiddingStrategiesRequest, CallSettings)
     // Create client
     BiddingStrategyServiceClient biddingStrategyServiceClient = BiddingStrategyServiceClient.Create();
     // Initialize request argument(s)
     MutateBiddingStrategiesRequest request = new MutateBiddingStrategiesRequest
     {
         CustomerId = "",
         Operations =
         {
             new BiddingStrategyOperation(),
         },
         PartialFailure      = false,
         ValidateOnly        = false,
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
     };
     // Make the request
     MutateBiddingStrategiesResponse response = biddingStrategyServiceClient.MutateBiddingStrategies(request);
     // End snippet
 }
Example #5
0
        // [START create_cross_account_strategy]
        /// <summary>
        /// Creates a new TargetSpend (Maximize Clicks) cross-account bidding strategy in the
        /// specified manager account.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="managerCustomerId">The manager customer ID.</param>
        /// <returns>The resource name of the newly created bidding strategy.</returns>
        private string CreateBiddingStrategy(GoogleAdsClient client, long managerCustomerId)
        {
            BiddingStrategyServiceClient biddingStrategyServiceClient =
                client.GetService(Services.V10.BiddingStrategyService);

            // Create a portfolio bidding strategy.
            // [START set_currency_code]
            BiddingStrategy portfolioBiddingStrategy = new BiddingStrategy
            {
                Name        = $"Maximize clicks #{ExampleUtilities.GetRandomString()}",
                TargetSpend = new TargetSpend(),
                // Set the currency of the new bidding strategy. If not provided, the bidding
                // strategy uses the manager account's default currency.
                CurrencyCode = "USD"
            };
            // [END set_currency_code]

            // Send a create operation that will create the portfolio bidding strategy.
            MutateBiddingStrategiesResponse mutateBiddingStrategiesResponse =
                biddingStrategyServiceClient.MutateBiddingStrategies(managerCustomerId.ToString(),
                                                                     new[]
            {
                new BiddingStrategyOperation
                {
                    Create = portfolioBiddingStrategy
                }
            });

            // Print and return the resource name of the newly created cross-account bidding
            // strategy.
            string biddingStrategyResourceName =
                mutateBiddingStrategiesResponse.Results.First().ResourceName;

            Console.WriteLine("Created cross-account bidding strategy " +
                              $"'{biddingStrategyResourceName}'.");

            return(biddingStrategyResourceName);
        }