/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="adGroupId">Id of the ad group to be updated.</param> public void Run(AdWordsUser user, long adGroupId) { using (AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201705.AdGroupService)) { // Create the ad group. AdGroup adGroup = new AdGroup(); adGroup.status = AdGroupStatus.PAUSED; adGroup.id = adGroupId; // Create the operation. AdGroupOperation operation = new AdGroupOperation(); operation.@operator = Operator.SET; operation.operand = adGroup; try { // Update the ad group. AdGroupReturnValue retVal = adGroupService.mutate(new AdGroupOperation[] { operation }); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { AdGroup pausedAdGroup = retVal.value[0]; Console.WriteLine("Ad group with id = '{0}' was successfully updated.", pausedAdGroup.id); } else { Console.WriteLine("No ad groups were updated."); } } catch (Exception e) { throw new System.ApplicationException("Failed to update ad group.", e); } } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="adGroupId">Id of the ad group to be removed.</param> public void Run(AdWordsUser user, long adGroupId) { using (AdGroupService adGroupService = (AdGroupService)user.GetService( AdWordsService.v201702.AdGroupService)) { // Create ad group with REMOVED status. AdGroup adGroup = new AdGroup(); adGroup.id = adGroupId; adGroup.status = AdGroupStatus.REMOVED; // Create the operation. AdGroupOperation operation = new AdGroupOperation(); operation.operand = adGroup; operation.@operator = Operator.SET; try { // Remove the ad group. AdGroupReturnValue retVal = adGroupService.mutate(new AdGroupOperation[] { operation }); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { AdGroup removedAdGroup = retVal.value[0]; Console.WriteLine("Ad group with id = \"{0}\" and name = \"{1}\" was removed.", removedAdGroup.id, removedAdGroup.name); } else { Console.WriteLine("No ad groups were removed."); } } catch (Exception e) { throw new System.ApplicationException("Failed to remove ad group.", e); } } }
/// <summary> /// Creates the ad group in a Shopping campaign. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">The campaign ID.</param> /// <returns>The ad group.</returns> private static AdGroup CreateAdGroup(AdWordsUser user, long campaignId) { using (AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201809.AdGroupService)) { // Create ad group. AdGroup adGroup = new AdGroup { campaignId = campaignId, name = "Ad Group #" + ExampleUtilities.GetRandomString() }; // Create operation. AdGroupOperation operation = new AdGroupOperation { operand = adGroup, @operator = Operator.ADD }; // Make the mutate request. AdGroupReturnValue retval = adGroupService.mutate(new AdGroupOperation[] { operation }); return(retval.value[0]); } }
/// <summary> /// Creates a test ad group for running further tests. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">The campaign id for which the adgroup is created.</param> /// <param name="adGroupType">The ad group type.</param> /// <param name="isCpmBid">True, if a ManualCPM bid is to be used.</param> /// <returns>The ad group ID.</returns> public long CreateAdGroup(AdWordsUser user, long campaignId, AdGroupType adGroupType, bool isCpmBid) { AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201806.AdGroupService); AdGroupOperation adGroupOperation = new AdGroupOperation(); adGroupOperation.@operator = Operator.ADD; adGroupOperation.operand = new AdGroup(); adGroupOperation.operand.campaignId = campaignId; adGroupOperation.operand.name = string.Format("AdGroup {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff")); adGroupOperation.operand.status = AdGroupStatus.ENABLED; if (adGroupType != AdGroupType.UNKNOWN) { adGroupOperation.operand.adGroupType = adGroupType; } if (isCpmBid) { BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); CpmBid cpmBid = new CpmBid(); cpmBid.bid = new Money(); cpmBid.bid.microAmount = 10000000; biddingConfig.bids = new Bids[] { cpmBid }; adGroupOperation.operand.biddingStrategyConfiguration = biddingConfig; } else { BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); CpcBid cpcBid = new CpcBid(); cpcBid.bid = new Money(); cpcBid.bid.microAmount = 10000000; biddingConfig.bids = new Bids[] { cpcBid }; adGroupOperation.operand.biddingStrategyConfiguration = biddingConfig; } AdGroupReturnValue retVal = adGroupService.mutate(new AdGroupOperation[] { adGroupOperation }); return(retVal.value[0].id); }
/// <summary> /// Creates an ad group. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">The campaign ID.</param> /// <returns>the newly created ad group.</returns> private static AdGroup CreateAdGroup(AdWordsUser user, long campaignId) { using (AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201806.AdGroupService)) { // Create the ad group. AdGroup adGroup = new AdGroup { // Required: Set the ad group's type to Dynamic Search Ads. adGroupType = AdGroupType.SEARCH_DYNAMIC_ADS, name = string.Format("Earth to Mars Cruises #{0}", ExampleUtilities.GetRandomString()), campaignId = campaignId, status = AdGroupStatus.PAUSED, // Recommended: Set a tracking URL template for your ad group if you want to use URL // tracking software. trackingUrlTemplate = "http://tracker.example.com/traveltracker/{escapedlpurl}" }; // Set the ad group bids. BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); CpcBid cpcBid = new CpcBid { bid = new Money { microAmount = 3000000 } }; biddingConfig.bids = new Bids[] { cpcBid }; adGroup.biddingStrategyConfiguration = biddingConfig; // Create the operation. AdGroupOperation operation = new AdGroupOperation { @operator = Operator.ADD, operand = adGroup }; try { // Create the ad group. AdGroupReturnValue retVal = adGroupService.mutate(new AdGroupOperation[] { operation }); // Display the results. AdGroup newAdGroup = retVal.value[0]; Console.WriteLine("Ad group with id = '{0}' and name = '{1}' was created.", newAdGroup.id, newAdGroup.name); return(newAdGroup); } catch (Exception e) { throw new System.ApplicationException("Failed to create ad group.", e); } } }
/// <summary> /// Creates the ad group in a Shopping campaign. /// </summary> /// <param name="user">The AdWords user for which the ad group is created.</param> /// <param name="campaign">The Shopping campaign.</param> /// <returns>The newly created ad group.</returns> private static AdGroup CreateAdGroup(AdWordsUser user, Campaign campaign) { using (AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201809.AdGroupService)) { // Create ad group. AdGroup adGroup = new AdGroup { campaignId = campaign.id, name = "Ad Group #" + ExampleUtilities.GetRandomString(), // Required: Set the ad group type to SHOPPING_SHOWCASE_ADS. adGroupType = AdGroupType.SHOPPING_SHOWCASE_ADS }; // Required: Set the ad group's bidding strategy configuration. BiddingStrategyConfiguration biddingConfiguration = new BiddingStrategyConfiguration { // Optional: Set the bids. bids = new Bids[] { new CpcBid() { bid = new Money() { microAmount = 100000 } } } }; adGroup.biddingStrategyConfiguration = biddingConfiguration; // Create the operation. AdGroupOperation operation = new AdGroupOperation { operand = adGroup, @operator = Operator.ADD }; // Make the mutate request. AdGroupReturnValue retval = adGroupService.mutate(new AdGroupOperation[] { operation }); return(retval.value[0]); } }
/// <summary> /// Creates an ad group in the specified campaign. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaign">The campaign to which the ad group should be attached.</param> /// <returns>The ad group that was created.</returns> private static AdGroup CreateAdGroup(AdWordsUser user, Campaign campaign) { using (AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201806.AdGroupService)) { AdGroup group = new AdGroup(); group.name = "Dynamic remarketing ad group"; group.campaignId = campaign.id; group.status = AdGroupStatus.ENABLED; AdGroupOperation op = new AdGroupOperation(); op.operand = group; op.@operator = Operator.ADD; AdGroupReturnValue result = adGroupService.mutate(new AdGroupOperation[] { op }); return(result.value[0]); } }
/// <summary> /// Creates the ad group in a Shopping campaign. /// </summary> /// <param name="adGroupService">The AdGroupService instance.</param> /// <param name="campaign">The Shopping campaign.</param> /// <returns>The ad group.</returns> private static AdGroup CreateAdGroup(AdGroupService adGroupService, Campaign campaign) { // Create ad group. AdGroup adGroup = new AdGroup(); adGroup.campaignId = campaign.id; adGroup.name = "Ad Group #" + ExampleUtilities.GetRandomString(); // Create operation. AdGroupOperation operation = new AdGroupOperation(); operation.operand = adGroup; operation.@operator = Operator.ADD; // Make the mutate request. AdGroupReturnValue retval = adGroupService.mutate(new AdGroupOperation[] { operation }); return(retval.value[0]); }
/// <summary> /// Creates the ad group in a Shopping campaign. /// </summary> /// <param name="user">The AdWords user for which the ad group is created.</param> /// <param name="campaign">The Shopping campaign.</param> /// <returns>The newly created ad group.</returns> private static AdGroup CreateAdGroup(AdWordsUser user, Campaign campaign) { AdGroupService adGroupService = (AdGroupService)user.GetService( AdWordsService.v201702.AdGroupService); // Create ad group. AdGroup adGroup = new AdGroup(); adGroup.campaignId = campaign.id; adGroup.name = "Ad Group #" + ExampleUtilities.GetRandomString(); // Required: Set the ad group type to SHOPPING_SHOWCASE_ADS. adGroup.adGroupType = AdGroupType.SHOPPING_SHOWCASE_ADS; // Required: Set the ad group's bidding strategy configuration. BiddingStrategyConfiguration biddingConfiguration = new BiddingStrategyConfiguration(); // Showcase ads require either ManualCpc or EnhancedCpc. biddingConfiguration.biddingStrategyType = BiddingStrategyType.MANUAL_CPC; // Optional: Set the bids. biddingConfiguration.bids = new Bids[] { new CpcBid() { bid = new Money() { microAmount = 100000 } } }; adGroup.biddingStrategyConfiguration = biddingConfiguration; // Create the operation. AdGroupOperation operation = new AdGroupOperation(); operation.operand = adGroup; operation.@operator = Operator.ADD; // Make the mutate request. AdGroupReturnValue retval = adGroupService.mutate(new AdGroupOperation[] { operation }); return(retval.value[0]); }
/// <summary> /// Creates the ad group in a Shopping campaign. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">The campaign ID.</param> /// <returns>The ad group.</returns> private static AdGroup CreateAdGroup(AdWordsUser user, long campaignId) { AdGroupService adGroupService = (AdGroupService)user.GetService( AdWordsService.v201710.AdGroupService); // Create ad group. AdGroup adGroup = new AdGroup(); adGroup.campaignId = campaignId; adGroup.name = "Ad Group #" + ExampleUtilities.GetRandomString(); // Create operation. AdGroupOperation operation = new AdGroupOperation(); operation.operand = adGroup; operation.@operator = Operator.ADD; // Make the mutate request. AdGroupReturnValue retval = adGroupService.mutate(new AdGroupOperation[] { operation }); adGroupService.Close(); return(retval.value[0]); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="adGroupId">Id of the ad group to be updated.</param> /// <param name="bidMicroAmount">The CPC bid amount in micros.</param> public void Run(AdWordsUser user, long adGroupId, long?bidMicroAmount) { using (AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201710.AdGroupService)) { // Create an ad group with the specified ID. AdGroup adGroup = new AdGroup(); adGroup.id = adGroupId; // Pause the ad group. adGroup.status = AdGroupStatus.PAUSED; // Update the CPC bid if specified. if (bidMicroAmount != null) { BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration(); Money cpcBidMoney = new Money(); cpcBidMoney.microAmount = bidMicroAmount.Value; CpcBid cpcBid = new CpcBid(); cpcBid.bid = cpcBidMoney; biddingStrategyConfiguration.bids = new Bids[] { cpcBid }; adGroup.biddingStrategyConfiguration = biddingStrategyConfiguration; } // Create the operation. AdGroupOperation operation = new AdGroupOperation(); operation.@operator = Operator.SET; operation.operand = adGroup; try { // Update the ad group. AdGroupReturnValue retVal = adGroupService.mutate(new AdGroupOperation[] { operation }); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { AdGroup adGroupResult = retVal.value[0]; BiddingStrategyConfiguration bsConfig = adGroupResult.biddingStrategyConfiguration; // Find the CpcBid in the bidding strategy configuration's bids collection. long cpcBidMicros = 0L; if (bsConfig != null && bsConfig.bids != null) { foreach (Bids bid in bsConfig.bids) { if (bid is CpcBid) { cpcBidMicros = ((CpcBid)bid).bid.microAmount; break; } } } Console.WriteLine("Ad group with ID {0} and name '{1}' updated to have status '{2}'" + " and CPC bid {3}", adGroupResult.id, adGroupResult.name, adGroupResult.status, cpcBidMicros); } else { Console.WriteLine("No ad groups were updated."); } } catch (Exception e) { throw new System.ApplicationException("Failed to update ad group.", e); } } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">Id of the campaign to which experiments are /// added.</param> /// <param name="adGroupId">Id of the ad group to which experiments are /// added.</param> /// <param name="criterionId">Id of the criterion for which experiments /// are added.</param> public void Run(AdWordsUser user, long campaignId, long adGroupId, long criterionId) { // Get the ExperimentService. ExperimentService experimentService = (ExperimentService)user.GetService(AdWordsService.v201607.ExperimentService); // Get the AdGroupService. AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201607.AdGroupService); // Get the AdGroupCriterionService. AdGroupCriterionService adGroupCriterionService = (AdGroupCriterionService)user.GetService(AdWordsService.v201607.AdGroupCriterionService); // Create the experiment. Experiment experiment = new Experiment(); experiment.campaignId = campaignId; experiment.name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(); experiment.queryPercentage = 10; experiment.startDateTime = DateTime.Now.AddDays(1).ToString("yyyyMMdd HHmmss"); // Optional: Set the end date. experiment.endDateTime = DateTime.Now.AddDays(30).ToString("yyyyMMdd HHmmss"); // Optional: Set the status. experiment.status = ExperimentStatus.ENABLED; // Create the operation. ExperimentOperation experimentOperation = new ExperimentOperation(); experimentOperation.@operator = Operator.ADD; experimentOperation.operand = experiment; try { // Add the experiment. ExperimentReturnValue experimentRetVal = experimentService.mutate( new ExperimentOperation[] { experimentOperation }); // Display the results. if (experimentRetVal != null && experimentRetVal.value != null && experimentRetVal.value. Length > 0) { long experimentId = 0; Experiment newExperiment = experimentRetVal.value[0]; Console.WriteLine("Experiment with name = \"{0}\" and id = \"{1}\" was added.\n", newExperiment.name, newExperiment.id); experimentId = newExperiment.id; // Set ad group for the experiment. AdGroup adGroup = new AdGroup(); adGroup.id = adGroupId; // Create experiment bid multiplier rule that will modify ad group bid // for the experiment. ManualCPCAdGroupExperimentBidMultipliers adGroupBidMultiplier = new ManualCPCAdGroupExperimentBidMultipliers(); adGroupBidMultiplier.maxCpcMultiplier = new BidMultiplier(); adGroupBidMultiplier.maxCpcMultiplier.multiplier = 1.5; // Set experiment data to the ad group. AdGroupExperimentData adGroupExperimentData = new AdGroupExperimentData(); adGroupExperimentData.experimentId = experimentId; adGroupExperimentData.experimentDeltaStatus = ExperimentDeltaStatus.MODIFIED; adGroupExperimentData.experimentBidMultipliers = adGroupBidMultiplier; adGroup.experimentData = adGroupExperimentData; // Create the operation. AdGroupOperation adGroupOperation = new AdGroupOperation(); adGroupOperation.operand = adGroup; adGroupOperation.@operator = Operator.SET; // Update the ad group. AdGroupReturnValue adGroupRetVal = adGroupService.mutate(new AdGroupOperation[] { adGroupOperation }); // Display the results. if (adGroupRetVal != null && adGroupRetVal.value != null && adGroupRetVal.value.Length > 0) { AdGroup updatedAdGroup = adGroupRetVal.value[0]; Console.WriteLine("Ad group with name = \"{0}\", id = \"{1}\" and status = \"{2}\" " + "was updated for the experiment.\n", updatedAdGroup.name, updatedAdGroup.id, updatedAdGroup.status); } else { Console.WriteLine("No ad groups were updated."); } // Set ad group criteria for the experiment. Criterion criterion = new Criterion(); criterion.id = criterionId; BiddableAdGroupCriterion adGroupCriterion = new BiddableAdGroupCriterion(); adGroupCriterion.adGroupId = adGroupId; adGroupCriterion.criterion = criterion; // Create experiment bid multiplier rule that will modify criterion bid // for the experiment. ManualCPCAdGroupCriterionExperimentBidMultiplier bidMultiplier = new ManualCPCAdGroupCriterionExperimentBidMultiplier(); bidMultiplier.maxCpcMultiplier = new BidMultiplier(); bidMultiplier.maxCpcMultiplier.multiplier = 1.5; // Set experiment data to the criterion. BiddableAdGroupCriterionExperimentData adGroupCriterionExperimentData = new BiddableAdGroupCriterionExperimentData(); adGroupCriterionExperimentData.experimentId = experimentId; adGroupCriterionExperimentData.experimentDeltaStatus = ExperimentDeltaStatus.MODIFIED; adGroupCriterionExperimentData.experimentBidMultiplier = bidMultiplier; adGroupCriterion.experimentData = adGroupCriterionExperimentData; // Create the operation. AdGroupCriterionOperation adGroupCriterionOperation = new AdGroupCriterionOperation(); adGroupCriterionOperation.operand = adGroupCriterion; adGroupCriterionOperation.@operator = Operator.SET; // Update the ad group criteria. AdGroupCriterionReturnValue adGroupCriterionRetVal = adGroupCriterionService.mutate( new AdGroupCriterionOperation[] { adGroupCriterionOperation }); // Display the results. if (adGroupCriterionRetVal != null && adGroupCriterionRetVal.value != null && adGroupCriterionRetVal.value.Length > 0) { AdGroupCriterion updatedAdGroupCriterion = adGroupCriterionRetVal.value[0]; Console.WriteLine("Ad group criterion with ad group id = \"{0}\", criterion id = " + "\"{1}\" and type = \"{2}\" was updated for the experiment.\n", updatedAdGroupCriterion.adGroupId, updatedAdGroupCriterion.criterion.id, updatedAdGroupCriterion.criterion.CriterionType); } else { Console.WriteLine("No ad group criteria were updated."); } } else { Console.WriteLine("No experiments were added."); } } catch (Exception e) { throw new System.ApplicationException("Failed to add experiment.", e); } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">Id of the campaign to which ad groups are /// added.</param> public void Run(AdWordsUser user, long campaignId) { using (AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201710.AdGroupService)) { List <AdGroupOperation> operations = new List <AdGroupOperation>(); for (int i = 0; i < NUM_ITEMS; i++) { // Create the ad group. AdGroup adGroup = new AdGroup(); adGroup.name = string.Format("Earth to Mars Cruises #{0}", ExampleUtilities.GetRandomString()); adGroup.status = AdGroupStatus.ENABLED; adGroup.campaignId = campaignId; // Set the ad group bids. BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); CpcBid cpcBid = new CpcBid(); cpcBid.bid = new Money(); cpcBid.bid.microAmount = 10000000; biddingConfig.bids = new Bids[] { cpcBid }; adGroup.biddingStrategyConfiguration = biddingConfig; // Optional: Set targeting restrictions. // Depending on the criterionTypeGroup value, most TargetingSettingDetail // only affect Display campaigns. However, the USER_INTEREST_AND_LIST value // works for RLSA campaigns - Search campaigns targeting using a // remarketing list. TargetingSetting targetingSetting = new TargetingSetting(); // Restricting to serve ads that match your ad group placements. // This is equivalent to choosing "Target and bid" in the UI. TargetingSettingDetail placementDetail = new TargetingSettingDetail(); placementDetail.criterionTypeGroup = CriterionTypeGroup.PLACEMENT; placementDetail.targetAll = false; // Using your ad group verticals only for bidding. This is equivalent // to choosing "Bid only" in the UI. TargetingSettingDetail verticalDetail = new TargetingSettingDetail(); verticalDetail.criterionTypeGroup = CriterionTypeGroup.VERTICAL; verticalDetail.targetAll = true; targetingSetting.details = new TargetingSettingDetail[] { placementDetail, verticalDetail }; adGroup.settings = new Setting[] { targetingSetting }; // Set the rotation mode. AdGroupAdRotationMode rotationMode = new AdGroupAdRotationMode(); rotationMode.adRotationMode = AdRotationMode.OPTIMIZE; adGroup.adGroupAdRotationMode = rotationMode; // Create the operation. AdGroupOperation operation = new AdGroupOperation(); operation.@operator = Operator.ADD; operation.operand = adGroup; operations.Add(operation); } try { // Create the ad group. AdGroupReturnValue retVal = adGroupService.mutate(operations.ToArray()); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { foreach (AdGroup newAdGroup in retVal.value) { Console.WriteLine("Ad group with id = '{0}' and name = '{1}' was created.", newAdGroup.id, newAdGroup.name); } } else { Console.WriteLine("No ad groups were created."); } } catch (Exception e) { throw new System.ApplicationException("Failed to create ad groups.", e); } } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">Id of the campaign to which ad groups are /// added.</param> public void Run(AdWordsUser user, long campaignId) { // Get the AdGroupService. AdGroupService adGroupService = (AdGroupService)user.GetService(AdWordsService.v201402.AdGroupService); List <AdGroupOperation> operations = new List <AdGroupOperation>(); for (int i = 0; i < NUM_ITEMS; i++) { // Create the ad group. AdGroup adGroup = new AdGroup(); adGroup.name = string.Format("Earth to Mars Cruises #{0}", ExampleUtilities.GetRandomString()); adGroup.status = AdGroupStatus.ENABLED; adGroup.campaignId = campaignId; // Set the ad group bids. BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); CpmBid cpmBid = new CpmBid(); cpmBid.bid = new Money(); cpmBid.bid.microAmount = 10000000; biddingConfig.bids = new Bids[] { cpmBid }; adGroup.biddingStrategyConfiguration = biddingConfig; // Optional: Set targeting restrictions. // These setting only affect serving for the Display Network. TargetingSetting targetingSetting = new TargetingSetting(); TargetingSettingDetail placementDetail = new TargetingSettingDetail(); placementDetail.criterionTypeGroup = CriterionTypeGroup.PLACEMENT; placementDetail.targetAll = true; TargetingSettingDetail verticalDetail = new TargetingSettingDetail(); verticalDetail.criterionTypeGroup = CriterionTypeGroup.VERTICAL; verticalDetail.targetAll = false; targetingSetting.details = new TargetingSettingDetail[] { placementDetail, verticalDetail }; adGroup.settings = new Setting[] { targetingSetting }; // Create the operation. AdGroupOperation operation = new AdGroupOperation(); operation.@operator = Operator.ADD; operation.operand = adGroup; operations.Add(operation); } try { // Create the ad group. AdGroupReturnValue retVal = adGroupService.mutate(operations.ToArray()); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { foreach (AdGroup newAdGroup in retVal.value) { Console.WriteLine("Ad group with id = '{0}' and name = '{1}' was created.", newAdGroup.id, newAdGroup.name); } } else { Console.WriteLine("No ad groups were created."); } } catch (Exception ex) { throw new System.ApplicationException("Failed to create ad groups.", ex); } }