/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> public void Run(AdWordsUser user) { // Get the BudgetService. BudgetService budgetService = (BudgetService) user.GetService(AdWordsService.v201601.BudgetService); // Get the CampaignService. CampaignService campaignService = (CampaignService) user.GetService(AdWordsService.v201601.CampaignService); // Create the campaign budget. Budget budget = new Budget(); budget.name = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(); budget.period = BudgetBudgetPeriod.DAILY; budget.deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD; budget.amount = new Money(); budget.amount.microAmount = 500000; BudgetOperation budgetOperation = new BudgetOperation(); budgetOperation.@operator = Operator.ADD; budgetOperation.operand = budget; try { BudgetReturnValue budgetRetval = budgetService.mutate( new BudgetOperation[] { budgetOperation }); budget = budgetRetval.value[0]; } catch (Exception e) { throw new System.ApplicationException("Failed to add shared budget.", e); } List<CampaignOperation> operations = new List<CampaignOperation>(); for (int i = 0; i < NUM_ITEMS; i++) { // Create the campaign. Campaign campaign = new Campaign(); campaign.name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(); campaign.status = CampaignStatus.PAUSED; campaign.advertisingChannelType = AdvertisingChannelType.SEARCH; BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); biddingConfig.biddingStrategyType = BiddingStrategyType.MANUAL_CPC; campaign.biddingStrategyConfiguration = biddingConfig; campaign.budget = new Budget(); campaign.budget.budgetId = budget.budgetId; // Set the campaign network options. campaign.networkSetting = new NetworkSetting(); campaign.networkSetting.targetGoogleSearch = true; campaign.networkSetting.targetSearchNetwork = true; campaign.networkSetting.targetContentNetwork = false; campaign.networkSetting.targetPartnerSearchNetwork = false; // Set the campaign settings for Advanced location options. GeoTargetTypeSetting geoSetting = new GeoTargetTypeSetting(); geoSetting.positiveGeoTargetType = GeoTargetTypeSettingPositiveGeoTargetType.DONT_CARE; geoSetting.negativeGeoTargetType = GeoTargetTypeSettingNegativeGeoTargetType.DONT_CARE; campaign.settings = new Setting[] { geoSetting }; // Optional: Set the start date. campaign.startDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd"); // Optional: Set the end date. campaign.endDate = DateTime.Now.AddYears(1).ToString("yyyyMMdd"); // Optional: Set the campaign ad serving optimization status. campaign.adServingOptimizationStatus = AdServingOptimizationStatus.ROTATE; // Optional: Set the frequency cap. FrequencyCap frequencyCap = new FrequencyCap(); frequencyCap.impressions = 5; frequencyCap.level = Level.ADGROUP; frequencyCap.timeUnit = TimeUnit.DAY; campaign.frequencyCap = frequencyCap; // Create the operation. CampaignOperation operation = new CampaignOperation(); operation.@operator = Operator.ADD; operation.operand = campaign; operations.Add(operation); } try { // Add the campaign. CampaignReturnValue retVal = campaignService.mutate(operations.ToArray()); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { foreach (Campaign newCampaign in retVal.value) { Console.WriteLine("Campaign with name = '{0}' and id = '{1}' was added.", newCampaign.name, newCampaign.id); } } else { Console.WriteLine("No campaigns were added."); } } catch (Exception e) { throw new System.ApplicationException("Failed to add campaigns.", e); } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> public void Run(AdWordsUser user) { // Get the CampaignService. BudgetService budgetService = (BudgetService)user.GetService(AdWordsService.v201409.BudgetService); // Get the CampaignService. CampaignService campaignService = (CampaignService)user.GetService(AdWordsService.v201409.CampaignService); // Create the campaign budget. Budget budget = new Budget(); budget.name = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(); budget.period = BudgetBudgetPeriod.DAILY; budget.deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD; budget.amount = new Money(); budget.amount.microAmount = 500000; BudgetOperation budgetOperation = new BudgetOperation(); budgetOperation.@operator = Operator.ADD; budgetOperation.operand = budget; try { BudgetReturnValue budgetRetval = budgetService.mutate(new BudgetOperation[] { budgetOperation }); budget = budgetRetval.value[0]; } catch (Exception ex) { throw new System.ApplicationException("Failed to add shared budget.", ex); } List <CampaignOperation> operations = new List <CampaignOperation>(); for (int i = 0; i < NUM_ITEMS; i++) { // Create the campaign. Campaign campaign = new Campaign(); campaign.name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(); campaign.status = CampaignStatus.PAUSED; campaign.advertisingChannelType = AdvertisingChannelType.SEARCH; BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); biddingConfig.biddingStrategyType = BiddingStrategyType.MANUAL_CPM; // Optional: also provide matching bidding scheme. biddingConfig.biddingScheme = new ManualCpmBiddingScheme(); campaign.biddingStrategyConfiguration = biddingConfig; // Set the campaign budget. campaign.budget = new Budget(); campaign.budget.budgetId = budget.budgetId; // Set targetContentNetwork true. Other network targeting is not available // for Ad Exchange Buyers. campaign.networkSetting = new NetworkSetting(); campaign.networkSetting.targetGoogleSearch = false; campaign.networkSetting.targetSearchNetwork = false; campaign.networkSetting.targetContentNetwork = true; campaign.networkSetting.targetPartnerSearchNetwork = false; // Enable campaign for Real-time bidding. RealTimeBiddingSetting rtbSetting = new RealTimeBiddingSetting(); rtbSetting.optIn = true; campaign.settings = new Setting[] { rtbSetting }; // Optional: Set the start date. campaign.startDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd"); // Optional: Set the end date. campaign.endDate = DateTime.Now.AddYears(1).ToString("yyyyMMdd"); // Optional: Set the campaign ad serving optimization status. campaign.adServingOptimizationStatus = AdServingOptimizationStatus.ROTATE; // Optional: Set the frequency cap. FrequencyCap frequencyCap = new FrequencyCap(); frequencyCap.impressions = 5; frequencyCap.level = Level.ADGROUP; frequencyCap.timeUnit = TimeUnit.DAY; campaign.frequencyCap = frequencyCap; // Create the operation. CampaignOperation operation = new CampaignOperation(); operation.@operator = Operator.ADD; operation.operand = campaign; operations.Add(operation); } try { // Add the campaign. CampaignReturnValue retVal = campaignService.mutate(operations.ToArray()); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { foreach (Campaign newCampaign in retVal.value) { Console.WriteLine("Campaign with name = '{0}' and id = '{1}' was added.", newCampaign.name, newCampaign.id); } } else { Console.WriteLine("No campaigns were added."); } } catch (Exception ex) { throw new System.ApplicationException("Failed to add campaigns.", ex); } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> public void Run(AdWordsUser user) { // Get the BudgetService. BudgetService budgetService = (BudgetService)user.GetService(AdWordsService.v201609.BudgetService); // Get the CampaignService. CampaignService campaignService = (CampaignService)user.GetService(AdWordsService.v201609.CampaignService); // Create the campaign budget. Budget budget = new Budget(); budget.name = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(); budget.deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD; budget.amount = new Money(); budget.amount.microAmount = 500000; BudgetOperation budgetOperation = new BudgetOperation(); budgetOperation.@operator = Operator.ADD; budgetOperation.operand = budget; try { BudgetReturnValue budgetRetval = budgetService.mutate( new BudgetOperation[] { budgetOperation }); budget = budgetRetval.value[0]; } catch (Exception e) { throw new System.ApplicationException("Failed to add shared budget.", e); } List <CampaignOperation> operations = new List <CampaignOperation>(); for (int i = 0; i < NUM_ITEMS; i++) { // Create the campaign. Campaign campaign = new Campaign(); campaign.name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(); campaign.advertisingChannelType = AdvertisingChannelType.SEARCH; // Recommendation: Set the campaign to PAUSED when creating it to prevent // the ads from immediately serving. Set to ENABLED once you've added // targeting and the ads are ready to serve. campaign.status = CampaignStatus.PAUSED; BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); biddingConfig.biddingStrategyType = BiddingStrategyType.MANUAL_CPC; campaign.biddingStrategyConfiguration = biddingConfig; campaign.budget = new Budget(); campaign.budget.budgetId = budget.budgetId; // Set the campaign network options. campaign.networkSetting = new NetworkSetting(); campaign.networkSetting.targetGoogleSearch = true; campaign.networkSetting.targetSearchNetwork = true; campaign.networkSetting.targetContentNetwork = false; campaign.networkSetting.targetPartnerSearchNetwork = false; // Set the campaign settings for Advanced location options. GeoTargetTypeSetting geoSetting = new GeoTargetTypeSetting(); geoSetting.positiveGeoTargetType = GeoTargetTypeSettingPositiveGeoTargetType.DONT_CARE; geoSetting.negativeGeoTargetType = GeoTargetTypeSettingNegativeGeoTargetType.DONT_CARE; campaign.settings = new Setting[] { geoSetting }; // Optional: Set the start date. campaign.startDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd"); // Optional: Set the end date. campaign.endDate = DateTime.Now.AddYears(1).ToString("yyyyMMdd"); // Optional: Set the campaign ad serving optimization status. campaign.adServingOptimizationStatus = AdServingOptimizationStatus.ROTATE; // Optional: Set the frequency cap. FrequencyCap frequencyCap = new FrequencyCap(); frequencyCap.impressions = 5; frequencyCap.level = Level.ADGROUP; frequencyCap.timeUnit = TimeUnit.DAY; campaign.frequencyCap = frequencyCap; // Create the operation. CampaignOperation operation = new CampaignOperation(); operation.@operator = Operator.ADD; operation.operand = campaign; operations.Add(operation); } try { // Add the campaign. CampaignReturnValue retVal = campaignService.mutate(operations.ToArray()); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { foreach (Campaign newCampaign in retVal.value) { Console.WriteLine("Campaign with name = '{0}' and id = '{1}' was added.", newCampaign.name, newCampaign.id); } } else { Console.WriteLine("No campaigns were added."); } } catch (Exception e) { throw new System.ApplicationException("Failed to add campaigns.", e); } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> public void Run(AdWordsUser user) { using (CampaignService campaignService = (CampaignService)user.GetService(AdWordsService.v201802.CampaignService)) { Budget budget = CreateBudget(user); List <CampaignOperation> operations = new List <CampaignOperation>(); for (int i = 0; i < NUM_ITEMS; i++) { // Create the campaign. Campaign campaign = new Campaign { name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(), advertisingChannelType = AdvertisingChannelType.SEARCH, // Recommendation: Set the campaign to PAUSED when creating it to prevent // the ads from immediately serving. Set to ENABLED once you've added // targeting and the ads are ready to serve. status = CampaignStatus.PAUSED }; BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration { biddingStrategyType = BiddingStrategyType.MANUAL_CPC }; campaign.biddingStrategyConfiguration = biddingConfig; campaign.budget = new Budget { budgetId = budget.budgetId }; // Set the campaign network options. campaign.networkSetting = new NetworkSetting { targetGoogleSearch = true, targetSearchNetwork = true, targetContentNetwork = false, targetPartnerSearchNetwork = false }; // Set the campaign settings for Advanced location options. GeoTargetTypeSetting geoSetting = new GeoTargetTypeSetting { positiveGeoTargetType = GeoTargetTypeSettingPositiveGeoTargetType.DONT_CARE, negativeGeoTargetType = GeoTargetTypeSettingNegativeGeoTargetType.DONT_CARE }; campaign.settings = new Setting[] { geoSetting }; // Optional: Set the start date. campaign.startDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd"); // Optional: Set the end date. campaign.endDate = DateTime.Now.AddYears(1).ToString("yyyyMMdd"); // Optional: Set the frequency cap. FrequencyCap frequencyCap = new FrequencyCap { impressions = 5, level = Level.ADGROUP, timeUnit = TimeUnit.DAY }; campaign.frequencyCap = frequencyCap; // Create the operation. CampaignOperation operation = new CampaignOperation { @operator = Operator.ADD, operand = campaign }; operations.Add(operation); } try { // Add the campaign. CampaignReturnValue retVal = campaignService.mutate(operations.ToArray()); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { foreach (Campaign newCampaign in retVal.value) { Console.WriteLine("Campaign with name = '{0}' and id = '{1}' was added.", newCampaign.name, newCampaign.id); } } else { Console.WriteLine("No campaigns were added."); } } catch (Exception e) { throw new System.ApplicationException("Failed to add campaigns.", e); } } }
public FrequencyCapOfStartingMinute(long _startingMinute, FrequencyCap _frequencyCap) { startingMinute = _startingMinute; frequencyCap = _frequencyCap; }