Пример #1
0
 /// <summary>
 /// Creates a test shopping campaign for running further tests.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="biddingStrategy">The bidding strategy to be used.</param>
 /// <returns>The campaign id.</returns>
 public long CreateShoppingCampaign(AdWordsUser user, BiddingStrategyType strategyType) {
   return CreateCampaign(user, AdvertisingChannelType.SHOPPING, strategyType);
 }
Пример #2
0
    /// <summary>
    /// Creates a test campaign for running further tests.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="biddingStrategy">The bidding strategy to be used.</param>
    /// <returns>The campaign id.</returns>
    public long CreateCampaign(AdWordsUser user, AdvertisingChannelType channelType,
        BiddingStrategyType strategyType) {
      CampaignService campaignService =
          (CampaignService) user.GetService(AdWordsService.v201406.CampaignService);

      BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
      biddingConfig.biddingStrategyType = strategyType;

      CampaignOperation campaignOperation = new CampaignOperation();
      campaignOperation.@operator = Operator.ADD;
      campaignOperation.operand = new Campaign();
      campaignOperation.operand.name =
          string.Format("Campaign {0}", DateTime.Now.ToString("yyyy-M-d H:m:s.ffffff"));
      campaignOperation.operand.advertisingChannelType = channelType;
      campaignOperation.operand.status = CampaignStatus.PAUSED;
      campaignOperation.operand.biddingStrategyConfiguration = biddingConfig;
      campaignOperation.operand.budget = new Budget();
      campaignOperation.operand.budget.budgetId = CreateBudget(user);
      campaignOperation.operand.budget.period = BudgetBudgetPeriod.DAILY;
      campaignOperation.operand.budget.amount = new Money();
      campaignOperation.operand.budget.amount.microAmount = 100000000;
      campaignOperation.operand.budget.deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD;

      List<Setting> settings = new List<Setting>();
      KeywordMatchSetting matchSetting = new KeywordMatchSetting();
      matchSetting.optIn = true;
      settings.Add(matchSetting);

      if (channelType == AdvertisingChannelType.SHOPPING) {
        // All Shopping campaigns need a ShoppingSetting.
        ShoppingSetting shoppingSetting = new ShoppingSetting();
        shoppingSetting.salesCountry = "US";
        shoppingSetting.campaignPriority = 0;
        shoppingSetting.merchantId = (user.Config as AdWordsAppConfig).MerchantCenterId;

        settings.Add(shoppingSetting);
      }
      campaignOperation.operand.settings = settings.ToArray();

      CampaignReturnValue retVal =
          campaignService.mutate(new CampaignOperation[] {campaignOperation});
      return retVal.value[0].id;
    }
Пример #3
0
 /// <summary>
 /// Creates a test search campaign for running further tests.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="biddingStrategy">The bidding strategy to be used.</param>
 /// <returns>The campaign id.</returns>
 public long CreateSearchCampaign(AdWordsUser user, BiddingStrategyType strategyType) {
   return CreateCampaign(user, AdvertisingChannelType.SEARCH, strategyType);
 }
Пример #4
0
 /// <summary>
 /// Creates a display campaign for running further tests.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="biddingStrategy">The bidding strategy to be used.</param>
 /// <returns>The campaign id.</returns>
 public long CreateDisplayCampaign(AdWordsUser user, BiddingStrategyType strategyType) {
   return CreateCampaign(user, AdvertisingChannelType.DISPLAY, strategyType);
 }
Пример #5
0
 /// <summary>
 /// Creates a display campaign for running further tests.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="biddingStrategy">The bidding strategy to be used.</param>
 /// <returns>The campaign id.</returns>
 public long CreateDisplayCampaign(AdWordsUser user, BiddingStrategyType strategyType)
 {
     return(CreateCampaign(user, AdvertisingChannelType.DISPLAY, strategyType));
 }
