/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> public void Run(AdWordsUser user) { // [START prepareUAC] MOE:strip_line // Get the CampaignService. CampaignService campaignService = (CampaignService)user.GetService(AdWordsService.v201609.CampaignService); // Create the campaign. Campaign campaign = new Campaign(); campaign.name = "Interplanetary Cruise App #" + ExampleUtilities.GetRandomString(); campaign.status = CampaignStatus.PAUSED; // Set the advertising channel and subchannel types for universal app campaigns. campaign.advertisingChannelType = AdvertisingChannelType.MULTI_CHANNEL; campaign.advertisingChannelSubType = AdvertisingChannelSubType.UNIVERSAL_APP_CAMPAIGN; // Set the campaign's bidding strategy. Universal app campaigns // only support TARGET_CPA bidding strategy. BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); biddingConfig.biddingStrategyType = BiddingStrategyType.TARGET_CPA; // Set the target CPA to $1 / app install. TargetCpaBiddingScheme biddingScheme = new TargetCpaBiddingScheme(); biddingScheme.targetCpa = new Money(); biddingScheme.targetCpa.microAmount = 1000000; biddingConfig.biddingScheme = biddingScheme; campaign.biddingStrategyConfiguration = biddingConfig; // Set the campaign's budget. campaign.budget = new Budget(); campaign.budget.budgetId = CreateBudget(user).budgetId; // 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"); // [END prepareUAC] MOE:strip_line // [START setUACAssets] MOE:strip_line // Set the campaign's assets and ad text ideas. These values will be used to // generate ads. UniversalAppCampaignSetting universalAppSetting = new UniversalAppCampaignSetting(); universalAppSetting.appId = "com.interplanetarycruise.booking"; universalAppSetting.description1 = "Best Space Cruise Line"; universalAppSetting.description2 = "Visit all the planets"; universalAppSetting.description3 = "Trips 7 days a week"; universalAppSetting.description4 = "Buy your tickets now!"; // Optional: You can set up to 10 image assets for your campaign. // See UploadImage.cs for an example on how to upload images. // // universalAppSetting.imageMediaIds = new long[] { INSERT_IMAGE_MEDIA_ID_HERE }; // [END setUACAssets] MOE:strip_line // [START optimizeUAC] MOE:strip_line // Optimize this campaign for getting new users for your app. universalAppSetting.universalAppBiddingStrategyGoalType = UniversalAppBiddingStrategyGoalType.OPTIMIZE_FOR_INSTALL_CONVERSION_VOLUME; // Optional: If you select the OPTIMIZE_FOR_IN_APP_CONVERSION_VOLUME goal // type, then also specify your in-app conversion types so AdWords can // focus your campaign on people who are most likely to complete the // corresponding in-app actions. // Conversion type IDs can be retrieved using ConversionTrackerService.get. // // campaign.selectiveOptimization = new SelectiveOptimization(); // campaign.selectiveOptimization.conversionTypeIds = // new long[] { INSERT_CONVERSION_TYPE_ID_1_HERE, INSERT_CONVERSION_TYPE_ID_2_HERE }; // Optional: Set the campaign settings for Advanced location options. GeoTargetTypeSetting geoSetting = new GeoTargetTypeSetting(); geoSetting.positiveGeoTargetType = GeoTargetTypeSettingPositiveGeoTargetType.LOCATION_OF_PRESENCE; geoSetting.negativeGeoTargetType = GeoTargetTypeSettingNegativeGeoTargetType.DONT_CARE; campaign.settings = new Setting[] { universalAppSetting, geoSetting }; // [END optimizeUAC] MOE:strip_line // [START createUAC] MOE:strip_line // Create the operation. CampaignOperation operation = new CampaignOperation(); operation.@operator = Operator.ADD; operation.operand = campaign; try { // Add the campaign. CampaignReturnValue retVal = campaignService.mutate(new CampaignOperation[] { operation }); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { foreach (Campaign newCampaign in retVal.value) { Console.WriteLine("Universal app campaign with name = '{0}' and id = '{1}' was added.", newCampaign.name, newCampaign.id); // Optional: Set the campaign's location and language targeting. No other targeting // criteria can be used for universal app campaigns. SetCampaignTargetingCriteria(user, newCampaign); } } else { Console.WriteLine("No universal app campaigns were added."); } } catch (Exception e) { throw new System.ApplicationException("Failed to add universal app campaigns.", e); } // [END createUAC] MOE:strip_line }
/// <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)) { // Create the campaign. Campaign campaign = new Campaign { name = "Interplanetary Cruise App #" + ExampleUtilities.GetRandomString(), // 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, // Set the advertising channel and subchannel types for universal app campaigns. advertisingChannelType = AdvertisingChannelType.MULTI_CHANNEL, advertisingChannelSubType = AdvertisingChannelSubType.UNIVERSAL_APP_CAMPAIGN }; // Set the campaign's bidding strategy. Universal app campaigns // only support TARGET_CPA bidding strategy. BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration { biddingStrategyType = BiddingStrategyType.TARGET_CPA }; // Set the target CPA to $1 / app install. TargetCpaBiddingScheme biddingScheme = new TargetCpaBiddingScheme { targetCpa = new Money { microAmount = 1000000 } }; biddingConfig.biddingScheme = biddingScheme; campaign.biddingStrategyConfiguration = biddingConfig; // Set the campaign's budget. campaign.budget = new Budget { budgetId = CreateBudget(user).budgetId }; // 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"); // Set the campaign's assets and ad text ideas. These values will be used to // generate ads. UniversalAppCampaignSetting universalAppSetting = new UniversalAppCampaignSetting { appId = "com.labpixies.colordrips", appVendor = MobileApplicationVendor.VENDOR_GOOGLE_MARKET, description1 = "A cool puzzle game", description2 = "Remove connected blocks", description3 = "3 difficulty levels", description4 = "4 colorful fun skins", // Optional: You can set up to 20 image assets for your campaign. // See UploadImage.cs for an example on how to upload images. // // universalAppSetting.imageMediaIds = // new long[] { INSERT_IMAGE_MEDIA_ID_HERE }; // // Optimize this campaign for getting new users for your app. universalAppBiddingStrategyGoalType = UniversalAppBiddingStrategyGoalType .OPTIMIZE_FOR_INSTALL_CONVERSION_VOLUME }; // Optional: If you select the OPTIMIZE_FOR_IN_APP_CONVERSION_VOLUME goal // type, then also specify your in-app conversion types so AdWords can // focus your campaign on people who are most likely to complete the // corresponding in-app actions. // Conversion type IDs can be retrieved using ConversionTrackerService.get. // // campaign.selectiveOptimization = new SelectiveOptimization(); // campaign.selectiveOptimization.conversionTypeIds = // new long[] // { // INSERT_CONVERSION_TYPE_ID_1_HERE, // INSERT_CONVERSION_TYPE_ID_2_HERE // }; // Optional: Set the campaign settings for Advanced location options. GeoTargetTypeSetting geoSetting = new GeoTargetTypeSetting { positiveGeoTargetType = GeoTargetTypeSettingPositiveGeoTargetType.LOCATION_OF_PRESENCE, negativeGeoTargetType = GeoTargetTypeSettingNegativeGeoTargetType.DONT_CARE }; campaign.settings = new Setting[] { universalAppSetting, geoSetting }; // Create the operation. CampaignOperation operation = new CampaignOperation { @operator = Operator.ADD, operand = campaign }; try { // Add the campaign. CampaignReturnValue retVal = campaignService.mutate(new CampaignOperation[] { operation }); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { foreach (Campaign newCampaign in retVal.value) { Console.WriteLine( "Universal app campaign with name = '{0}' and id = '{1}' " + "was added.", newCampaign.name, newCampaign.id); // Optional: Set the campaign's location and language targeting. // No other targeting criteria can be used for universal app campaigns. SetCampaignTargetingCriteria(user, newCampaign); } } else { Console.WriteLine("No universal app campaigns were added."); } } catch (Exception e) { throw new System.ApplicationException("Failed to add universal app campaigns.", e); } } }