Hi, I've found some weird behaviour trying to apply some conditions to an AdGroupSelector.
I've attached a script to show this weird scenario :-( Here is the output of the script ( Removing Campaign & Adgroups names for the sake of privacy) , but feel free to execute in your own accounts: current Campaign: Campaign1 Total adGroups in currentCampaign : 2 0.0 matching adGroups whose Ctr is above 0.14 2.0 matching adGroups whose Ctr is below 0.14 The sum of number [2.0] of adGroups below Ctr threshold(0.14) and number of adGroups above [0.0] Ctr threshold has to be equal to the total number of adgroups of the current Campaign [2.0] current Campaign: Campaign2 Total adGroups in currentCampaign : 3 0.0 matching adGroups whose Ctr is above 0.14 3.0 matching adGroups whose Ctr is below 0.14 The sum of number [3.0] of adGroups below Ctr threshold(0.14) and number of adGroups above [0.0] Ctr threshold has to be equal to the total number of adgroups of the current Campaign [3.0] current Campaign: Campaign3 Total adGroups in currentCampaign : 3 1.0 matching adGroups whose Ctr is above 0.14 2.0 matching adGroups whose Ctr is below 0.14 The sum of number [2.0] of adGroups below Ctr threshold(0.14) and number of adGroups above [1.0] Ctr threshold has to be equal to the total number of adgroups of the current Campaign [3.0] *current Campaign: Campaign4* Total adGroups in currentCampaign : *15* 1.0 matching adGroups whose Ctr is above 0.14 5.0 matching adGroups whose Ctr is below 0.14 The sum of number [5.0] of adGroups below Ctr threshold(0.14) and number of adGroups above [1.0] Ctr threshold has to be equal to the total number of adgroups of the current Campaign [15.0] *current Campaign: Campaign5* Total adGroups in currentCampaign : *27* 1.0 matching adGroups whose Ctr is above 0.14 15.0 matching adGroups whose Ctr is below 0.14 The sum of number [15.0] of adGroups below Ctr threshold(0.14) and number of adGroups above [1.0] Ctr threshold has to be equal to the total number of adgroups of the current Campaign [27.0] As you can see results for Campaign4 and Campaign5 are inconsistent . I think the text is self-explanatory , but if you need more details, please let me know. The point is : Imaging that a Campaign has 10 Adgroups ( Campaign is enabled and all adGroups of the campaign are enabled too). if we take LAST_7_DAYS as a time window , and we have 3 adGroups out of 10 that has Ctr above .014 , when I filter the selection as *.withCondition('Ctr < 0.14)* , the Iterator should return 7 entities , but as you see in the example, it doesn't behave properly in any case. -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and Google+: https://googleadsdeveloper.blogspot.com/ https://plus.google.com/+GoogleAdsDevelopers/posts =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/11e80e72-82b2-4cd4-be37-859566f599af%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
function main() { var account = AdWordsApp.currentAccount(); // Select All Campaigns labeled with OA var campaignIterator = getCampaignsByLabel('OA', { filterPaused : true, onlySearch: false } ); while (campaignIterator.hasNext()) { var campaign = campaignIterator.next(); var currentCampaignName = campaign.getName(); Logger.log("current Campaign: " + currentCampaignName); var withoutFiltersIterator = getAdGroupsFromCampaignName(currentCampaignName, { filterPaused : true }); var adGroupAboveIterator = getAdGroupsFromCampaignName(currentCampaignName, { filterPaused : true, above14 : true }); var adGroupBelowIterator = getAdGroupsFromCampaignName(currentCampaignName, { filterPaused : true, above14 : false }); Logger.log('Total adGroups in currentCampaign : ' + withoutFiltersIterator.totalNumEntities()); // Above Iteration Logger.log("%s matching adGroups whose Ctr is above 0.14 ", adGroupAboveIterator.totalNumEntities()); Logger.log("%s matching adGroups whose Ctr is below 0.14 ", adGroupBelowIterator.totalNumEntities()); Logger.log ("The sum of number [%s] of adGroups below Ctr threshold(0.14) and number of adGroups above [%s] Ctr threshold has to be equal to the total number of adgroups of the current Campaign [%s]", adGroupBelowIterator.totalNumEntities() , adGroupAboveIterator.totalNumEntities() , withoutFiltersIterator.totalNumEntities() ); while (adGroupAboveIterator.hasNext()) { var adGroup = adGroupAboveIterator.next(); var currentAdGroupName = adGroup.getName(); //var stats = adGroup.getStatsFor('LAST_7_DAYS'); //Logger.log(currentAdGroupName + ', ' + stats.getCtr()); } while (adGroupBelowIterator.hasNext()) { var adGroup = adGroupBelowIterator.next(); var currentAdGroupName = adGroup.getName(); //var stats = adGroup.getStatsFor('LAST_7_DAYS'); //Logger.log(currentAdGroupName + ', ' + stats.getCtr()); } } } function getAdGroupFromAdgroupName (adgroupName) { var filterString = 'Name = "' + adgroupName + '"'; return AdWordsApp.adGroups() .withCondition(filterString) .get(); } function getAdGroupsFromCampaignName(campaignName, obj) { var filterString = "CampaignName = '" + campaignName + "'"; if (obj.filterPaused) { filterString += ' AND CampaignStatus = "ENABLED" AND Status = "ENABLED"'; } if (obj.hasOwnProperty("above14")) { var ctrCondition = obj.above14 ? "Ctr > 0.14" : "Ctr < 0.14"; return AdWordsApp.adGroups() .forDateRange('LAST_7_DAYS') .withCondition(filterString) .withCondition(ctrCondition) .get(); } else { return AdWordsApp.adGroups() .forDateRange('LAST_7_DAYS') .withCondition(filterString) .get(); } } function getCampaignsByLabel(label, obj) { var filterString = "LabelNames = '" + label +"'"; if (obj.filterPaused) { filterString += ' AND Status = "ENABLED"'; } return AdWordsApp.campaigns() .withCondition(filterString) .get(); }