Пример #6
0
 /// <summary>
 /// Creates a test shopping campaign for running further tests.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="biddingStrategy">The bidding strategy to be used.</param>
 /// <returns>The campaign id.</returns>
 public long CreateShoppingCampaign(AdWordsUser user, BiddingStrategyType strategyType)
 {
     return(CreateCampaign(user, AdvertisingChannelType.SHOPPING, strategyType));
 }
        /// <summary>
        /// Creates a test campaign for running further tests.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="channelType">The advertising channel type for this
        /// campaign.</param>
        /// <param name="strategyType">The bidding strategy to be used for
        /// this campaign.</param>
        /// <param name="isMobile">True, if this campaign is mobile-only, false
        /// otherwise.</param>
        /// <returns>The campaign id.</returns>
        public long CreateCampaign(AdWordsUser user, AdvertisingChannelType channelType,
                                   BiddingStrategyType strategyType, bool isMobile)
        {
            CampaignService campaignService =
                (CampaignService)user.GetService(AdWordsService.v201605.CampaignService);

            Campaign campaign = new Campaign()
            {
                name = string.Format("Campaign {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff")),
                advertisingChannelType = channelType,
                status = CampaignStatus.PAUSED,
                biddingStrategyConfiguration = new BiddingStrategyConfiguration()
                {
                    biddingStrategyType = strategyType
                },
                budget = new Budget()
                {
                    budgetId = CreateBudget(user),
                    amount   = new Money()
                    {
                        microAmount = 100000000,
                    },
                    deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD
                }
            };

            if (isMobile)
            {
                switch (campaign.advertisingChannelType)
                {
                case AdvertisingChannelType.SEARCH:
                    campaign.advertisingChannelSubType = AdvertisingChannelSubType.SEARCH_MOBILE_APP;
                    break;

                case AdvertisingChannelType.DISPLAY:
                    campaign.advertisingChannelSubType = AdvertisingChannelSubType.DISPLAY_MOBILE_APP;
                    break;
                }
            }

            List <Setting> settings = new List <Setting>();

            if (channelType == AdvertisingChannelType.SHOPPING)
            {
                // All Shopping campaigns need a ShoppingSetting.
                ShoppingSetting shoppingSetting = new ShoppingSetting()
                {
                    salesCountry     = "US",
                    campaignPriority = 0,
                    merchantId       = (user.Config as AdWordsAppConfig).MerchantCenterId
                };
                settings.Add(shoppingSetting);
            }
            campaign.settings = settings.ToArray();

            CampaignOperation campaignOperation = new CampaignOperation()
            {
                @operator = Operator.ADD,
                operand   = campaign
            };

            CampaignReturnValue retVal =
                campaignService.mutate(new CampaignOperation[] { campaignOperation });

            return(retVal.value[0].id);
        }
Пример #8
0
 /// <summary>
 /// Creates a test search campaign for running further tests.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="biddingStrategy">The bidding strategy to be used.</param>
 /// <returns>The campaign id.</returns>
 public long CreateSearchCampaign(AdWordsUser user, BiddingStrategyType strategyType)
 {
     return(CreateCampaign(user, AdvertisingChannelType.SEARCH, strategyType));
 }
 /// <summary>
 /// Creates a test campaign for running further tests.
 /// </summary>
 /// <param name="user">The AdWords user.</param>
 /// <param name="channelType">The advertising channel type for this
 /// campaign.</param>
 /// <param name="strategyType">The bidding strategy to be used for
 /// this campaign.</param>
 /// <returns>The campaign id.</returns>
 public long CreateCampaign(AdWordsUser user, AdvertisingChannelType channelType,
                            BiddingStrategyType strategyType)
 {
     return(CreateCampaign(user, channelType, strategyType, false));
 }
