コード例 #1
0
        /// <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
        }
コード例 #2
0
        /// <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);
              }
        }
コード例 #3
0
        /// <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.v201605.BudgetService);

            // Get the CampaignService.
            CampaignService campaignService =
                (CampaignService)user.GetService(AdWordsService.v201605.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.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);
            }
        }
コード例 #4
0
        /// <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.v201806.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);
                }
            }
        }
コード例 #5
0
        /// <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);
                }
            }
        }
コード例 #6
0
        public static CampaignReturnValue CreateCampaign(AdWordsUser user, CampaignLo campaignDto)
        {
            using (CampaignService campaignService =
                       (CampaignService)user.GetService(AdWordsService.v201710.CampaignService))
            {
                CampaignReturnValue camp = new CampaignReturnValue();

                Budget budget = Budgets.CreateBudget(user, campaignDto);

                List <CampaignOperation> operations = new List <CampaignOperation>();


                // Create the campaign.
                Campaign campaign = new Campaign();
                campaign.name = campaignDto.Name;
                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.ENABLED;

                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.
                if (Debugger.IsAttached)
                {
                    campaignDto.StartDate = campaignDto.StartDate.AddHours(6);
                }
                campaign.startDate = campaignDto.StartDate.ToString("yyyyMMdd");

                // Optional: Set the end date.
                if (Debugger.IsAttached)
                {
                    campaignDto.EndDate = campaignDto.EndDate.AddHours(6);
                }
                campaign.endDate = campaignDto.EndDate.ToString("yyyyMMdd");

                // 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.
                    camp = campaignService.mutate(operations.ToArray());
                }
                catch (Exception e)
                {
                    throw new System.ApplicationException("Failed to add campaigns.", e);
                }
                return(camp);
            }
        }