MCC Level Impression Share Report

217 views
Skip to first unread message

Ethan M.

unread,
Feb 15, 2017, 3:51:55 AM2/15/17
to AdWords Scripts Forum
I'm trying to put together a monthly report that pulls in impression share data at the account level.   When running this script the first result is showing as undefined and the remaining accounts are all reporting the same numbers after the undefined row.  

Any help cleaning this up would be appreciated.

  function main() {
   
var accountIterator = MccApp.accounts().get();
   
var mccAccount = AdWordsApp.currentAccount();
   
while (accountIterator.hasNext()) {
     
var account = accountIterator.next();
     
MccApp.select(account);
     
var accountName = account.getName();


     
Logger.log(accountName + " has a search impression share of " + iShare + " and is missing out on " + iShareBudget + " of traffic due to budget.");


     
var report = AdWordsApp.report(
       
"SELECT SearchImpressionShare, SearchRankLostImpressionShare, SearchBudgetLostImpressionShare " +
       
"FROM ACCOUNT_PERFORMANCE_REPORT " +
       
"DURING THIS_MONTH", {
          includeZeroImpressions
: false
       
});
     
var rows = report.rows();
     
while (rows.hasNext()) {
       
var row = rows.next();
       
var cName = row['CampaignName'];
       
var iShare = row['SearchImpressionShare'];
       
var iShareRank = row['SearchRankLostImpressionShare'];
       
var iShareBudget = row['SearchBudgetLostImpressionShare'];
     
}
   
}
 
}

Results look something like:  


  AdWords CID xxx-xxx-xx1 has a search impression share of undefined and is missing out on undefined of traffic due to budget.

  AdWords CID xxx-xxx-xx2 has a search impression share of < 10% and is missing out on 0.00% of traffic due to budget.

  AdWords CID xxx-xxx-xx3 has a search impression share of 13.06% and is missing out on 83.42% of traffic due to budget.

  AdWords CID xxx-xxx-xx4 has a search impression share of 13.06% and is missing out on 83.42% of traffic due to budget.

  AdWords CID xxx-xxx-xx5 has a search impression share of 13.06% and is missing out on 83.42% of traffic due to budget.

  AdWords CID xxx-xxx-xx6 has a search impression share of 13.06% and is missing out on 83.42% of traffic due to budget.

Paul Justine de Honor

unread,
Feb 15, 2017, 5:43:10 AM2/15/17
to AdWords Scripts Forum
Hi Ethan,

It seems that you called the variable before the declaration which caused to throw an undefined value. You might try to modify your script same as the script below:

 function main() {
   
var accountIterator = MccApp.accounts().get();
   
var mccAccount = AdWordsApp.currentAccount();
   
while (accountIterator.hasNext()) {
     
var account = accountIterator.next();
     
MccApp.select(account);
     
var accountName = account.getName();


     
var report = AdWordsApp.report(

       
"SELECT SearchImpressionShare, SearchRankLostImpressionShare, SearchBudgetLostImpressionShare " +
       
"FROM ACCOUNT_PERFORMANCE_REPORT " +
       
"DURING THIS_MONTH", {
          includeZeroImpressions
: false
       
});
     
var rows = report.rows();
     
while (rows.hasNext()) {
       
var row = rows.next();
       
var cName = row['CampaignName'];
       
var iShare = row['SearchImpressionShare'];
       
var iShareRank = row['SearchRankLostImpressionShare'];
       
var iShareBudget = row['SearchBudgetLostImpressionShare'];

       
Logger.log(accountName + " has a search impression share of " + iShare + " and is missing out on " + iShareBudget + " of traffic due to budget.");
     
}
   
}
 
}

If you encountered any issue, please send the CID along with the name of the script (reply privately to author).

Thanks,
Paul Justine De Honor
AdWords Scripts Team

Ethan M.

unread,
Feb 15, 2017, 12:34:38 PM2/15/17
to AdWords Scripts Forum
I feel a bit silly, but that was it.    Thanks Paul.

Joyce Lava (AdWords Scripts Team)

unread,
Feb 16, 2017, 12:47:42 AM2/16/17
to AdWords Scripts Forum
Hi Ethan,

No worries. Please feel free to let our team know about any concerns you might have about AdWords Scripts and we'll gladly assist you.

Regards,
Joyce Lava
AdWords Scripts Team
Reply all
Reply to author
Forward
0 new messages