Пример #10
0
        /// <summary>
        /// Creates a test campaign for running further tests.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="channelType">The advertising channel type for this
        /// campaign.</param>
        /// <param name="strategyType">The bidding strategy to be used for
        /// this campaign.</param>
        /// <param name="isMobile">True, if this campaign is mobile-only, false
        /// otherwise.</param>
        /// <param name="isDsa">True, if this campaign is for DSA, false
        /// otherwise.</param>
        /// <param name="isGmail">True, if this campaign is for GMail Ads, false
        /// otherwise.</param>
        /// <returns>The campaign id.</returns>
        private long CreateCampaign(AdWordsUser user, AdvertisingChannelType channelType,
                                    BiddingStrategyType strategyType, bool isMobile, bool isDsa, bool isGmail)
        {
            CampaignService campaignService =
                (CampaignService)user.GetService(AdWordsService.v201806.CampaignService);

            Campaign campaign = new Campaign()
            {
                name = string.Format("Campaign {0}",
                                     DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff")),
                advertisingChannelType = channelType,

                // Set the test campaign to PAUSED when creating it to prevent the ads from serving.
                status = CampaignStatus.PAUSED,

                biddingStrategyConfiguration = new BiddingStrategyConfiguration()
                {
                    biddingStrategyType = strategyType
                },
                budget = new Budget()
                {
                    budgetId = CreateBudget(user),
                    amount   = new Money()
                    {
                        microAmount = 100000000,
                    },
                    deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD
                }
            };

            // Campaign setups that cannot be inferred just from AdvertisingChannelType uses flags.
            List <Setting> settings = new List <Setting>();

            // The following flags are all mutually exclusive for the purpose of testing.
            if (isMobile)
            {
                switch (campaign.advertisingChannelType)
                {
                case AdvertisingChannelType.SEARCH:
                    campaign.advertisingChannelSubType =
                        AdvertisingChannelSubType.SEARCH_MOBILE_APP;
                    break;

                case AdvertisingChannelType.DISPLAY:
                    campaign.advertisingChannelSubType =
                        AdvertisingChannelSubType.DISPLAY_MOBILE_APP;
                    break;
                }
            }
            else if (isDsa)
            {
                // Required: Set the campaign's Dynamic Search Ads settings.
                DynamicSearchAdsSetting dynamicSearchAdsSetting = new DynamicSearchAdsSetting();

                // Required: Set the domain name and language.
                dynamicSearchAdsSetting.domainName   = "example.com";
                dynamicSearchAdsSetting.languageCode = "en";
                settings.Add(dynamicSearchAdsSetting);
            }
            else if (isGmail)
            {
                campaign.advertisingChannelSubType = AdvertisingChannelSubType.DISPLAY_GMAIL_AD;
            }
            else if (channelType == AdvertisingChannelType.SHOPPING)
            {
                // All Shopping campaigns need a ShoppingSetting.
                ShoppingSetting shoppingSetting = new ShoppingSetting()
                {
                    salesCountry     = "US",
                    campaignPriority = 0,
                    merchantId       = (user.Config as AdWordsAppConfig).MerchantCenterId
                };
                settings.Add(shoppingSetting);
            }

            campaign.settings = settings.ToArray();

            CampaignOperation campaignOperation = new CampaignOperation()
            {
                @operator = Operator.ADD,
                operand   = campaign
            };

            CampaignReturnValue retVal = campaignService.mutate(new CampaignOperation[]
            {
                campaignOperation
            });

            return(retVal.value[0].id);
        }
        /// <summary>
        /// Creates a test campaign for running further tests.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="biddingStrategy">The bidding strategy to be used.</param>
        /// <returns>The campaign id.</returns>
        public long CreateCampaign(AdWordsUser user, BiddingStrategyType strategyType)
        {
            CampaignService campaignService =
              (CampaignService) user.GetService(AdWordsService.v201309.CampaignService);

              BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
              biddingConfig.biddingStrategyType = strategyType;

              CampaignOperation campaignOperation = new CampaignOperation();
              campaignOperation.@operator = Operator.ADD;
              campaignOperation.operand = new Campaign();
              campaignOperation.operand.name =
              string.Format("Campaign {0}", DateTime.Now.ToString("yyyy-M-d H:m:s.ffffff"));
              campaignOperation.operand.status = CampaignStatus.PAUSED;
              campaignOperation.operand.biddingStrategyConfiguration = biddingConfig;
              campaignOperation.operand.budget = new Budget();
              campaignOperation.operand.budget.period = BudgetBudgetPeriod.DAILY;
              campaignOperation.operand.budget.amount = new Money();
              campaignOperation.operand.budget.amount.microAmount = 100000000;
              campaignOperation.operand.budget.deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD;
              KeywordMatchSetting matchSetting = new KeywordMatchSetting();
              matchSetting.optIn = true;
              campaignOperation.operand.settings = new Setting[] {matchSetting};

              CampaignReturnValue retVal =
              campaignService.mutate(new CampaignOperation[] {campaignOperation});
              return retVal.value[0].id;
        }
Пример #12
0
    /// <summary>
    /// Creates a test campaign for running further tests.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="channelType">The advertising channel type for this
    /// campaign.</param>
    /// <param param name="strategyType">The bidding strategy to be used for
    /// this campaign.</param>
    /// <param name="isMobile">True, if this campaign is mobile-only, false
    /// otherwise.</param>
    /// <returns>The campaign id.</returns>
    public long CreateCampaign(AdWordsUser user, AdvertisingChannelType channelType,
        BiddingStrategyType strategyType, bool isMobile) {
      CampaignService campaignService =
          (CampaignService) user.GetService(AdWordsService.v201506.CampaignService);

      Campaign campaign = new Campaign() {
        name = string.Format("Campaign {0}", DateTime.Now.ToString("yyyy-M-d H:m:s.ffffff")),
        advertisingChannelType = channelType,
        status = CampaignStatus.PAUSED,
        biddingStrategyConfiguration = new BiddingStrategyConfiguration() {
          biddingStrategyType = strategyType
        },
        budget = new Budget() {
          budgetId = CreateBudget(user),
          period = BudgetBudgetPeriod.DAILY,
          amount = new Money() {
            microAmount = 100000000,
          },
          deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD
        }
      };

      if (isMobile) {
        switch (campaign.advertisingChannelType) {
          case AdvertisingChannelType.SEARCH:
            campaign.advertisingChannelSubType = AdvertisingChannelSubType.SEARCH_MOBILE_APP;
            break;

          case AdvertisingChannelType.DISPLAY:
            campaign.advertisingChannelSubType = AdvertisingChannelSubType.DISPLAY_MOBILE_APP;
            break;
        }
      }

      List<Setting> settings = new List<Setting>();

      if (channelType == AdvertisingChannelType.SHOPPING) {
        // All Shopping campaigns need a ShoppingSetting.
        ShoppingSetting shoppingSetting = new ShoppingSetting() {
          salesCountry = "US",
          campaignPriority = 0,
          merchantId = (user.Config as AdWordsAppConfig).MerchantCenterId
        };
        settings.Add(shoppingSetting);
      }
      campaign.settings = settings.ToArray();

      CampaignOperation campaignOperation = new CampaignOperation() {
        @operator = Operator.ADD,
        operand = campaign
      };

      CampaignReturnValue retVal =
          campaignService.mutate(new CampaignOperation[] { campaignOperation });
      return retVal.value[0].id;
    }
Пример #13
0
 /// <summary>
 /// Creates a test campaign for running further tests.
 /// </summary>
 /// <param name="user">The AdWords user.</param>
 /// <param name="channelType">The advertising channel type for this
 /// campaign.</param>
 /// <param param name="strategyType">The bidding strategy to be used for
 /// this campaign.</param>
 /// <returns>The campaign id.</returns>
 public long CreateCampaign(AdWordsUser user, AdvertisingChannelType channelType,
     BiddingStrategyType strategyType) {
   return CreateCampaign(user, channelType, strategyType, false);
 }