private void LoadCampaignPerformanceReport(out bool hasVideoCampaign) { hasVideoCampaign = false; //had to reinitialize even though its an input parameter var definition = new ReportDefinition() { reportName = "Custom Date CAMPAIGN_PERFORMANCE_REPORT", reportType = ReportDefinitionReportType.CAMPAIGN_PERFORMANCE_REPORT, selector = new Selector() { fields = new string[] { "CampaignId", "CampaignName", "CampaignStatus", "Impressions", "AveragePosition", "Clicks", "Cost", "AdNetworkType1", // create partitioning by search/display networks "ContentBudgetLostImpressionShare", "ContentImpressionShare", "ContentRankLostImpressionShare", "SearchBudgetLostImpressionShare", "SearchImpressionShare", "SearchRankLostImpressionShare", "AdvertisingChannelSubType", "AdvertisingChannelType", } } }; var reportFilePath = DownloadReport(definition); // check report for impressions using (var reader = new XmlCampaignPerformanceReader()) { // file to datareader string AdvertisingChannelType; reader.Initialize(reportFilePath, this._rptlogId, this._rptdDate, this._clientId); AdvertisingChannelType = reader.AdvertisingChannelType; if (AdvertisingChannelType.ToUpper().Equals("VIDEO")) { hasVideoCampaign = true; } } LoadCampaignChannel(reportFilePath); LoadReport <XmlCampaignChannelReader>(reportFilePath); // todo: harden file deletion even during exceptions if (this._deleteDownloadedReportOnCompletion) { File.Delete(reportFilePath); } }
/// <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); }
public override int GetHashCode() { int hash = 1; if (AvailabilityMode != 0) { hash ^= AvailabilityMode.GetHashCode(); } if (AdvertisingChannelType != 0) { hash ^= AdvertisingChannelType.GetHashCode(); } hash ^= advertisingChannelSubType_.GetHashCode(); if (includeDefaultChannelSubType_ != null) { hash ^= IncludeDefaultChannelSubType.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (AvailabilityMode != global::Google.Ads.GoogleAds.V8.Enums.CriterionCategoryChannelAvailabilityModeEnum.Types.CriterionCategoryChannelAvailabilityMode.Unspecified) { hash ^= AvailabilityMode.GetHashCode(); } if (AdvertisingChannelType != global::Google.Ads.GoogleAds.V8.Enums.AdvertisingChannelTypeEnum.Types.AdvertisingChannelType.Unspecified) { hash ^= AdvertisingChannelType.GetHashCode(); } hash ^= advertisingChannelSubType_.GetHashCode(); if (HasIncludeDefaultChannelSubType) { hash ^= IncludeDefaultChannelSubType.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <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.v201607.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); }
/// <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)); }
/// <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; }
/// <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.v201802.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="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; }
/// <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); }