/// <summary> /// Creates the campaign with a shared bidding strategy. /// </summary> /// <param name="campaignService">The campaign service.</param> /// <param name="name">The campaign name.</param> /// <param name="biddingStrategyId">The bidding strategy id.</param> /// <param name="sharedBudgetId">The shared budget id.</param> /// <returns>The campaign object.</returns> private Campaign CreateCampaignWithBiddingStrategy(CampaignService campaignService, string name, long biddingStrategyId, long sharedBudgetId) { // Create campaign. Campaign campaign = new Campaign(); campaign.name = name; campaign.advertisingChannelType = AdvertisingChannelType.SEARCH; // Set the budget. campaign.budget = new Budget(); campaign.budget.budgetId = sharedBudgetId; // Set bidding strategy (required). BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration(); biddingStrategyConfiguration.biddingStrategyId = biddingStrategyId; campaign.biddingStrategyConfiguration = biddingStrategyConfiguration; // Set network targeting (recommended). NetworkSetting networkSetting = new NetworkSetting(); networkSetting.targetGoogleSearch = true; networkSetting.targetSearchNetwork = true; networkSetting.targetContentNetwork = true; campaign.networkSetting = networkSetting; // Create operation. CampaignOperation operation = new CampaignOperation(); operation.operand = campaign; operation.@operator = Operator.ADD; return campaignService.mutate(new CampaignOperation[] {operation}).value[0]; }
/// <summary> /// Creates the shopping campaign. /// </summary> /// <param name="budgetId">The budget id.</param> /// <param name="merchantId">The Merchant Center id.</param> /// <param name="campaignService">The CampaignService instance.</param> /// <returns>The Shopping campaign.</returns> private static Campaign CreateCampaign(long budgetId, long merchantId, CampaignService campaignService) { // Create campaign. Campaign campaign = new Campaign(); campaign.name = "Shopping campaign #" + ExampleUtilities.GetRandomString(); // The advertisingChannelType is what makes this a Shopping campaign. campaign.advertisingChannelType = AdvertisingChannelType.SHOPPING; // Set shared budget (required). campaign.budget = new Budget(); campaign.budget.budgetId = budgetId; // Set bidding strategy (required). BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration(); biddingStrategyConfiguration.biddingStrategyType = BiddingStrategyType.MANUAL_CPC; campaign.biddingStrategyConfiguration = biddingStrategyConfiguration; // All Shopping campaigns need a ShoppingSetting. ShoppingSetting shoppingSetting = new ShoppingSetting(); shoppingSetting.salesCountry = "US"; shoppingSetting.campaignPriority = 0; shoppingSetting.merchantId = merchantId; // Set to "true" to enable Local Inventory Ads in your campaign. shoppingSetting.enableLocal = true; campaign.settings = new Setting[] { shoppingSetting }; // Create operation. CampaignOperation campaignOperation = new CampaignOperation(); campaignOperation.operand = campaign; campaignOperation.@operator = Operator.ADD; // Make the mutate request. CampaignReturnValue retval = campaignService.mutate( new CampaignOperation[] { campaignOperation }); return retval.value[0]; }