Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculate an impression weighted quality score average for a Bing Ads PPC account
function main() {
var time = "LAST_30_DAYS";
var totalImpressions = 0;
var totalQs = 0;
var iterator = BingAdsApp.campaigns().forDateRange(time).withCondition("Impressions > 0").get();
while(iterator.hasNext()) {
var campaign = iterator.next();
var impressions = campaign.getStats().getImpressions();
totalImpressions += impressions;
}
Logger.log("The account had " + totalImpressions + " impressions (" + time + ")");
var kwIter = BingAdsApp.keywords().forDateRange(time).withCondition("Impressions > 0").get();
while(kwIter.hasNext()) {
var keyword = kwIter.next();
var kwText = keyword.getText();
var impressions = keyword.getStats().getImpressions();
var qs = keyword.getQualityScore();
var qsContribution = qs / totalImpressions * 100;
Logger.log(kwText + " " + impressions + " " + qs + " " + qsContribution);
totalQs += qsContribution;
}
Logger.log("Account QS: " + totalQs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.